示例#1
0
void check_for_changes(char *path)
{
	chdir(path);
	File_t *file_list_one = first_run(path);	// FilesInDirectory(path); 
	for (;;)
	{
		sleep(changes_interval);

		if (debugging)
		{
			puts("PING!");
		}
		
		File_t *file_list_two = files_in_directory(path); 

		compare_file_lists(file_list_one, file_list_two);

		file_list_free(file_list_one);
		if (run_once) {
			file_list_free(file_list_two);
			return;
		}
		file_list_one = file_list_two;
	}
}
示例#2
0
void menu_free(void *data)
{
   menu_handle_t *menu = (menu_handle_t*)data;

   if (!menu)
      return;
  
#ifdef HAVE_SHADER_MANAGER
   if (menu->shader)
      free(menu->shader);
   menu->shader = NULL;
#endif

   if (driver.menu_ctx && driver.menu_ctx->free)
      driver.menu_ctx->free(menu);

#ifdef HAVE_DYNAMIC
   libretro_free_system_info(&g_extern.menu.info);
#endif

   file_list_free(menu->menu_stack);
   file_list_free(menu->selection_buf);

   rarch_main_command(RARCH_CMD_HISTORY_DEINIT);

   if (g_extern.core_info)
      core_info_list_free(g_extern.core_info);

   if (g_extern.core_info_current)
      free(g_extern.core_info_current);

   free(data);
}
示例#3
0
static void menu_list_free_list(file_list_t *list)
{
   unsigned i;

   for (i = 0; i < list->size; i++)
      menu_driver_list_free(list, i, list->size);

   if (list)
      file_list_free(list);
}
示例#4
0
void menu_free(void *data)
{
   rgui_handle_t *rgui = (rgui_handle_t*)data;

   if (!rgui)
      return;

   if (driver.menu_ctx && driver.menu_ctx->free)
      driver.menu_ctx->free(rgui);

#ifdef HAVE_DYNAMIC
   libretro_free_system_info(&rgui->info);
#endif

   file_list_free(rgui->menu_stack);
   file_list_free(rgui->selection_buf);

   rom_history_free(rgui->history);
   core_info_list_free(rgui->core_info);

   free(rgui);
}
示例#5
0
static void menu_list_free_list(file_list_t *list)
{
   unsigned i;

   for (i = 0; i < list->size; i++)
   {
      menu_ctx_list_t list_info;

      list_info.list      = list;
      list_info.idx       = i;
      list_info.list_size = list->size;

      menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info);
   }

   file_list_free(list);
}
示例#6
0
static void menu_list_destroy(file_list_t *list)
{
   unsigned i;
   driver_t *driver = driver_get_ptr();

   if (!list)
      return;

   if (!driver->menu_ctx)
      goto end;

   for (i = 0; i < list->size; i++)
      menu_driver_list_delete(list, i, list->size);

end:
   if (list)
      file_list_free(list);
}
示例#7
0
文件: misc.c 项目: op5/merlin
/* returns the last timestamp of a configuration change */
time_t get_last_cfg_change(void)
{
	time_t mt = 0;
	struct file_list *flist, *base;

	base = flist = get_cfg_files(config_file, NULL);

	for (; flist; flist = flist->next) {
		if (flist->st.st_mtime > mt)
			mt = flist->st.st_mtime;
	}

	if (base)
		file_list_free(base);

	/* 0 if we for some reason failed */
	return mt;
}
示例#8
0
void menu_list_destroy(file_list_t *list)
{
   unsigned i;
   if (!list)
      return;

   if (!driver.menu_ctx)
      goto end;

   for (i = 0; i < list->size; i++)
   {
      if (driver.menu_ctx->list_delete)
         driver.menu_ctx->list_delete(list, i, list->size);
      if (driver.menu_ctx->backend->list_delete)
         driver.menu_ctx->backend->list_delete(list, i, list->size);
   }

end:
   file_list_free(list);
}
示例#9
0
void ozone_refresh_horizontal_list(ozone_handle_t *ozone)
{
   ozone_context_destroy_horizontal_list(ozone);
   if (ozone->horizontal_list)
   {
      ozone_free_list_nodes(ozone->horizontal_list, false);
      file_list_free(ozone->horizontal_list);
   }
   ozone->horizontal_list = NULL;

   menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);

   ozone->horizontal_list         = (file_list_t*)
      calloc(1, sizeof(file_list_t));

   if (ozone->horizontal_list)
      ozone_init_horizontal_list(ozone);

   ozone_context_reset_horizontal_list(ozone);
}
示例#10
0
文件: misc.c 项目: op5/merlin
/*
 * calculate a sha1 hash of the contents of all config files
 * sorted by their full path.
 * *hash must hold at least 20 bytes
 */
