mirror of https://github.com/MidnightCommander/mc
Changed interface of mc_stat() and mc_lstat() functions
...to handle vfs_path_t object as parameter. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
c47bc3778e
commit
eeaad790ab
|
@ -1,6 +1,8 @@
|
|||
#ifndef MC_CONFIG_H
|
||||
#define MC_CONFIG_H
|
||||
|
||||
#include "lib/vfs/vfs.h" /* vfs_path_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define CONFIG_APP_SECTION "Midnight-Commander"
|
||||
|
@ -110,6 +112,7 @@ const char *mc_config_get_home_dir (void);
|
|||
|
||||
char *mc_config_get_full_path (const char *config_name);
|
||||
|
||||
vfs_path_t *mc_config_get_full_vpath (const char *config_name);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
|
|
@ -115,10 +115,17 @@ mc_config_init (const gchar * ini_path)
|
|||
if (ini_path == NULL)
|
||||
return mc_config;
|
||||
|
||||
if (exist_file (ini_path) && mc_stat (ini_path, &st) == 0 && st.st_size != 0)
|
||||
if (exist_file (ini_path))
|
||||
{
|
||||
/* file exists and not empty */
|
||||
g_key_file_load_from_file (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (ini_path);
|
||||
if (mc_stat (vpath, &st) == 0 && st.st_size != 0)
|
||||
{
|
||||
/* file exists and not empty */
|
||||
g_key_file_load_from_file (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
mc_config->ini_path = g_strdup (ini_path);
|
||||
|
|
|
@ -503,3 +503,24 @@ mc_config_get_full_path (const char *config_name)
|
|||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get full path to config file by short name.
|
||||
*
|
||||
* @param config_name short name
|
||||
* @return object with full path to config file
|
||||
*/
|
||||
|
||||
vfs_path_t *
|
||||
mc_config_get_full_vpath (const char *config_name)
|
||||
{
|
||||
vfs_path_t *ret_vpath;
|
||||
char *str_path;
|
||||
|
||||
str_path = mc_config_get_full_path (config_name);
|
||||
|
||||
ret_vpath = vfs_path_from_str(str_path);
|
||||
g_free (str_path);
|
||||
return ret_vpath;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
17
lib/util.c
17
lib/util.c
|
@ -116,14 +116,18 @@ resolve_symlinks (const char *path)
|
|||
int len;
|
||||
struct stat mybuf;
|
||||
const char *p;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (*path != PATH_SEP)
|
||||
return NULL;
|
||||
|
||||
vpath = vfs_path_from_str (path);
|
||||
r = buf = g_malloc (MC_MAXPATHLEN);
|
||||
buf2 = g_malloc (MC_MAXPATHLEN);
|
||||
*r++ = PATH_SEP;
|
||||
*r = 0;
|
||||
p = path;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
q = strchr (p + 1, PATH_SEP);
|
||||
|
@ -135,12 +139,12 @@ resolve_symlinks (const char *path)
|
|||
}
|
||||
c = *q;
|
||||
*q = 0;
|
||||
if (mc_lstat (path, &mybuf) < 0)
|
||||
if (mc_lstat (vpath, &mybuf) < 0)
|
||||
{
|
||||
g_free (buf);
|
||||
g_free (buf2);
|
||||
buf = NULL;
|
||||
*q = c;
|
||||
return NULL;
|
||||
goto ret;
|
||||
}
|
||||
if (!S_ISLNK (mybuf.st_mode))
|
||||
strcpy (r, p + 1);
|
||||
|
@ -150,9 +154,9 @@ resolve_symlinks (const char *path)
|
|||
if (len < 0)
|
||||
{
|
||||
g_free (buf);
|
||||
g_free (buf2);
|
||||
buf = NULL;
|
||||
*q = c;
|
||||
return NULL;
|
||||
goto ret;
|
||||
}
|
||||
buf2[len] = 0;
|
||||
if (*buf2 == PATH_SEP)
|
||||
|
@ -176,7 +180,10 @@ resolve_symlinks (const char *path)
|
|||
strcpy (buf, PATH_SEP_STR);
|
||||
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
||||
*(r - 1) = 0;
|
||||
|
||||
ret:
|
||||
g_free (buf2);
|
||||
vfs_path_free (vpath);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ mc_def_getlocalcopy (const char *filename)
|
|||
ssize_t i;
|
||||
char buffer[8192];
|
||||
struct stat mystat;
|
||||
vfs_path_t *vpath = vfs_path_from_str (filename);
|
||||
|
||||
fdin = mc_open (filename, O_RDONLY | O_LINEAR);
|
||||
if (fdin == -1)
|
||||
|
@ -106,12 +107,14 @@ mc_def_getlocalcopy (const char *filename)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (mc_stat (filename, &mystat) != -1)
|
||||
if (mc_stat (vpath, &mystat) != -1)
|
||||
chmod (tmp, mystat.st_mode);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
return tmp;
|
||||
|
||||
fail:
|
||||
vfs_path_free (vpath);
|
||||
if (fdout != -1)
|
||||
close (fdout);
|
||||
if (fdin != -1)
|
||||
|
@ -556,13 +559,11 @@ mc_closedir (DIR * dirp)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
mc_stat (const char *filename, struct stat *buf)
|
||||
mc_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
int result = -1;
|
||||
vfs_path_t *vpath;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
vpath = vfs_path_from_str (filename);
|
||||
if (vpath == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -575,20 +576,17 @@ mc_stat (const char *filename, struct stat *buf)
|
|||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
}
|
||||
|
||||
vfs_path_free (vpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
mc_lstat (const char *filename, struct stat *buf)
|
||||
mc_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
int result = -1;
|
||||
vfs_path_t *vpath;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
vpath = vfs_path_from_str (filename);
|
||||
if (vpath == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -601,7 +599,6 @@ mc_lstat (const char *filename, struct stat *buf)
|
|||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
}
|
||||
|
||||
vfs_path_free (vpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -538,28 +538,29 @@ _vfs_get_cwd (void)
|
|||
|
||||
path_element = vfs_path_get_by_index (vfs_get_raw_current_dir (), -1);
|
||||
|
||||
if (path_element->class->flags & VFSF_LOCAL)
|
||||
if ((path_element->class->flags & VFSF_LOCAL) != 0)
|
||||
{
|
||||
char *tmp;
|
||||
char *current_dir;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tmp = g_get_current_dir ();
|
||||
if (tmp != NULL)
|
||||
current_dir = g_get_current_dir ();
|
||||
tmp_vpath = vfs_path_from_str (current_dir);
|
||||
g_free (current_dir);
|
||||
|
||||
if (tmp_vpath != NULL)
|
||||
{ /* One of the directories in the path is not readable */
|
||||
struct stat my_stat, my_stat2;
|
||||
|
||||
/* Check if it is O.K. to use the current_dir */
|
||||
if (!(mc_global.vfs.cd_symlinks
|
||||
&& mc_stat (tmp, &my_stat) == 0
|
||||
&& mc_stat (path_element->path, &my_stat2) == 0
|
||||
&& mc_stat (tmp_vpath, &my_stat) == 0
|
||||
&& mc_stat (vfs_get_raw_current_dir (), &my_stat2) == 0
|
||||
&& my_stat.st_ino == my_stat2.st_ino && my_stat.st_dev == my_stat2.st_dev))
|
||||
{
|
||||
vfs_set_raw_current_dir (vfs_path_from_str (tmp));
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
vfs_set_raw_current_dir (tmp_vpath);
|
||||
else
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
}
|
||||
|
||||
return vfs_path_to_str (vfs_get_raw_current_dir ());
|
||||
}
|
||||
|
||||
|
|
|
@ -282,13 +282,13 @@ off_t mc_lseek (int fd, off_t offset, int whence);
|
|||
DIR *mc_opendir (const char *dirname);
|
||||
struct dirent *mc_readdir (DIR * dirp);
|
||||
int mc_closedir (DIR * dir);
|
||||
int mc_stat (const char *path, struct stat *buf);
|
||||
int mc_stat (const vfs_path_t * vpath, struct stat *buf);
|
||||
int mc_mknod (const char *path, mode_t mode, dev_t dev);
|
||||
int mc_link (const char *name1, const char *name2);
|
||||
int mc_mkdir (const char *path, mode_t mode);
|
||||
int mc_rmdir (const char *path);
|
||||
int mc_fstat (int fd, struct stat *buf);
|
||||
int mc_lstat (const char *path, struct stat *buf);
|
||||
int mc_lstat (const vfs_path_t * vpath, struct stat *buf);
|
||||
int mc_symlink (const char *name1, const char *name2);
|
||||
int mc_rename (const char *original, const char *target);
|
||||
int mc_chmod (const char *path, mode_t mode);
|
||||
|
|
|
@ -209,13 +209,13 @@ filename_completion_function (const char *text, int state, input_complete_t flag
|
|||
isdir = 1;
|
||||
isexec = 0;
|
||||
{
|
||||
char *tmp;
|
||||
vfs_path_t *vpath;
|
||||
struct stat tempstat;
|
||||
|
||||
tmp = g_strconcat (dirname, PATH_SEP_STR, entry->d_name, (char *) NULL);
|
||||
canonicalize_pathname (tmp);
|
||||
vpath = vfs_path_build_filename (dirname, entry->d_name, (char *) NULL);
|
||||
|
||||
/* Unix version */
|
||||
if (!mc_stat (tmp, &tempstat))
|
||||
if (mc_stat (vpath, &tempstat) == 0)
|
||||
{
|
||||
uid_t my_uid = getuid ();
|
||||
gid_t my_gid = getgid ();
|
||||
|
@ -235,7 +235,7 @@ filename_completion_function (const char *text, int state, input_complete_t flag
|
|||
/* stat failed, strange. not a dir in any case */
|
||||
isdir = 0;
|
||||
}
|
||||
g_free (tmp);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
if ((flags & INPUT_COMPLETE_COMMANDS) && (isexec || isdir))
|
||||
break;
|
||||
|
|
|
@ -466,13 +466,16 @@ mc_setup_by_args (int argc, char *argv[])
|
|||
{
|
||||
char *fname;
|
||||
struct stat st;
|
||||
vfs_path_t *tmp_vpath, *fname_vpath;
|
||||
|
||||
fname = g_strndup (tmp, p - 1 - tmp);
|
||||
tmp_vpath = vfs_path_from_str (tmp);
|
||||
fname_vpath = vfs_path_from_str (fname);
|
||||
/*
|
||||
* Check that the file before the colon actually exists.
|
||||
* If it doesn't exist, revert to the old behavior.
|
||||
*/
|
||||
if (mc_stat (tmp, &st) == -1 && mc_stat (fname, &st) != -1)
|
||||
if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
|
||||
{
|
||||
mc_run_param0 = fname;
|
||||
mc_args__edit_start_line = atoi (p);
|
||||
|
@ -482,6 +485,8 @@ mc_setup_by_args (int argc, char *argv[])
|
|||
g_free (fname);
|
||||
goto try_plus_filename;
|
||||
}
|
||||
vfs_path_free (tmp_vpath);
|
||||
vfs_path_free (fname_vpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3335,9 +3335,11 @@ do \
|
|||
real_file##n = mc_getlocalcopy (file##n); \
|
||||
if (real_file##n != NULL) \
|
||||
{ \
|
||||
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
|
||||
use_copy##n = 1; \
|
||||
if (mc_stat (real_file##n, &st##n) != 0) \
|
||||
if (mc_stat (tmp_vpath, &st##n) != 0) \
|
||||
use_copy##n = -1; \
|
||||
vfs_path_free (tmp_vpath); \
|
||||
} \
|
||||
} \
|
||||
vfs_path_free(vpath); \
|
||||
|
@ -3353,9 +3355,11 @@ do \
|
|||
if (use_copy##n > 0) \
|
||||
{ \
|
||||
time_t mtime; \
|
||||
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
|
||||
mtime = st##n.st_mtime; \
|
||||
if (mc_stat (real_file##n, &st##n) == 0) \
|
||||
if (mc_stat (tmp_vpath, &st##n) == 0) \
|
||||
changed = (mtime != st##n.st_mtime); \
|
||||
vfs_path_free (tmp_vpath); \
|
||||
} \
|
||||
mc_ungetlocalcopy (file##n, real_file##n, changed); \
|
||||
g_free (real_file##n); \
|
||||
|
|
|
@ -1833,8 +1833,10 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||
long curs;
|
||||
long start_mark, end_mark;
|
||||
struct stat status;
|
||||
vfs_path_t *block_file_vpath;
|
||||
|
||||
block_file = mc_config_get_full_path (EDIT_BLOCK_FILE);
|
||||
block_file_vpath = vfs_path_from_str (block_file);
|
||||
curs = edit->curs1;
|
||||
nomark = eval_marks (edit, &start_mark, &end_mark);
|
||||
if (nomark == 0)
|
||||
|
@ -1842,7 +1844,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||
|
||||
/* run shell scripts from menu */
|
||||
if (user_menu_cmd (edit, menu_file, selected_entry)
|
||||
&& (mc_stat (block_file, &status) == 0) && (status.st_size != 0))
|
||||
&& (mc_stat (block_file_vpath, &status) == 0) && (status.st_size != 0))
|
||||
{
|
||||
int rc = 0;
|
||||
FILE *fd;
|
||||
|
@ -1869,6 +1871,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
g_free (block_file);
|
||||
vfs_path_free (block_file_vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -124,6 +124,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
char *savename = 0;
|
||||
gchar *real_filename;
|
||||
int this_save_mode, fd = -1;
|
||||
vfs_path_t *real_filename_vpath;
|
||||
|
||||
if (!filename)
|
||||
return 0;
|
||||
|
@ -138,12 +139,13 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
{
|
||||
real_filename = g_strdup (filename);
|
||||
}
|
||||
real_filename_vpath = vfs_path_from_str (real_filename);
|
||||
|
||||
this_save_mode = option_save_mode;
|
||||
if (this_save_mode != EDIT_QUICK_SAVE)
|
||||
{
|
||||
vfs_path_t *vpath = vfs_path_from_str (real_filename);
|
||||
if (!vfs_file_is_local (vpath) || (fd = mc_open (real_filename, O_RDONLY | O_BINARY)) == -1)
|
||||
if (!vfs_file_is_local (real_filename_vpath)
|
||||
|| (fd = mc_open (real_filename, O_RDONLY | O_BINARY)) == -1)
|
||||
{
|
||||
/*
|
||||
* The file does not exists yet, so no safe save or
|
||||
|
@ -151,7 +153,6 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
*/
|
||||
this_save_mode = EDIT_QUICK_SAVE;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
if (fd != -1)
|
||||
mc_close (fd);
|
||||
}
|
||||
|
@ -161,7 +162,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
int rv;
|
||||
struct stat sb;
|
||||
|
||||
rv = mc_stat (real_filename, &sb);
|
||||
rv = mc_stat (real_filename_vpath, &sb);
|
||||
if (rv == 0 && sb.st_nlink > 1)
|
||||
{
|
||||
rv = edit_query_dialog3 (_("Warning"),
|
||||
|
@ -177,6 +178,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
break;
|
||||
default:
|
||||
g_free (real_filename);
|
||||
vfs_path_free (real_filename_vpath);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -194,6 +196,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
if (rv != 0)
|
||||
{
|
||||
g_free (real_filename);
|
||||
vfs_path_free (real_filename_vpath);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +221,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
if (!savename)
|
||||
{
|
||||
g_free (real_filename);
|
||||
vfs_path_free (real_filename_vpath);
|
||||
return 0;
|
||||
}
|
||||
/* FIXME:
|
||||
|
@ -276,6 +280,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
}
|
||||
else if (edit->lb == LB_ASIS)
|
||||
{ /* do not change line breaks */
|
||||
vfs_path_t *savename_vpath;
|
||||
long buf;
|
||||
buf = 0;
|
||||
filelen = edit->last_byte;
|
||||
|
@ -323,8 +328,13 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
goto error_save;
|
||||
|
||||
/* Update the file information, especially the mtime. */
|
||||
if (mc_stat (savename, &edit->stat1) == -1)
|
||||
savename_vpath = vfs_path_from_str (savename);
|
||||
if (mc_stat (savename_vpath, &edit->stat1) == -1)
|
||||
{
|
||||
vfs_path_free (savename_vpath);
|
||||
goto error_save;
|
||||
}
|
||||
vfs_path_free (savename_vpath);
|
||||
}
|
||||
else
|
||||
{ /* change line breaks */
|
||||
|
@ -369,6 +379,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
goto error_save;
|
||||
g_free (savename);
|
||||
g_free (real_filename);
|
||||
vfs_path_free (real_filename_vpath);
|
||||
return 1;
|
||||
error_save:
|
||||
/* FIXME: Is this safe ?
|
||||
|
@ -376,6 +387,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||
* mc_unlink (savename);
|
||||
*/
|
||||
g_free (real_filename);
|
||||
vfs_path_free (real_filename_vpath);
|
||||
g_free (savename);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -443,6 +443,7 @@ execute_with_vfs_arg (const char *command, const char *filename)
|
|||
struct stat st;
|
||||
time_t mtime;
|
||||
vfs_path_t *vpath = vfs_path_from_str (filename);
|
||||
vfs_path_t *localcopy_vpath;
|
||||
|
||||
/* Simplest case, this file is local */
|
||||
if (!filename || vfs_file_is_local (vpath))
|
||||
|
@ -465,6 +466,7 @@ execute_with_vfs_arg (const char *command, const char *filename)
|
|||
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"), filename);
|
||||
return;
|
||||
}
|
||||
localcopy_vpath = vfs_path_from_str (localcopy);
|
||||
|
||||
/*
|
||||
* filename can be an entry on panel, it can be changed by executing
|
||||
|
@ -472,12 +474,13 @@ execute_with_vfs_arg (const char *command, const char *filename)
|
|||
* below unnecessary.
|
||||
*/
|
||||
fn = g_strdup (filename);
|
||||
mc_stat (localcopy, &st);
|
||||
mc_stat (localcopy_vpath, &st);
|
||||
mtime = st.st_mtime;
|
||||
do_execute (command, localcopy, EXECUTE_INTERNAL);
|
||||
mc_stat (localcopy, &st);
|
||||
mc_stat (localcopy_vpath, &st);
|
||||
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
|
||||
g_free (localcopy);
|
||||
vfs_path_free (localcopy_vpath);
|
||||
g_free (fn);
|
||||
}
|
||||
|
||||
|
|
|
@ -743,10 +743,16 @@ apply_advanced_chowns (struct stat *sf)
|
|||
|
||||
do
|
||||
{
|
||||
lc_fname = next_file ();
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (mc_stat (lc_fname, sf) != 0)
|
||||
lc_fname = next_file ();
|
||||
vpath = vfs_path_from_str (lc_fname);
|
||||
|
||||
if (mc_stat (vpath, sf) != 0)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
ch_cmode = sf->st_mode;
|
||||
if (mc_chmod (lc_fname, get_mode ()) == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||
|
@ -758,6 +764,7 @@ apply_advanced_chowns (struct stat *sf)
|
|||
lc_fname, unix_error_string (errno));
|
||||
|
||||
do_file_mark (current_panel, current_file, 0);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
while (current_panel->marked);
|
||||
}
|
||||
|
@ -774,16 +781,19 @@ chown_advanced_cmd (void)
|
|||
|
||||
do
|
||||
{ /* do while any files remaining */
|
||||
vfs_path_t *vpath;
|
||||
init_chown_advanced ();
|
||||
|
||||
if (current_panel->marked)
|
||||
fname = next_file (); /* next marked file */
|
||||
else
|
||||
fname = selection (current_panel)->fname; /* single file */
|
||||
vpath = vfs_path_from_str (fname);
|
||||
|
||||
if (mc_stat (fname, sf_stat) != 0)
|
||||
if (mc_stat (vpath, sf_stat) != 0)
|
||||
{ /* get status of file */
|
||||
destroy_dlg (ch_dlg);
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
ch_cmode = sf_stat->st_mode;
|
||||
|
@ -827,6 +837,8 @@ chown_advanced_cmd (void)
|
|||
need_update = 1;
|
||||
}
|
||||
destroy_dlg (ch_dlg);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
}
|
||||
while (current_panel->marked && !end_chown);
|
||||
|
||||
|
|
|
@ -389,9 +389,14 @@ apply_mask (struct stat *sf)
|
|||
do
|
||||
{
|
||||
char *fname;
|
||||
vfs_path_t *vpath;
|
||||
gboolean ok;
|
||||
|
||||
fname = next_file ();
|
||||
if (mc_stat (fname, sf) != 0)
|
||||
vpath = vfs_path_from_str (fname);
|
||||
ok = (mc_stat (vpath, sf) == 0);
|
||||
vfs_path_free (vpath);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
c_stat = sf->st_mode;
|
||||
|
@ -412,6 +417,7 @@ chmod_cmd (void)
|
|||
|
||||
do
|
||||
{ /* do while any files remaining */
|
||||
vfs_path_t *vpath;
|
||||
Dlg_head *ch_dlg;
|
||||
struct stat sf_stat;
|
||||
char *fname;
|
||||
|
@ -430,8 +436,14 @@ chmod_cmd (void)
|
|||
else
|
||||
fname = selection (current_panel)->fname; /* single file */
|
||||
|
||||
if (mc_stat (fname, &sf_stat) != 0)
|
||||
vpath = vfs_path_from_str (fname);
|
||||
|
||||
if (mc_stat (vpath, &sf_stat) != 0)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
||||
c_stat = sf_stat.st_mode;
|
||||
|
||||
|
|
|
@ -284,6 +284,7 @@ chown_cmd (void)
|
|||
|
||||
do
|
||||
{ /* do while any files remaining */
|
||||
vfs_path_t *vpath;
|
||||
ch_dlg = init_chown ();
|
||||
new_user = new_group = -1;
|
||||
|
||||
|
@ -292,11 +293,14 @@ chown_cmd (void)
|
|||
else
|
||||
fname = selection (current_panel)->fname; /* single file */
|
||||
|
||||
if (mc_stat (fname, &sf_stat) != 0)
|
||||
vpath = vfs_path_from_str (fname);
|
||||
if (mc_stat (vpath, &sf_stat) != 0)
|
||||
{ /* get status of file */
|
||||
destroy_dlg (ch_dlg);
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
||||
/* select in listboxes */
|
||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
||||
|
|
|
@ -141,6 +141,8 @@ static int
|
|||
handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (dp->d_name[0] == '.' && dp->d_name[1] == 0)
|
||||
return 0;
|
||||
if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0)
|
||||
|
@ -150,7 +152,8 @@ handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
|||
if (!panels_options.show_backups && dp->d_name[NLENGTH (dp) - 1] == '~')
|
||||
return 0;
|
||||
|
||||
if (mc_lstat (dp->d_name, buf1) == -1)
|
||||
vpath = vfs_path_from_str (dp->d_name);
|
||||
if (mc_lstat (vpath, buf1) == -1)
|
||||
{
|
||||
/*
|
||||
* lstat() fails - such entries should be identified by
|
||||
|
@ -169,11 +172,12 @@ handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
|||
if (S_ISLNK (buf1->st_mode))
|
||||
{
|
||||
struct stat buf2;
|
||||
if (!mc_stat (dp->d_name, &buf2))
|
||||
if (mc_stat (vpath, &buf2) == 0)
|
||||
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||
else
|
||||
*stale_link = 1;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && (fltr != NULL)
|
||||
&& !mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB))
|
||||
return 0;
|
||||
|
@ -199,13 +203,12 @@ get_dotdot_dir_stat (const char *path, struct stat *st)
|
|||
|
||||
if ((path != NULL) && (path[0] != '\0') && (st != NULL))
|
||||
{
|
||||
char *dotdot_dir;
|
||||
vfs_path_t *vpath;
|
||||
struct stat s;
|
||||
|
||||
dotdot_dir = g_strdup_printf ("%s/../", path);
|
||||
canonicalize_pathname (dotdot_dir);
|
||||
ret = mc_stat (dotdot_dir, &s) == 0;
|
||||
g_free (dotdot_dir);
|
||||
vpath = vfs_path_build_filename (path, "..", NULL);
|
||||
ret = mc_stat (vpath, &s) == 0;
|
||||
vfs_path_free (vpath);
|
||||
*st = s;
|
||||
}
|
||||
|
||||
|
@ -480,12 +483,19 @@ int
|
|||
handle_path (dir_list * list, const char *path,
|
||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (path[0] == '.' && path[1] == 0)
|
||||
return 0;
|
||||
if (path[0] == '.' && path[1] == '.' && path[2] == 0)
|
||||
return 0;
|
||||
if (mc_lstat (path, buf1) == -1)
|
||||
|
||||
vpath = vfs_path_from_str (path);
|
||||
if (mc_lstat (vpath, buf1) == -1)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (S_ISDIR (buf1->st_mode))
|
||||
tree_store_mark_checked (path);
|
||||
|
@ -496,17 +506,18 @@ handle_path (dir_list * list, const char *path,
|
|||
if (S_ISLNK (buf1->st_mode))
|
||||
{
|
||||
struct stat buf2;
|
||||
if (!mc_stat (path, &buf2))
|
||||
if (mc_stat (vpath, &buf2) == 0)
|
||||
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||
else
|
||||
*stale_link = 1;
|
||||
}
|
||||
|
||||
vfs_path_free (vpath);
|
||||
|
||||
/* Need to grow the *list? */
|
||||
if (next_free == list->size)
|
||||
{
|
||||
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
|
||||
if (list->list == NULL)
|
||||
return -1;
|
||||
list->size += RESIZE_STEPS;
|
||||
}
|
||||
|
@ -587,9 +598,14 @@ gboolean
|
|||
if_link_is_exe (const char *full_name, const file_entry * file)
|
||||
{
|
||||
struct stat b;
|
||||
vfs_path_t *vpath = vfs_path_from_str (full_name);
|
||||
|
||||
if (S_ISLNK (file->st.st_mode) && mc_stat (full_name, &b) == 0)
|
||||
if (S_ISLNK (file->st.st_mode) && mc_stat (vpath, &b) == 0)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return is_exe (b.st_mode);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||
{
|
||||
if (do_local_copy)
|
||||
{
|
||||
vfs_path_t *vpath_local;
|
||||
localcopy = mc_getlocalcopy (filename);
|
||||
if (localcopy == NULL)
|
||||
{
|
||||
|
@ -237,9 +238,11 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||
vfs_path_free (vpath);
|
||||
return;
|
||||
}
|
||||
mc_stat (localcopy, &mystat);
|
||||
vpath_local = vfs_path_from_str (localcopy);
|
||||
mc_stat (vpath_local, &mystat);
|
||||
localmtime = mystat.st_mtime;
|
||||
text = quote_func (localcopy, 0);
|
||||
vfs_path_free (vpath_local);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -377,8 +380,12 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||
|
||||
if (localcopy)
|
||||
{
|
||||
mc_stat (localcopy, &mystat);
|
||||
vfs_path_t *vpath_local;
|
||||
|
||||
vpath_local = vfs_path_from_str (localcopy);
|
||||
mc_stat (vpath_local, &mystat);
|
||||
mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);
|
||||
vfs_path_free (vpath_local);
|
||||
g_free (localcopy);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
@ -698,7 +705,14 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
|||
g_free (title);
|
||||
}
|
||||
}
|
||||
mc_stat (filename, &mystat);
|
||||
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (filename);
|
||||
mc_stat (vpath, &mystat);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
include_target = NULL;
|
||||
include_target_len = 0;
|
||||
|
|
|
@ -293,12 +293,14 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat)
|
|||
if (lp->vfs == my_vfs && lp->ino == ino && lp->dev == dev)
|
||||
{
|
||||
struct vfs_class *lp_name_class;
|
||||
int stat_result;
|
||||
|
||||
vpath = vfs_path_from_str (lp->name);
|
||||
lp_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||
stat_result = mc_stat (vpath, &link_stat);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
if (!mc_stat (lp->name, &link_stat) && link_stat.st_ino == ino
|
||||
if (!stat_result && link_stat.st_ino == ino
|
||||
&& link_stat.st_dev == dev && lp_name_class == my_vfs)
|
||||
{
|
||||
struct vfs_class *p_class, *dst_name_class;
|
||||
|
@ -306,22 +308,26 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat)
|
|||
p = strchr (lp->name, 0) + 1; /* i.e. where the `name' file
|
||||
was copied to */
|
||||
|
||||
vpath = vfs_path_from_str (p);
|
||||
p_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str (dst_name);
|
||||
dst_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str (p);
|
||||
p_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||
|
||||
if (dst_name_class == p_class)
|
||||
{
|
||||
if (!mc_stat (p, &link_stat))
|
||||
if (!mc_stat (vpath, &link_stat))
|
||||
{
|
||||
if (!mc_link (p, dst_name))
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
||||
}
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot make the hardlink"));
|
||||
return FALSE;
|
||||
|
@ -361,7 +367,10 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||
struct stat sb;
|
||||
gboolean dst_is_symlink;
|
||||
|
||||
dst_is_symlink = (mc_lstat (dst_path, &sb) == 0) && S_ISLNK (sb.st_mode);
|
||||
vfs_path_t *src_vpath = vfs_path_from_str (src_path);
|
||||
vfs_path_t *dst_vpath = vfs_path_from_str (dst_path);
|
||||
|
||||
dst_is_symlink = (mc_lstat (dst_vpath, &sb) == 0) && S_ISLNK (sb.st_mode);
|
||||
|
||||
retry_src_readlink:
|
||||
len = mc_readlink (src_path, link_target, MC_MAXPATHLEN - 1);
|
||||
|
@ -383,18 +392,14 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||
|
||||
if (ctx->stable_symlinks)
|
||||
{
|
||||
vfs_path_t *vpath1 = vfs_path_from_str (src_path);
|
||||
vfs_path_t *vpath2 = vfs_path_from_str (dst_path);
|
||||
|
||||
if (!vfs_file_is_local (vpath1) || !vfs_file_is_local (vpath2))
|
||||
if (!vfs_file_is_local (src_vpath) || !vfs_file_is_local (dst_vpath))
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR,
|
||||
_("Cannot make stable symlinks across"
|
||||
"non-local filesystems:\n\nOption Stable Symlinks will be disabled"));
|
||||
ctx->stable_symlinks = FALSE;
|
||||
}
|
||||
vfs_path_free (vpath1);
|
||||
vfs_path_free (vpath2);
|
||||
}
|
||||
|
||||
if (ctx->stable_symlinks && !g_path_is_absolute (link_target))
|
||||
|
@ -432,8 +437,12 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||
}
|
||||
retry_dst_symlink:
|
||||
if (mc_symlink (link_target, dst_path) == 0)
|
||||
{
|
||||
/* Success */
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return FILE_CONT;
|
||||
}
|
||||
/*
|
||||
* if dst_exists, it is obvious that this had failed.
|
||||
* We can delete the old symlink and try again...
|
||||
|
@ -442,8 +451,13 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||
{
|
||||
if (!mc_unlink (dst_path))
|
||||
if (mc_symlink (link_target, dst_path) == 0)
|
||||
{
|
||||
/* Success */
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
|
||||
return FILE_CONT;
|
||||
}
|
||||
}
|
||||
if (ctx->skip_all)
|
||||
return_status = FILE_SKIPALL;
|
||||
|
@ -455,6 +469,8 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||
if (return_status == FILE_RETRY)
|
||||
goto retry_dst_symlink;
|
||||
}
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
|
@ -774,6 +790,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
FileProgressStatus return_status = FILE_CONT;
|
||||
gboolean copy_done = FALSE;
|
||||
gboolean old_ask_overwrite;
|
||||
vfs_path_t *src_vpath, *dst_vpath;
|
||||
|
||||
file_progress_show_source (ctx, s);
|
||||
file_progress_show_target (ctx, d);
|
||||
|
@ -781,8 +798,10 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
return FILE_ABORT;
|
||||
|
||||
mc_refresh ();
|
||||
src_vpath = vfs_path_from_str (s);
|
||||
dst_vpath = vfs_path_from_str (d);
|
||||
|
||||
while (mc_lstat (s, &src_stats) != 0)
|
||||
while (mc_lstat (src_vpath, &src_stats) != 0)
|
||||
{
|
||||
/* Source doesn't exist */
|
||||
if (ctx->skip_all)
|
||||
|
@ -794,10 +813,14 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
ctx->skip_all = TRUE;
|
||||
}
|
||||
if (return_status != FILE_RETRY)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
}
|
||||
|
||||
if (mc_lstat (d, &dst_stats) == 0)
|
||||
if (mc_lstat (dst_vpath, &dst_stats) == 0)
|
||||
{
|
||||
if (src_stats.st_dev == dst_stats.st_dev && src_stats.st_ino == dst_stats.st_ino)
|
||||
return warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same file"), s, d);
|
||||
|
@ -806,6 +829,8 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot overwrite directory \"%s\""), d);
|
||||
do_refresh ();
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return FILE_SKIP;
|
||||
}
|
||||
|
||||
|
@ -813,7 +838,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
{
|
||||
return_status = query_replace (ctx, d, &src_stats, &dst_stats);
|
||||
if (return_status != FILE_CONT)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
}
|
||||
/* Ok to overwrite */
|
||||
}
|
||||
|
@ -826,11 +855,19 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
if (return_status == FILE_CONT)
|
||||
goto retry_src_remove;
|
||||
else
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
}
|
||||
|
||||
if (mc_rename (s, d) == 0)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return progress_update_one (tctx, ctx, src_stats.st_size);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* Comparison to EXDEV seems not to work in nfs if you're moving from
|
||||
|
@ -852,6 +889,9 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
if (return_status == FILE_RETRY)
|
||||
goto retry_rename;
|
||||
}
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
|
||||
return return_status;
|
||||
}
|
||||
#endif
|
||||
|
@ -862,7 +902,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
return_status = copy_file_file (tctx, ctx, s, d);
|
||||
tctx->ask_overwrite = old_ask_overwrite;
|
||||
if (return_status != FILE_CONT)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
copy_done = TRUE;
|
||||
|
||||
|
@ -871,7 +915,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
|
||||
return_status = check_progress_buttons (ctx);
|
||||
if (return_status != FILE_CONT)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
mc_refresh ();
|
||||
|
||||
|
@ -883,12 +931,18 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||
goto retry_src_remove;
|
||||
if (return_status == FILE_SKIPALL)
|
||||
ctx->skip_all = TRUE;
|
||||
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
if (!copy_done)
|
||||
return_status = progress_update_one (tctx, ctx, src_stats.st_size);
|
||||
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
|
||||
return return_status;
|
||||
}
|
||||
|
||||
|
@ -903,13 +957,14 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
{
|
||||
int return_status;
|
||||
struct stat buf;
|
||||
vfs_path_t *vpath = vfs_path_from_str (s);
|
||||
|
||||
file_progress_show_deleting (ctx, s);
|
||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||
return FILE_ABORT;
|
||||
mc_refresh ();
|
||||
|
||||
if (tctx->progress_count != 0 && mc_lstat (s, &buf) != 0)
|
||||
if (tctx->progress_count != 0 && mc_lstat (vpath, &buf) != 0)
|
||||
{
|
||||
/* ignore, most likely the mc_unlink fails, too */
|
||||
buf.st_size = 0;
|
||||
|
@ -919,7 +974,10 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
{
|
||||
return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s);
|
||||
if (return_status == FILE_ABORT)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return return_status;
|
||||
}
|
||||
if (return_status == FILE_RETRY)
|
||||
continue;
|
||||
if (return_status == FILE_SKIPALL)
|
||||
|
@ -927,6 +985,7 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
break;
|
||||
}
|
||||
|
||||
vfs_path_free (vpath);
|
||||
if (tctx->progress_count == 0)
|
||||
return FILE_CONT;
|
||||
return progress_update_one (tctx, ctx, buf.st_size);
|
||||
|
@ -948,40 +1007,55 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
DIR *reading;
|
||||
char *path;
|
||||
FileProgressStatus return_status = FILE_CONT;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (!strcmp (s, ".."))
|
||||
if (strcmp (s, "..") == 0)
|
||||
return FILE_RETRY;
|
||||
|
||||
vpath = vfs_path_from_str (s);
|
||||
reading = mc_opendir (s);
|
||||
|
||||
if (!reading)
|
||||
return FILE_RETRY;
|
||||
if (reading == NULL)
|
||||
{
|
||||
return_status = FILE_RETRY;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
if (!strcmp (next->d_name, "."))
|
||||
continue;
|
||||
if (!strcmp (next->d_name, ".."))
|
||||
continue;
|
||||
path = concat_dir_and_file (s, next->d_name);
|
||||
if (mc_lstat (path, &buf))
|
||||
tmp_vpath = vfs_path_from_str (path);
|
||||
if (mc_lstat (tmp_vpath, &buf) != 0)
|
||||
{
|
||||
g_free (path);
|
||||
mc_closedir (reading);
|
||||
return FILE_RETRY;
|
||||
vfs_path_free (tmp_vpath);
|
||||
return_status = FILE_RETRY;
|
||||
goto ret;
|
||||
}
|
||||
if (S_ISDIR (buf.st_mode))
|
||||
return_status = recursive_erase (tctx, ctx, path);
|
||||
else
|
||||
return_status = erase_file (tctx, ctx, path);
|
||||
vfs_path_free (tmp_vpath);
|
||||
g_free (path);
|
||||
}
|
||||
mc_closedir (reading);
|
||||
if (return_status == FILE_ABORT)
|
||||
return return_status;
|
||||
goto ret;
|
||||
|
||||
file_progress_show_deleting (ctx, s);
|
||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||
return FILE_ABORT;
|
||||
{
|
||||
return_status = FILE_ABORT;
|
||||
goto ret;
|
||||
}
|
||||
mc_refresh ();
|
||||
|
||||
while (my_rmdir (s) != 0 && !ctx->skip_all)
|
||||
|
@ -990,13 +1064,15 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||
if (return_status == FILE_RETRY)
|
||||
continue;
|
||||
if (return_status == FILE_ABORT)
|
||||
return return_status;
|
||||
goto ret;
|
||||
if (return_status == FILE_SKIPALL)
|
||||
ctx->skip_all = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FILE_CONT;
|
||||
ret:
|
||||
vfs_path_free (vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1334,6 +1410,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||
dest_status_t dst_status = DEST_NONE;
|
||||
int open_flags;
|
||||
gboolean is_first_time = TRUE;
|
||||
vfs_path_t *src_vpath, *dst_vpath;
|
||||
|
||||
/* FIXME: We should not be using global variables! */
|
||||
ctx->do_reget = 0;
|
||||
|
@ -1346,7 +1423,8 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||
|
||||
mc_refresh ();
|
||||
|
||||
while (mc_stat (dst_path, &sb2) == 0)
|
||||
dst_vpath = vfs_path_from_str (dst_path);
|
||||
while (mc_stat (dst_vpath, &sb2) == 0)
|
||||
{
|
||||
if (S_ISDIR (sb2.st_mode))
|
||||
{
|
||||
|
@ -1365,8 +1443,10 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||
dst_exists = TRUE;
|
||||
break;
|
||||
}
|
||||
vfs_path_free (dst_vpath);
|
||||
|
||||
while ((*ctx->stat_func) (src_path, &sb) != 0)
|
||||
src_vpath = vfs_path_from_str (src_path);
|
||||
while ((*ctx->stat_func) (src_vpath, &sb) != 0)
|
||||
{
|
||||
if (ctx->skip_all)
|
||||
return_status = FILE_SKIPALL;
|
||||
|
@ -1377,8 +1457,12 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||
ctx->skip_all = TRUE;
|
||||
}
|
||||
if (return_status != FILE_RETRY)
|
||||
{
|
||||
vfs_path_free (src_vpath);
|
||||
return return_status;
|
||||
}
|
||||
}
|
||||
vfs_path_free (src_vpath);
|
||||
|
||||
if (dst_exists)
|
||||
{
|
||||
|
@ -1807,12 +1891,17 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
struct utimbuf utb;
|
||||
struct link *lp;
|
||||
char *d;
|
||||
vfs_path_t *src_vpath, *dst_vpath;
|
||||
|
||||
d = g_strdup (_d);
|
||||
|
||||
src_vpath = vfs_path_from_str (s);
|
||||
dst_vpath = vfs_path_from_str (_d);
|
||||
|
||||
/* First get the mode of the source dir */
|
||||
|
||||
retry_src_stat:
|
||||
if ((*ctx->stat_func) (s, &cbuf) != 0)
|
||||
if ((*ctx->stat_func) (src_vpath, &cbuf) != 0)
|
||||
{
|
||||
if (ctx->skip_all)
|
||||
return_status = FILE_SKIPALL;
|
||||
|
@ -1870,11 +1959,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
}
|
||||
|
||||
lp = g_new (struct link, 1);
|
||||
{
|
||||
vfs_path_t *vpath = vfs_path_from_str (s);
|
||||
lp->vfs = vfs_path_get_by_index (vpath, -1)->class;
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
lp->vfs = vfs_path_get_by_index (src_vpath, -1)->class;
|
||||
lp->ino = cbuf.st_ino;
|
||||
lp->dev = cbuf.st_dev;
|
||||
lp->next = parent_dirs;
|
||||
|
@ -1882,7 +1967,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
|
||||
retry_dst_stat:
|
||||
/* Now, check if the dest dir exists, if not, create it. */
|
||||
if (mc_stat (d, &buf))
|
||||
if (mc_stat (dst_vpath, &buf) != 0)
|
||||
{
|
||||
/* Here the dir doesn't exist : make it ! */
|
||||
if (move_over)
|
||||
|
@ -1947,11 +2032,12 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
}
|
||||
|
||||
lp = g_new (struct link, 1);
|
||||
mc_stat (dest_dir, &buf);
|
||||
{
|
||||
vfs_path_t *vpath = vfs_path_from_str (dest_dir);
|
||||
lp->vfs = vfs_path_get_by_index (vpath, -1)->class;
|
||||
vfs_path_free (vpath);
|
||||
vfs_path_t *tmp_vpath = vfs_path_from_str (dest_dir);
|
||||
mc_stat (tmp_vpath, &buf);
|
||||
|
||||
lp->vfs = vfs_path_get_by_index (tmp_vpath, -1)->class;
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
lp->ino = buf.st_ino;
|
||||
lp->dev = buf.st_dev;
|
||||
|
@ -1985,6 +2071,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
||||
{
|
||||
char *path;
|
||||
vfs_path_t *tmp_vpath;
|
||||
/*
|
||||
* Now, we don't want '.' and '..' to be created / copied at any time
|
||||
*/
|
||||
|
@ -1995,8 +2082,9 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
|
||||
/* get the filename and add it to the src directory */
|
||||
path = concat_dir_and_file (s, next->d_name);
|
||||
tmp_vpath = vfs_path_from_str (path);
|
||||
|
||||
(*ctx->stat_func) (path, &buf);
|
||||
(*ctx->stat_func) (tmp_vpath, &buf);
|
||||
if (S_ISDIR (buf.st_mode))
|
||||
{
|
||||
char *mdpath;
|
||||
|
@ -2049,6 +2137,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
}
|
||||
}
|
||||
g_free (path);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
mc_closedir (reading);
|
||||
|
||||
|
@ -2072,6 +2161,8 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
g_free (parent_dirs);
|
||||
ret_fast:
|
||||
g_free (d);
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
|
@ -2089,6 +2180,10 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
FileProgressStatus return_status;
|
||||
gboolean move_over = FALSE;
|
||||
gboolean dstat_ok;
|
||||
vfs_path_t *src_vpath, *dst_vpath, *destdir_vpath;
|
||||
|
||||
src_vpath = vfs_path_from_str (s);
|
||||
dst_vpath = vfs_path_from_str (d);
|
||||
|
||||
file_progress_show_source (ctx, s);
|
||||
file_progress_show_target (ctx, d);
|
||||
|
@ -2097,8 +2192,9 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
|
||||
mc_refresh ();
|
||||
|
||||
mc_stat (s, &sbuf);
|
||||
dstat_ok = (mc_stat (d, &dbuf) == 0);
|
||||
mc_stat (src_vpath, &sbuf);
|
||||
|
||||
dstat_ok = (mc_stat (dst_vpath, &dbuf) == 0);
|
||||
|
||||
if (dstat_ok && sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino)
|
||||
return warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same directory"), s, d);
|
||||
|
@ -2113,9 +2209,11 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
else
|
||||
destdir = concat_dir_and_file (d, x_basename (s));
|
||||
|
||||
destdir_vpath = vfs_path_from_str (destdir);
|
||||
|
||||
/* Check if the user inputted an existing dir */
|
||||
retry_dst_stat:
|
||||
if (mc_stat (destdir, &destbuf) == 0)
|
||||
if (mc_stat (destdir_vpath, &destbuf) == 0)
|
||||
{
|
||||
if (move_over)
|
||||
{
|
||||
|
@ -2139,6 +2237,9 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
goto retry_dst_stat;
|
||||
}
|
||||
g_free (destdir);
|
||||
vfs_path_free (destdir_vpath);
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
|
@ -2194,12 +2295,15 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||
|
||||
ret:
|
||||
g_free (destdir);
|
||||
vfs_path_free (destdir_vpath);
|
||||
while (erase_list)
|
||||
{
|
||||
lp = erase_list;
|
||||
erase_list = erase_list->next;
|
||||
g_free (lp);
|
||||
}
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
|
@ -2354,30 +2458,34 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
FileProgressStatus ret = FILE_CONT;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (dirname);
|
||||
|
||||
if (!compute_symlinks)
|
||||
{
|
||||
res = mc_lstat (dirname, &s);
|
||||
res = mc_lstat (vpath, &s);
|
||||
if (res != 0)
|
||||
return ret;
|
||||
goto ret;
|
||||
|
||||
/* don't scan symlink to directory */
|
||||
if (S_ISLNK (s.st_mode))
|
||||
{
|
||||
(*ret_marked)++;
|
||||
*ret_total += (uintmax_t) s.st_size;
|
||||
return ret;
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
|
||||
dir = mc_opendir (dirname);
|
||||
|
||||
if (dir == NULL)
|
||||
return ret;
|
||||
goto ret;
|
||||
|
||||
while ((dirent = mc_readdir (dir)) != NULL)
|
||||
{
|
||||
char *fullname;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
ret = (cback != NULL) ? cback (ui, dirname) : FILE_CONT;
|
||||
|
||||
|
@ -2390,11 +2498,13 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||
continue;
|
||||
|
||||
fullname = concat_dir_and_file (dirname, dirent->d_name);
|
||||
res = mc_lstat (fullname, &s);
|
||||
tmp_vpath = vfs_path_from_str (fullname);
|
||||
res = mc_lstat (tmp_vpath, &s);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
g_free (fullname);
|
||||
vfs_path_free (tmp_vpath);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2410,6 +2520,7 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||
if (ret != FILE_CONT)
|
||||
{
|
||||
g_free (fullname);
|
||||
vfs_path_free (tmp_vpath);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2423,10 +2534,12 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||
}
|
||||
|
||||
g_free (fullname);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
|
||||
ret:
|
||||
vfs_path_free (vpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2482,6 +2595,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
|
||||
if (single_entry)
|
||||
{
|
||||
vfs_path_t *source_vpath;
|
||||
|
||||
if (force_single)
|
||||
source = selection (panel)->fname;
|
||||
else
|
||||
|
@ -2493,8 +2608,9 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
source_vpath = vfs_path_from_str (source);
|
||||
/* Update stat to get actual info */
|
||||
if (mc_stat (source, &src_stat) != 0)
|
||||
if (mc_stat (source_vpath, &src_stat) != 0)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot stat \"%s\"\n%s"),
|
||||
path_trunc (source, 30), unix_error_string (errno));
|
||||
|
@ -2510,9 +2626,10 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
|
||||
update_panels (flags, UP_KEEPSEL);
|
||||
}
|
||||
|
||||
vfs_path_free (source_vpath);
|
||||
return FALSE;
|
||||
}
|
||||
vfs_path_free (source_vpath);
|
||||
}
|
||||
|
||||
ctx = file_op_context_new (operation);
|
||||
|
@ -2716,7 +2833,11 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
{
|
||||
case OP_COPY:
|
||||
/* we use file_mask_op_follow_links only with OP_COPY */
|
||||
ctx->stat_func (source_with_path, &src_stat);
|
||||
{
|
||||
vfs_path_t *vpath = vfs_path_from_str (source_with_path);
|
||||
ctx->stat_func (vpath, &src_stat);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
if (S_ISDIR (src_stat.st_mode))
|
||||
value = copy_dir_dir (tctx, ctx, source_with_path, dest,
|
||||
|
@ -2752,8 +2873,10 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
{
|
||||
int dst_result;
|
||||
struct stat dst_stat;
|
||||
vfs_path_t *vpath = vfs_path_from_str (dest);
|
||||
|
||||
dst_result = mc_stat (dest, &dst_stat);
|
||||
dst_result = mc_stat (vpath, &dst_stat);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
if ((dst_result != 0) || S_ISDIR (dst_stat.st_mode))
|
||||
break;
|
||||
|
@ -2814,7 +2937,13 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||
{
|
||||
case OP_COPY:
|
||||
/* we use file_mask_op_follow_links only with OP_COPY */
|
||||
ctx->stat_func (source_with_path, &src_stat);
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (source_with_path);
|
||||
ctx->stat_func (vpath, &src_stat);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
if (S_ISDIR (src_stat.st_mode))
|
||||
value = copy_dir_dir (tctx, ctx, source_with_path, temp2,
|
||||
TRUE, FALSE, FALSE, NULL);
|
||||
|
|
|
@ -1073,6 +1073,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||
|
||||
{
|
||||
struct stat buf;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
QuickDialog Quick_input = {
|
||||
fmd_xlen, FMDY, -1, -1, op_names[operation],
|
||||
|
@ -1137,6 +1138,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||
tmp = dest_dir;
|
||||
dest_dir = tilde_expand (tmp);
|
||||
g_free (tmp);
|
||||
vpath = vfs_path_from_str (dest_dir);
|
||||
|
||||
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
|
||||
if (ctx->dest_mask == NULL)
|
||||
|
@ -1144,13 +1146,13 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||
else
|
||||
ctx->dest_mask++;
|
||||
orig_mask = ctx->dest_mask;
|
||||
if (!*ctx->dest_mask
|
||||
if (*ctx->dest_mask == '\0'
|
||||
|| (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask)
|
||||
&& (!only_one
|
||||
|| (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))
|
||||
|| (mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode))))
|
||||
|| (ctx->dive_into_subdirs
|
||||
&& ((!only_one && !is_wildcarded (ctx->dest_mask))
|
||||
|| (only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))))
|
||||
|| (only_one && mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode)))))
|
||||
ctx->dest_mask = g_strdup ("\\0");
|
||||
else
|
||||
{
|
||||
|
@ -1162,6 +1164,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||
g_free (dest_dir);
|
||||
dest_dir = g_strdup ("./");
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
if (val == B_USER)
|
||||
*do_bg = TRUE;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
#include <inttypes.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
typedef int (*mc_stat_fn) (const char *filename, struct stat * buf);
|
||||
typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
|
|
|
@ -982,17 +982,21 @@ search_content (Dlg_head * h, const char *directory, const char *filename)
|
|||
char *fname = NULL;
|
||||
int file_fd;
|
||||
gboolean ret_val = FALSE;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
fname = mc_build_filename (directory, filename, (char *) NULL);
|
||||
vpath = vfs_path_from_str (fname);
|
||||
|
||||
if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode))
|
||||
if (mc_stat (vpath, &s) != 0 || !S_ISREG (s.st_mode))
|
||||
{
|
||||
g_free (fname);
|
||||
vfs_path_free (vpath);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
file_fd = mc_open (fname, O_RDONLY);
|
||||
g_free (fname);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
if (file_fd == -1)
|
||||
return FALSE;
|
||||
|
@ -1189,6 +1193,7 @@ do_search (Dlg_head * h)
|
|||
while (dirp == NULL)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tty_setcolor (REVERSE_COLOR);
|
||||
|
||||
|
@ -1224,6 +1229,7 @@ do_search (Dlg_head * h)
|
|||
|
||||
g_free (directory);
|
||||
directory = tmp;
|
||||
tmp_vpath = vfs_path_from_str (directory);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
|
@ -1236,12 +1242,13 @@ do_search (Dlg_head * h)
|
|||
/* mc_stat should not be called after mc_opendir
|
||||
because vfs_s_opendir modifies the st_nlink
|
||||
*/
|
||||
if (mc_stat (directory, &tmp_stat) == 0)
|
||||
if (mc_stat (tmp_vpath, &tmp_stat) == 0)
|
||||
subdirs_left = tmp_stat.st_nlink - 2;
|
||||
else
|
||||
subdirs_left = 0;
|
||||
|
||||
dirp = mc_opendir (directory);
|
||||
vfs_path_free (tmp_vpath);
|
||||
} /* while (!dirp) */
|
||||
|
||||
/* skip invalid filenames */
|
||||
|
@ -1269,17 +1276,18 @@ do_search (Dlg_head * h)
|
|||
ignore_count++;
|
||||
else
|
||||
{
|
||||
char *tmp_name;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tmp_name = mc_build_filename (directory, dp->d_name, (char *) NULL);
|
||||
tmp_vpath = vfs_path_build_filename (directory, dp->d_name, (char *) NULL);
|
||||
|
||||
if (mc_lstat (tmp_name, &tmp_stat) == 0 && S_ISDIR (tmp_stat.st_mode))
|
||||
if (mc_lstat (tmp_vpath, &tmp_stat) == 0 && S_ISDIR (tmp_stat.st_mode))
|
||||
{
|
||||
push_directory (tmp_name);
|
||||
push_directory (vfs_path_to_str (tmp_vpath));
|
||||
vfs_path_free (tmp_vpath);
|
||||
subdirs_left--;
|
||||
}
|
||||
else
|
||||
g_free (tmp_name);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1630,9 +1630,17 @@ save_cwds_stat (void)
|
|||
{
|
||||
if (panels_options.fast_reload)
|
||||
{
|
||||
mc_stat (current_panel->cwd, &(current_panel->dir_stat));
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (current_panel->cwd);
|
||||
mc_stat (vpath, &(current_panel->dir_stat));
|
||||
vfs_path_free (vpath);
|
||||
if (get_other_type () == view_listing)
|
||||
mc_stat (other_panel->cwd, &(other_panel->dir_stat));
|
||||
{
|
||||
vpath = vfs_path_from_str (other_panel->cwd);
|
||||
mc_stat (vpath, &(other_panel->dir_stat));
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2542,12 +2542,20 @@ chdir_to_readlink (WPanel * panel)
|
|||
char buffer[MC_MAXPATHLEN], *p;
|
||||
int i;
|
||||
struct stat st;
|
||||
vfs_path_t *panel_fname_vpath = vfs_path_from_str (selection (panel)->fname);
|
||||
|
||||
i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1);
|
||||
if (i < 0)
|
||||
{
|
||||
vfs_path_free (panel_fname_vpath);
|
||||
return;
|
||||
if (mc_stat (selection (panel)->fname, &st) < 0)
|
||||
}
|
||||
if (mc_stat (panel_fname_vpath, &st) < 0)
|
||||
{
|
||||
vfs_path_free (panel_fname_vpath);
|
||||
return;
|
||||
}
|
||||
vfs_path_free (panel_fname_vpath);
|
||||
buffer[i] = 0;
|
||||
if (!S_ISDIR (st.st_mode))
|
||||
{
|
||||
|
@ -3506,11 +3514,11 @@ reload_panelized (WPanel * panel)
|
|||
{
|
||||
int i, j;
|
||||
dir_list *list = &panel->dir;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (panel != current_panel)
|
||||
{
|
||||
int ret;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (panel->cwd);
|
||||
ret = mc_chdir (vpath);
|
||||
|
@ -3529,9 +3537,11 @@ reload_panelized (WPanel * panel)
|
|||
*/
|
||||
do_file_mark (panel, i, 0);
|
||||
}
|
||||
if (mc_lstat (list->list[i].fname, &list->list[i].st))
|
||||
vpath = vfs_path_from_str (list->list[i].fname);
|
||||
if (mc_lstat (vpath, &list->list[i].st))
|
||||
{
|
||||
g_free (list->list[i].fname);
|
||||
vfs_path_free (vpath);
|
||||
continue;
|
||||
}
|
||||
if (list->list[i].f.marked)
|
||||
|
@ -3539,6 +3549,7 @@ reload_panelized (WPanel * panel)
|
|||
if (j != i)
|
||||
list->list[j] = list->list[i];
|
||||
j++;
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
if (j == 0)
|
||||
panel->count = set_zero_dir (list) ? 1 : 0;
|
||||
|
@ -3548,7 +3559,6 @@ reload_panelized (WPanel * panel)
|
|||
if (panel != current_panel)
|
||||
{
|
||||
int ret;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (current_panel->cwd);
|
||||
ret = mc_chdir (vpath);
|
||||
|
|
|
@ -795,7 +795,7 @@ tree_entry *
|
|||
tree_store_start_check (const char *path)
|
||||
{
|
||||
tree_entry *current, *retval;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (!ts.loaded)
|
||||
return NULL;
|
||||
|
@ -808,9 +808,14 @@ tree_store_start_check (const char *path)
|
|||
if (!current)
|
||||
{
|
||||
struct stat s;
|
||||
vfs_path_t *vpath = vfs_path_from_str (path);
|
||||
|
||||
if (mc_stat (path, &s) == -1)
|
||||
if (mc_stat (vpath, &s) == -1)
|
||||
{
|
||||
vfs_path_free (vpath);
|
||||
return NULL;
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
||||
if (!S_ISDIR (s.st_mode))
|
||||
return NULL;
|
||||
|
@ -909,7 +914,7 @@ tree_store_rescan (const char *dir)
|
|||
{
|
||||
for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp))
|
||||
{
|
||||
char *full_name;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
if (dp->d_name[0] == '.')
|
||||
{
|
||||
|
@ -917,13 +922,13 @@ tree_store_rescan (const char *dir)
|
|||
continue;
|
||||
}
|
||||
|
||||
full_name = concat_dir_and_file (dir, dp->d_name);
|
||||
if (mc_lstat (full_name, &buf) != -1)
|
||||
tmp_vpath = vfs_path_build_filename (dir, dp->d_name, NULL);
|
||||
if (mc_lstat (tmp_vpath, &buf) != -1)
|
||||
{
|
||||
if (S_ISDIR (buf.st_mode))
|
||||
tree_store_mark_checked (dp->d_name);
|
||||
}
|
||||
g_free (full_name);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
mc_closedir (dirp);
|
||||
}
|
||||
|
|
|
@ -215,17 +215,19 @@ cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const char *name)
|
||||
cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const vfs_path_t * vpath)
|
||||
{
|
||||
int fd, type;
|
||||
cpio_super_data_t *arch;
|
||||
mode_t mode;
|
||||
struct vfs_s_inode *root;
|
||||
char *name = vfs_path_to_str (vpath);
|
||||
|
||||
fd = mc_open (name, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
|
||||
g_free (name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -233,7 +235,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const char
|
|||
super->data = g_new (cpio_super_data_t, 1);
|
||||
arch = (cpio_super_data_t *) super->data;
|
||||
arch->fd = -1; /* for now */
|
||||
mc_stat (name, &arch->st);
|
||||
mc_stat (vpath, &arch->st);
|
||||
arch->type = CPIO_UNKNOWN;
|
||||
arch->deferred = NULL;
|
||||
|
||||
|
@ -249,6 +251,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const char
|
|||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
|
||||
g_free (s);
|
||||
g_free (name);
|
||||
return -1;
|
||||
}
|
||||
g_free (s);
|
||||
|
@ -268,6 +271,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const char
|
|||
super->root = root;
|
||||
|
||||
CPIO_SEEK_SET (super, 0);
|
||||
g_free (name);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
@ -723,15 +727,11 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
|||
const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
int status = STATUS_START;
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) vpath_element;
|
||||
|
||||
if (cpio_open_cpio_file (vpath_element->class, super, archive_name) == -1)
|
||||
{
|
||||
g_free (archive_name);
|
||||
if (cpio_open_cpio_file (vpath_element->class, super, vpath) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
@ -740,8 +740,14 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
|||
switch (status)
|
||||
{
|
||||
case STATUS_EOF:
|
||||
message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), archive_name);
|
||||
return 0;
|
||||
{
|
||||
char *archive_name;
|
||||
|
||||
archive_name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), archive_name);
|
||||
g_free (archive_name);
|
||||
return 0;
|
||||
}
|
||||
case STATUS_OK:
|
||||
continue;
|
||||
case STATUS_TRAIL:
|
||||
|
@ -750,7 +756,6 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
|||
break;
|
||||
}
|
||||
|
||||
g_free (archive_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -761,11 +766,9 @@ static void *
|
|||
cpio_super_check (const vfs_path_t * vpath)
|
||||
{
|
||||
static struct stat sb;
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
int stat_result;
|
||||
|
||||
stat_result = mc_stat (archive_name, &sb);
|
||||
g_free (archive_name);
|
||||
stat_result = mc_stat (vpath, &sb);
|
||||
return (stat_result == 0 ? &sb : NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -374,8 +374,11 @@ extfs_free_archive (struct archive *archive)
|
|||
if (archive->local_name != NULL)
|
||||
{
|
||||
struct stat my;
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
mc_stat (archive->local_name, &my);
|
||||
tmp_vpath = vfs_path_from_str (archive->local_name);
|
||||
mc_stat (tmp_vpath, &my);
|
||||
vfs_path_free (tmp_vpath);
|
||||
mc_ungetlocalcopy (archive->name, archive->local_name,
|
||||
archive->local_stat.st_mtime != my.st_mtime);
|
||||
g_free (archive->local_name);
|
||||
|
@ -391,7 +394,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||
{
|
||||
const extfs_plugin_info_t *info;
|
||||
static dev_t archive_counter = 0;
|
||||
FILE *result;
|
||||
FILE *result = NULL;
|
||||
mode_t mode;
|
||||
char *cmd;
|
||||
struct stat mystat;
|
||||
|
@ -409,14 +412,14 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||
|
||||
if (info->need_archive)
|
||||
{
|
||||
if (mc_stat (name, &mystat) == -1)
|
||||
return NULL;
|
||||
if (mc_stat (vpath, &mystat) == -1)
|
||||
goto ret;
|
||||
|
||||
if (!vfs_file_is_local (vpath))
|
||||
{
|
||||
local_name = mc_getlocalcopy (name);
|
||||
if (local_name == NULL)
|
||||
return NULL;
|
||||
goto ret;
|
||||
}
|
||||
tmp = name_quote ((vpath != NULL) ? path_element->path : name, 0);
|
||||
}
|
||||
|
@ -436,8 +439,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||
mc_ungetlocalcopy (name, local_name, 0);
|
||||
g_free (local_name);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
return NULL;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
#ifdef ___QNXNTO__
|
||||
|
@ -450,7 +452,11 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||
current_archive->local_name = local_name;
|
||||
|
||||
if (local_name != NULL)
|
||||
mc_stat (local_name, ¤t_archive->local_stat);
|
||||
{
|
||||
vfs_path_t *tmp_vpath = vfs_path_from_str (local_name);
|
||||
mc_stat (tmp_vpath, ¤t_archive->local_stat);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
current_archive->inode_counter = 0;
|
||||
current_archive->fd_usage = 0;
|
||||
current_archive->rdev = archive_counter++;
|
||||
|
@ -474,6 +480,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||
|
||||
*pparc = current_archive;
|
||||
|
||||
ret:
|
||||
vfs_path_free (vpath);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs
|
|||
archive->name = archive_name;
|
||||
archive->data = g_new (tar_super_data_t, 1);
|
||||
arch = (tar_super_data_t *) archive->data;
|
||||
mc_stat (archive_name, &arch->st);
|
||||
mc_stat (vpath, &arch->st);
|
||||
arch->fd = -1;
|
||||
arch->type = TAR_UNKNOWN;
|
||||
|
||||
|
@ -819,11 +819,9 @@ static void *
|
|||
tar_super_check (const vfs_path_t * vpath)
|
||||
{
|
||||
static struct stat stat_buf;
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
int stat_result;
|
||||
|
||||
stat_result = mc_stat (archive_name, &stat_buf);
|
||||
g_free (archive_name);
|
||||
stat_result = mc_stat (vpath, &stat_buf);
|
||||
|
||||
return (stat_result != 0) ? NULL : &stat_buf;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue