Пример #1
0
int
show_trashes_menu(view_t *view, int calc_size)
{
	char **trashes;
	int ntrashes;
	int i;

	static menu_data_t m;
	menus_init_data(&m, view,
			format_str("%sNon-empty trash directories", calc_size ? "[  size] " : ""),
			strdup("No non-empty trash directories found"));

	m.execute_handler = &execute_trashes_cb;
	m.key_handler = &trashes_khandler;
	m.extra_data = calc_size;

	trashes = list_trashes(&ntrashes);

	show_progress(NULL, 0);
	for(i = 0; i < ntrashes; i++)
	{
		char *const item = format_item(trashes[i], calc_size);
		m.len = put_into_string_array(&m.items, m.len, item);
	}

	free_string_array(trashes, ntrashes);

	return menus_enter(m.state, view);
}
Пример #2
0
/* Collects files under specified file system tree. */
static void
list_files_recursively(const char path[], int skip_dot_files, strlist_t *list)
{
	int i;

	/* Obtain sorted list of files. */
	int len;
	char **lst = list_sorted_files(path, &len);
	if(len < 0)
	{
		return;
	}

	/* Visit all subdirectories ignoring symbolic links to directories. */
	for(i = 0; i < len && !ui_cancellation_requested(); ++i)
	{
		char *full_path;
		if(skip_dot_files && lst[i][0] == '.')
		{
			update_string(&lst[i], NULL);
			continue;
		}

		full_path = format_str("%s/%s", path, lst[i]);
		if(is_dir(full_path))
		{
			if(!is_symlink(full_path))
			{
				list_files_recursively(full_path, skip_dot_files, list);
			}
			free(full_path);
			update_string(&lst[i], NULL);
		}
		else
		{
			free(lst[i]);
			lst[i] = full_path;
		}

		show_progress("Listing...", 1000);
	}

	/* Append files. */
	for(i = 0; i < len; ++i)
	{
		if(lst[i] != NULL)
		{
			list->nitems = put_into_string_array(&list->items, list->nitems, lst[i]);
		}
	}

	free(lst);
}
Пример #3
0
Файл: ipc.c Проект: jubalh/vifm
static void
parse_data(const char *buf)
{
	char **array = NULL;
	size_t len = 0;
	while(*buf != '\0')
	{
		len = add_to_string_array(&array, len, 1, buf);
		buf += strlen(buf) + 1;
	}
	len = put_into_string_array(&array, len, NULL);
	callback(array);
	free_string_array(array, len);
}
Пример #4
0
/* Callback for listings of bookmarks. */
static void
bmarks_cb(const char path[], const char tags[], time_t timestamp, void *arg)
{
	menu_info *m = arg;
	char *line = format_str("%s: ", replace_home_part_strict(path));
	size_t len = strlen(line);

	char *dup = strdup(tags);
	char *tag = dup, *state = NULL;
	while((tag = split_and_get(tag, ',', &state)) != NULL)
	{
		strappendch(&line, &len, '[');
		strappend(&line, &len, tag);
		strappendch(&line, &len, ']');
	}
	free(dup);

	(void)add_to_string_array(&m->data, m->len, 1, path);
	m->len = put_into_string_array(&m->items, m->len, line);
}
Пример #5
0
int
show_cabbrevs_menu(FileView *view)
{
	void *state;
	const wchar_t *lhs, *rhs;
	int no_remap;

	static menu_data_t m;
	init_menu_data(&m, view, strdup("Abbreviation -- N -- Replacement"),
			strdup("No abbreviation set"));
	m.key_handler = &commands_khandler;

	state = NULL;
	while(vle_abbr_iter(&lhs, &rhs, &no_remap, &state))
	{
		char *const descr = describe_abbrev(lhs, rhs, no_remap, 2);
		m.len = put_into_string_array(&m.items, m.len, descr);
	}

	return display_menu(m.state, view);
}