int get_config_hash(unsigned char *hash)
{
	struct file_list **sorted_flist;
	unsigned int num_files = 0, i = 0;
	blk_SHA_CTX ctx;

	blk_SHA1_Init(&ctx);

	sorted_flist = get_sorted_oconf_files(&num_files);

	for (i = 0; i < num_files; i++) {
		hash_add_file(sorted_flist[i]->name, &ctx);
		sorted_flist[i]->next = NULL;
		file_list_free(sorted_flist[i]);
	}
	blk_SHA1_Final(hash, &ctx);
	free(sorted_flist);

	return 0;
}
示例#11
0
文件: browser.c 项目: gentoo/pornview
void
browser_destroy (void)
{
    file_list_free (BROWSER_FILE_LIST);

    if (conf.save_win_state)
    {
	conf.window_width = browser->window->allocation.width;
	conf.window_height = browser->window->allocation.height;
	conf.dirtree_width = DIRVIEW_WIDTH;
	conf.dirtree_height = DIRVIEW_HEIGHT;
    }

    if (conf.startup_dir_mode == 1)
    {
	if (conf.startup_dir != NULL)
	{
	    g_free (conf.startup_dir);
	    conf.startup_dir = g_strdup (browser->current_path->str);
	}
    }
    if (browser->current_path)
	g_string_free (browser->current_path, TRUE);

    if (browser->last_path)
	g_string_free (browser->last_path, TRUE);

#ifdef ENABLE_MOVIE
    videoplay_destroy ();
#endif

    imageview_destroy ();
    thumbview_destroy ();
    dirview_destroy ();

    g_free (browser);

    gtk_main_quit ();
}
示例#12
0
QWidget *DriversPage::widget()
{
   unsigned i;
   QWidget          *widget    = new QWidget;
   FormLayout          *layout = new FormLayout;
   file_list_t           *list = (file_list_t*)calloc(1, sizeof(*list));

   menu_displaylist_build_list(
         list, DISPLAYLIST_DRIVER_SETTINGS_LIST);

   for (i = 0; i < list->size; i++)
   {
      menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
         file_list_get_actiondata_at_offset(list, i);

      layout->add(cbs->enum_idx);
   }

   file_list_free(list);

   widget->setLayout(layout);

   return widget;
}
示例#13
0
文件: tuifs.c 项目: AreaScout/vice
/* FIXME: documentation.  */
char *tui_file_selector(const char *title, const char *directory,
                        const char *pattern, const char *default_item,
                        read_contents_func_type contents_func,
                        char **browse_file_return,
                        unsigned int *browse_file_number_return)
{
    static char *return_path = NULL;
    struct file_list *fl;
    int curr_item, first_item, need_update;
    int x, y, width, height, num_cols, num_lines, field_width;
    int num_files;
    char str[0x100];
    int str_len = 0;
    tui_area_t backing_store = NULL;

    if (contents_func != NULL) {
        *browse_file_return = NULL;
    }

    if (browse_file_number_return != NULL) {
        *browse_file_number_return = 0;
    }

    if (directory != NULL) {
        return_path = lib_stralloc(directory);
    } else {
        return_path = ioutil_current_dir();
    }

    slashize_path(&return_path);

    fl = file_list_read(return_path, pattern);
    if (fl == NULL) {
        return NULL;
    }

    first_item = curr_item = 0;
    num_cols = 4;
    field_width = 18;
    num_lines = 17;
    height = num_lines + 2;
    width = field_width * num_cols + 4;
    num_files = num_cols * num_lines;

    if (default_item != NULL && *default_item) {
        int i;

        for (i = 0; i < fl->num_items; i++) {
            if (!strcasecmp(default_item, fl->items[i].name)) {
                curr_item = i;
                while (curr_item - first_item >= num_files) {
                    first_item += num_lines;
                }
                break;
            }
        }
    }

    x = CENTER_X(width);
    y = CENTER_Y(height);

    need_update = 1;

    tui_area_get(&backing_store, x, y, width + 2, height + 1);

    tui_display_window(x, y, width, height, MENU_BORDER, MENU_BACK, title, NULL);

    while (1) {
        int key;

        tui_set_attr(MENU_FORE, MENU_BACK, 0);
        if (need_update) {
            file_selector_display_path(return_path, x + 1, y + height - 1, width - 2);
            file_selector_update(fl, first_item, x + 2, y + 1, field_width, num_lines, num_cols);
            tui_set_attr(FIRST_LINE_FORE, FIRST_LINE_BACK, 0);
            tui_display(0, tui_num_lines() - 1, tui_num_cols(), "\030\031\033\032: Move  <Enter>: Select  %s<Alt>-<letter>: Change drive", contents_func != NULL ? "<Space>: Preview  " : "");
            need_update = 0;
        }
        tui_set_attr(MENU_FORE, MENU_HIGHLIGHT, 0);
        file_selector_display_item(fl, curr_item, first_item, x + 2, y + 1, field_width, num_lines, num_cols);
        key = getkey();
        tui_set_attr(MENU_FORE, MENU_BACK, 0);
        file_selector_display_item(fl, curr_item, first_item, x + 2, y + 1, field_width, num_lines, num_cols);

        switch (key) {
            case K_Escape:
                tui_area_put(backing_store, x, y);
                tui_area_free(backing_store);
                return NULL;
            case K_Left:
                str_len = 0;
                if (curr_item - num_lines >= 0) {
                    curr_item -= num_lines;
                    if (curr_item < first_item) {
                        if (first_item >= num_lines) {
                            first_item -= num_lines;
                            need_update = 1;
                        } else {
                            curr_item += num_lines;
                        }
                    }
                }
                break;
            case K_Up:
                str_len = 0;
                if (curr_item > 0) {
                    curr_item--;
                    if (curr_item < first_item) {
                        first_item = curr_item;
                        need_update = 1;
                    }
                }
                break;
            case K_Right:
                str_len = 0;
                if (curr_item + num_lines < fl->num_used_items) {
                    curr_item += num_lines;
                    if (curr_item - first_item >= num_files) {
                        first_item += num_lines;
                        need_update = 1;
                    }
                }
                break;
            case K_Down:
                str_len = 0;
                if (curr_item < fl->num_used_items - 1) {
                    curr_item++;
                    if (curr_item == first_item + num_files) {
                        first_item++;
                        need_update = 1;
                    }
                }
                break;
            case K_PageDown:
                str_len = 0;
                if (curr_item + num_files < fl->num_used_items) {
                    curr_item += num_files;
                    first_item += num_files;
                }
                need_update = 1;
                break;
            case K_PageUp:
                str_len = 0;
                if (curr_item - num_files >= 0) {
                    curr_item -= num_files;
                    first_item -= num_files;
                    if (first_item < 0) {
                        first_item = 0;
                    }
                    need_update = 1;
                }
                break;
            case K_Home:
                str_len = 0;
                curr_item = 0;
                if (first_item != 0) {
                    first_item = 0;
                    need_update = 1;
                }
                break;
            case K_End:
                str_len = 0;
                curr_item = fl->num_used_items - 1;
                first_item = curr_item - num_files + 1;
                if (first_item < 0) {
                    first_item = 0;
                }
                need_update = 1;
                break;
            case K_Return:
                str_len = 0;
                if (fl->items[curr_item].type == FT_DIR) {
                    struct file_list *new_fl;
                    char *new_path;

                    new_path = change_path(fl, return_path, curr_item);

                    new_fl = file_list_read(new_path, pattern);

                    if (new_fl != NULL) {
                        file_list_free(fl);
                        fl = new_fl;
                        first_item = curr_item = 0;
                        lib_free(return_path);
                        return_path = new_path;
                        need_update = 1;
                        ioutil_chdir(return_path);
                    } else {
                        lib_free(new_path);
                    }
                } else {
                    char *p = util_concat(return_path, fl->items[curr_item].name, NULL);

                    lib_free(return_path);
                    return_path = p;
                    tui_area_put(backing_store, x, y);
                    tui_area_free(backing_store);
                    return return_path;
                }
                break;
            case K_BackSpace:
                if (str_len > 1) {
                    int n;
                    str_len--;
                    n = file_list_find(fl, str, str_len);
                    if (n >= 0) {
                        curr_item = n;
                        if (curr_item < first_item) {
                            first_item = curr_item;
                            need_update = 1;
                        } else if (first_item + num_files <= curr_item) {
                            first_item = curr_item - num_files + 1;
                            need_update = 1;
                        }
                    }
                } else {
                    str_len = 0;
                    curr_item = 0;
                    if (first_item != 0) {
                        first_item = 0;
                        need_update = 1;
                    }
                }
                break;
            case ' ':
                if (contents_func != NULL && fl->items[curr_item].type != FT_DIR && browse_file_return != NULL) {
                    tui_display(0, tui_num_lines() - 1, tui_num_cols(), "");
                    *browse_file_return = tui_image_browser(fl->items[curr_item].name, contents_func, browse_file_number_return);
                    if (*browse_file_return != NULL) {
                        char *p = util_concat(return_path, fl->items[curr_item].name, NULL);

                        lib_free(return_path);
                        return_path = p;
                        tui_area_put(backing_store, x, y);
                        tui_area_free(backing_store);
                        return return_path;
                    }
                    need_update = 1;
                    break;
                } else {
                    tui_beep();
                }
            default:
                {
                    int drive_num;

                    drive_num = alt_key_to_drive_num(key);

                    if (drive_num > 0) {
                        /* `A-a' ... `A-z' change the current drive.  */
                        int num_available_drives;
                        int current_drive;

                        _dos_getdrive(&current_drive);
                        _dos_setdrive(current_drive, &num_available_drives);
                        if (drive_num <= num_available_drives) {
                            char *new_path;

                            /* FIXME: This is a hack...  Maybe there is a cleaner
                               way to do it, but for now I just don't know.  */
                            _dos_setdrive(drive_num, &num_available_drives);
                            new_path = ioutil_current_dir();
                            if (new_path != NULL) {
                                slashize_path(&new_path);
                                _dos_setdrive(current_drive, &num_available_drives);
                                if (new_path != NULL) {
                                    struct file_list *new_fl;

                                    new_fl = file_list_read(new_path, pattern);
                                    if (new_fl != NULL) {
                                        file_list_free(fl);
                                        fl = new_fl;
                                        first_item = curr_item = 0;
                                        lib_free(return_path);
                                        return_path = new_path;
                                        need_update = 1;
                                        ioutil_chdir(return_path);
                                    } else {
                                        lib_free(new_path);
                                    }
                                }
                            } else {
                                _dos_setdrive(current_drive, &num_available_drives);
                                tui_beep();
                            }
                        } else {
                            tui_beep();
                        }
                    } else if (isprint(key) && str_len < 0x100) {
                        int n;

                        str[str_len] = key;
                        n = file_list_find(fl, str, str_len + 1);
                        if (n < 0) {
                            tui_beep();
                        } else {
                            str_len++;
                            curr_item = n;
                            if (curr_item < first_item) {
                                first_item = curr_item;
                                need_update = 1;
                            } else if (first_item + num_files <= curr_item) {
                                first_item = curr_item - num_files + 1;
                                need_update = 1;
                            }
                        }
                    }
                }
                break;
        }
    }
}