Exemple #1
0
/* Checks whether entry corresponds to comparison mismatch.  Returns non-zero if
 * so, otherwise zero is returned. */
static int
is_mismatched_entry(const dir_entry_t *entry)
{
	/* To avoid passing view pointer here, we exploit the fact that entry_to_pos()
	 * checks whether it's argument belongs to the given view. */
	int pos = entry_to_pos(&lwin, entry);
	FileView *other = &rwin;
	if(pos == -1)
	{
		pos = entry_to_pos(&rwin, entry);
		other = &lwin;
	}

	return (other->dir_entry[pos].id != entry->id);
}
Exemple #2
0
int
check_mark_directory(FileView *view, char m)
{
	const mark_t *const mark = get_mark_by_name(m);

	if(is_empty(mark))
	{
		return -1;
	}

	if(flist_custom_active(view))
	{
		dir_entry_t *entry;
		char path[PATH_MAX];
		snprintf(path, sizeof(path), "%s/%s", mark->directory, mark->file);
		entry = entry_from_path(view->dir_entry, view->list_rows, path);
		if(entry != NULL)
		{
			return entry_to_pos(view, entry);
		}
	}
	else if(paths_are_equal(view->curr_dir, mark->directory))
	{
		return find_file_pos_in_list(view, mark->file);
	}

	return -1;
}
Exemple #3
0
/* Loads full list of files into unfiltered list of the view.  Returns position
 * of file under cursor in the unfiltered list. */
static int
load_unfiltered_list(view_t *view)
{
	int current_file_pos = view->list_pos;

	view->local_filter.in_progress = 1;

	view->local_filter.saved = strdup(view->local_filter.filter.raw);

	if(list_is_incomplete(view))
	{
		char full_path[PATH_MAX + 1];
		dir_entry_t *entry;

		get_current_full_path(view, sizeof(full_path), full_path);

		filter_clear(&view->local_filter.filter);
		(void)populate_dir_list(view, 1);

		/* Resolve current file position in updated list. */
		entry = entry_from_path(view, view->dir_entry, view->list_rows, full_path);
		if(entry != NULL)
		{
			current_file_pos = entry_to_pos(view, entry);
		}

		if(current_file_pos >= view->list_rows)
		{
			current_file_pos = view->list_rows - 1;
		}
	}
	else
	{
		/* Save unfiltered (by local filter) list for further use. */
		replace_dir_entries(view, &view->local_filter.entries,
				&view->local_filter.entry_count, view->dir_entry, view->list_rows);
	}

	view->local_filter.unfiltered = view->dir_entry;
	view->local_filter.unfiltered_count = view->list_rows;
	view->local_filter.prefiltered_count = view->filtered;
	view->dir_entry = NULL;

	return current_file_pos;
}
Exemple #4
0
void
files_chmod(FileView *view, const char *mode, int recurse_dirs)
{
	char undo_msg[COMMAND_GROUP_INFO_LEN];
	dir_entry_t *entry;
	size_t len;

	snprintf(undo_msg, sizeof(undo_msg), "chmod in %s: ",
			replace_home_part(flist_get_dir(view)));
	len = strlen(undo_msg);

	ui_cancellation_reset();

	entry = NULL;
	while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested())
	{
		if(len >= 2U && undo_msg[len - 2U] != ':')
		{
			strncat(undo_msg + len, ", ", sizeof(undo_msg) - len - 1);
			len += strlen(undo_msg + len);
		}
		strncat(undo_msg + len, entry->name, sizeof(undo_msg) - len - 1);
		len += strlen(undo_msg + len);
	}

	cmd_group_begin(undo_msg);

	entry = NULL;
	while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested())
	{
		char inv[16];
		snprintf(inv, sizeof(inv), "0%o", entry->mode & 0xff);
		chmod_file_in_list(view, entry_to_pos(view, entry), mode, inv,
				recurse_dirs);
	}

	cmd_group_end();
}
Exemple #5
0
/* Runs each of selected file entries of the view individually. */
static void
run_selection_separately(FileView *view, int dont_execute)
{
	dir_entry_t *entry;

	const int pos = view->list_pos;

	entry = NULL;
	while(iter_selected_entries(view, &entry))
	{
		char *typed_fname;
		const char *entry_prog_cmd;

		typed_fname = get_typed_entry_fpath(entry);
		entry_prog_cmd = ft_get_program(typed_fname);
		free(typed_fname);

		view->list_pos = entry_to_pos(view, entry);
		run_using_prog(view, entry_prog_cmd, dont_execute, 0);
	}

	view->list_pos = pos;
}
Exemple #6
0
/* Changes attributes of files in the view. */
static void
files_attrib(FileView *view, DWORD add, DWORD sub, int recurse_dirs)
{
	char undo_msg[COMMAND_GROUP_INFO_LEN];
	dir_entry_t *entry;
	size_t len;

	snprintf(undo_msg, sizeof(undo_msg), "chmod in %s: ",
			replace_home_part(flist_get_dir(view)));
	len = strlen(undo_msg);

	ui_cancellation_reset();

	entry = NULL;
	while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested())
	{
		if(len >= 2U && undo_msg[len - 2U] != ':')
		{
			strncat(undo_msg + len, ", ", sizeof(undo_msg) - len - 1);
			len += strlen(undo_msg + len);
		}
		strncat(undo_msg + len, entry->name, sizeof(undo_msg) - len - 1);
		len += strlen(undo_msg + len);
	}

	cmd_group_begin(undo_msg);

	entry = NULL;
	while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested())
	{
		attrib_file_in_list(view, entry_to_pos(view, entry), add, sub,
				recurse_dirs);
	}

	cmd_group_end();
}