int fs_init(int argc, char **argv) { char buf[PATH_MAX]; int len; char *ptr; sf_list_def_t def; if (fs.isinited) { sf_log(SF_LOG_WARN, "fs_init: filesystem already initialized."); return SF_OK; } sf_memzero(&def, sizeof(def)); def.size = sizeof(struct directory); def.free = directory_close; sf_list_init(&fs.directories, &def); #ifdef __WIN32__ if (argv[0][1] == ':') { #else if (argv[0][0] == '/') { #endif strncpy(buf, argv[0], PATH_MAX); } else { len = PATH_MAX; getcwd(buf, len); len = strlen(buf); buf[len++] = seperator; buf[len] = '\0'; strncat(buf, argv[0], PATH_MAX - len); } ptr = strrchr(buf, seperator); assert(ptr != NULL); *ptr = '\0'; if (fs_cd(buf) != SF_OK) { sf_list_destroy(&fs.directories); return SF_ERR; } fs.isinited = 1; return SF_OK; } void fs_term(void) { sf_list_destroy(&fs.directories); }
static void ui_toolbox_on_destroy(struct ui *ui) { struct ui_toolbox *tb = (struct ui_toolbox *) ui; sf_list_destroy(&tb->buttons); }