mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-09 13:02:01 +03:00
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
a959d2843f
commit
32c6bde080
@ -1,6 +1,8 @@
|
|||||||
#ifndef MC_CONFIG_H
|
#ifndef MC_CONFIG_H
|
||||||
#define MC_CONFIG_H
|
#define MC_CONFIG_H
|
||||||
|
|
||||||
|
#include "lib/vfs/vfs.h" /* vfs_path_t */
|
||||||
|
|
||||||
/*** typedefs(not structures) and defined constants **********************************************/
|
/*** typedefs(not structures) and defined constants **********************************************/
|
||||||
|
|
||||||
#define CONFIG_APP_SECTION "Midnight-Commander"
|
#define CONFIG_APP_SECTION "Midnight-Commander"
|
||||||
@ -112,6 +114,7 @@ const char *mc_config_get_home_dir (void);
|
|||||||
|
|
||||||
char *mc_config_get_full_path (const char *config_name);
|
char *mc_config_get_full_path (const char *config_name);
|
||||||
|
|
||||||
|
vfs_path_t *mc_config_get_full_vpath (const char *config_name);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -115,10 +115,17 @@ mc_config_init (const gchar * ini_path)
|
|||||||
if (ini_path == NULL)
|
if (ini_path == NULL)
|
||||||
return mc_config;
|
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 */
|
vfs_path_t *vpath;
|
||||||
g_key_file_load_from_file (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
||||||
|
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);
|
mc_config->ini_path = g_strdup (ini_path);
|
||||||
|
@ -525,3 +525,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;
|
int len;
|
||||||
struct stat mybuf;
|
struct stat mybuf;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (*path != PATH_SEP)
|
if (*path != PATH_SEP)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (path);
|
||||||
r = buf = g_malloc (MC_MAXPATHLEN);
|
r = buf = g_malloc (MC_MAXPATHLEN);
|
||||||
buf2 = g_malloc (MC_MAXPATHLEN);
|
buf2 = g_malloc (MC_MAXPATHLEN);
|
||||||
*r++ = PATH_SEP;
|
*r++ = PATH_SEP;
|
||||||
*r = 0;
|
*r = 0;
|
||||||
p = path;
|
p = path;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
q = strchr (p + 1, PATH_SEP);
|
q = strchr (p + 1, PATH_SEP);
|
||||||
@ -135,12 +139,12 @@ resolve_symlinks (const char *path)
|
|||||||
}
|
}
|
||||||
c = *q;
|
c = *q;
|
||||||
*q = 0;
|
*q = 0;
|
||||||
if (mc_lstat (path, &mybuf) < 0)
|
if (mc_lstat (vpath, &mybuf) < 0)
|
||||||
{
|
{
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
g_free (buf2);
|
buf = NULL;
|
||||||
*q = c;
|
*q = c;
|
||||||
return NULL;
|
goto ret;
|
||||||
}
|
}
|
||||||
if (!S_ISLNK (mybuf.st_mode))
|
if (!S_ISLNK (mybuf.st_mode))
|
||||||
strcpy (r, p + 1);
|
strcpy (r, p + 1);
|
||||||
@ -150,9 +154,9 @@ resolve_symlinks (const char *path)
|
|||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
g_free (buf2);
|
buf = NULL;
|
||||||
*q = c;
|
*q = c;
|
||||||
return NULL;
|
goto ret;
|
||||||
}
|
}
|
||||||
buf2[len] = 0;
|
buf2[len] = 0;
|
||||||
if (*buf2 == PATH_SEP)
|
if (*buf2 == PATH_SEP)
|
||||||
@ -176,7 +180,10 @@ resolve_symlinks (const char *path)
|
|||||||
strcpy (buf, PATH_SEP_STR);
|
strcpy (buf, PATH_SEP_STR);
|
||||||
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
||||||
*(r - 1) = 0;
|
*(r - 1) = 0;
|
||||||
|
|
||||||
|
ret:
|
||||||
g_free (buf2);
|
g_free (buf2);
|
||||||
|
vfs_path_free (vpath);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ mc_def_getlocalcopy (const char *filename)
|
|||||||
ssize_t i;
|
ssize_t i;
|
||||||
char buffer[8192];
|
char buffer[8192];
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
|
vfs_path_t *vpath = vfs_path_from_str (filename);
|
||||||
|
|
||||||
fdin = mc_open (filename, O_RDONLY | O_LINEAR);
|
fdin = mc_open (filename, O_RDONLY | O_LINEAR);
|
||||||
if (fdin == -1)
|
if (fdin == -1)
|
||||||
@ -106,12 +107,14 @@ mc_def_getlocalcopy (const char *filename)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc_stat (filename, &mystat) != -1)
|
if (mc_stat (vpath, &mystat) != -1)
|
||||||
chmod (tmp, mystat.st_mode);
|
chmod (tmp, mystat.st_mode);
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
vfs_path_free (vpath);
|
||||||
if (fdout != -1)
|
if (fdout != -1)
|
||||||
close (fdout);
|
close (fdout);
|
||||||
if (fdin != -1)
|
if (fdin != -1)
|
||||||
@ -556,13 +559,11 @@ mc_closedir (DIR * dirp)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_stat (const char *filename, struct stat *buf)
|
mc_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
vfs_path_t *vpath;
|
|
||||||
vfs_path_element_t *path_element;
|
vfs_path_element_t *path_element;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (filename);
|
|
||||||
if (vpath == NULL)
|
if (vpath == NULL)
|
||||||
return -1;
|
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;
|
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs_path_free (vpath);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_lstat (const char *filename, struct stat *buf)
|
mc_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
vfs_path_t *vpath;
|
|
||||||
vfs_path_element_t *path_element;
|
vfs_path_element_t *path_element;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (filename);
|
|
||||||
if (vpath == NULL)
|
if (vpath == NULL)
|
||||||
return -1;
|
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;
|
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs_path_free (vpath);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,28 +538,29 @@ _vfs_get_cwd (void)
|
|||||||
|
|
||||||
path_element = vfs_path_get_by_index (vfs_get_raw_current_dir (), -1);
|
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 ();
|
current_dir = g_get_current_dir ();
|
||||||
if (tmp != NULL)
|
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 */
|
{ /* One of the directories in the path is not readable */
|
||||||
struct stat my_stat, my_stat2;
|
struct stat my_stat, my_stat2;
|
||||||
|
|
||||||
/* Check if it is O.K. to use the current_dir */
|
/* Check if it is O.K. to use the current_dir */
|
||||||
if (!(mc_global.vfs.cd_symlinks
|
if (!(mc_global.vfs.cd_symlinks
|
||||||
&& mc_stat (tmp, &my_stat) == 0
|
&& mc_stat (tmp_vpath, &my_stat) == 0
|
||||||
&& mc_stat (path_element->path, &my_stat2) == 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))
|
&& my_stat.st_ino == my_stat2.st_ino && my_stat.st_dev == my_stat2.st_dev))
|
||||||
{
|
vfs_set_raw_current_dir (tmp_vpath);
|
||||||
vfs_set_raw_current_dir (vfs_path_from_str (tmp));
|
else
|
||||||
}
|
vfs_path_free (tmp_vpath);
|
||||||
|
|
||||||
g_free (tmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return vfs_path_to_str (vfs_get_raw_current_dir ());
|
return vfs_path_to_str (vfs_get_raw_current_dir ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,13 +284,13 @@ off_t mc_lseek (int fd, off_t offset, int whence);
|
|||||||
DIR *mc_opendir (const char *dirname);
|
DIR *mc_opendir (const char *dirname);
|
||||||
struct dirent *mc_readdir (DIR * dirp);
|
struct dirent *mc_readdir (DIR * dirp);
|
||||||
int mc_closedir (DIR * dir);
|
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_mknod (const char *path, mode_t mode, dev_t dev);
|
||||||
int mc_link (const char *name1, const char *name2);
|
int mc_link (const char *name1, const char *name2);
|
||||||
int mc_mkdir (const char *path, mode_t mode);
|
int mc_mkdir (const char *path, mode_t mode);
|
||||||
int mc_rmdir (const char *path);
|
int mc_rmdir (const char *path);
|
||||||
int mc_fstat (int fd, struct stat *buf);
|
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_symlink (const char *name1, const char *name2);
|
||||||
int mc_rename (const char *original, const char *target);
|
int mc_rename (const char *original, const char *target);
|
||||||
int mc_chmod (const char *path, mode_t mode);
|
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;
|
isdir = 1;
|
||||||
isexec = 0;
|
isexec = 0;
|
||||||
{
|
{
|
||||||
char *tmp;
|
vfs_path_t *vpath;
|
||||||
struct stat tempstat;
|
struct stat tempstat;
|
||||||
|
|
||||||
tmp = g_strconcat (dirname, PATH_SEP_STR, entry->d_name, (char *) NULL);
|
vpath = vfs_path_build_filename (dirname, entry->d_name, (char *) NULL);
|
||||||
canonicalize_pathname (tmp);
|
|
||||||
/* Unix version */
|
/* Unix version */
|
||||||
if (!mc_stat (tmp, &tempstat))
|
if (mc_stat (vpath, &tempstat) == 0)
|
||||||
{
|
{
|
||||||
uid_t my_uid = getuid ();
|
uid_t my_uid = getuid ();
|
||||||
gid_t my_gid = getgid ();
|
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 */
|
/* stat failed, strange. not a dir in any case */
|
||||||
isdir = 0;
|
isdir = 0;
|
||||||
}
|
}
|
||||||
g_free (tmp);
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
if ((flags & INPUT_COMPLETE_COMMANDS) && (isexec || isdir))
|
if ((flags & INPUT_COMPLETE_COMMANDS) && (isexec || isdir))
|
||||||
break;
|
break;
|
||||||
|
@ -648,13 +648,16 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
|||||||
{
|
{
|
||||||
char *fname;
|
char *fname;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
vfs_path_t *tmp_vpath, *fname_vpath;
|
||||||
|
|
||||||
fname = g_strndup (tmp, p - 1 - tmp);
|
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.
|
* Check that the file before the colon actually exists.
|
||||||
* If it doesn't exist, revert to the old behavior.
|
* 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_run_param0 = fname;
|
||||||
mc_args__edit_start_line = atoi (p);
|
mc_args__edit_start_line = atoi (p);
|
||||||
@ -664,6 +667,8 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
|||||||
g_free (fname);
|
g_free (fname);
|
||||||
goto try_plus_filename;
|
goto try_plus_filename;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
|
vfs_path_free (fname_vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3335,9 +3335,11 @@ do \
|
|||||||
real_file##n = mc_getlocalcopy (file##n); \
|
real_file##n = mc_getlocalcopy (file##n); \
|
||||||
if (real_file##n != NULL) \
|
if (real_file##n != NULL) \
|
||||||
{ \
|
{ \
|
||||||
|
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
|
||||||
use_copy##n = 1; \
|
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; \
|
use_copy##n = -1; \
|
||||||
|
vfs_path_free (tmp_vpath); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
vfs_path_free(vpath); \
|
vfs_path_free(vpath); \
|
||||||
@ -3353,9 +3355,11 @@ do \
|
|||||||
if (use_copy##n > 0) \
|
if (use_copy##n > 0) \
|
||||||
{ \
|
{ \
|
||||||
time_t mtime; \
|
time_t mtime; \
|
||||||
|
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
|
||||||
mtime = st##n.st_mtime; \
|
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); \
|
changed = (mtime != st##n.st_mtime); \
|
||||||
|
vfs_path_free (tmp_vpath); \
|
||||||
} \
|
} \
|
||||||
mc_ungetlocalcopy (file##n, real_file##n, changed); \
|
mc_ungetlocalcopy (file##n, real_file##n, changed); \
|
||||||
g_free (real_file##n); \
|
g_free (real_file##n); \
|
||||||
|
@ -1833,8 +1833,10 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||||||
long curs;
|
long curs;
|
||||||
long start_mark, end_mark;
|
long start_mark, end_mark;
|
||||||
struct stat status;
|
struct stat status;
|
||||||
|
vfs_path_t *block_file_vpath;
|
||||||
|
|
||||||
block_file = mc_config_get_full_path (EDIT_BLOCK_FILE);
|
block_file = mc_config_get_full_path (EDIT_BLOCK_FILE);
|
||||||
|
block_file_vpath = vfs_path_from_str (block_file);
|
||||||
curs = edit->curs1;
|
curs = edit->curs1;
|
||||||
nomark = eval_marks (edit, &start_mark, &end_mark);
|
nomark = eval_marks (edit, &start_mark, &end_mark);
|
||||||
if (nomark == 0)
|
if (nomark == 0)
|
||||||
@ -1842,7 +1844,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||||||
|
|
||||||
/* run shell scripts from menu */
|
/* run shell scripts from menu */
|
||||||
if (user_menu_cmd (edit, menu_file, selected_entry)
|
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;
|
int rc = 0;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
@ -1869,6 +1871,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
|
|||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
|
|
||||||
g_free (block_file);
|
g_free (block_file);
|
||||||
|
vfs_path_free (block_file_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -126,6 +126,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
char *savename = 0;
|
char *savename = 0;
|
||||||
gchar *real_filename;
|
gchar *real_filename;
|
||||||
int this_save_mode, fd = -1;
|
int this_save_mode, fd = -1;
|
||||||
|
vfs_path_t *real_filename_vpath;
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return 0;
|
return 0;
|
||||||
@ -140,12 +141,13 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
{
|
{
|
||||||
real_filename = g_strdup (filename);
|
real_filename = g_strdup (filename);
|
||||||
}
|
}
|
||||||
|
real_filename_vpath = vfs_path_from_str (real_filename);
|
||||||
|
|
||||||
this_save_mode = option_save_mode;
|
this_save_mode = option_save_mode;
|
||||||
if (this_save_mode != EDIT_QUICK_SAVE)
|
if (this_save_mode != EDIT_QUICK_SAVE)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath = vfs_path_from_str (real_filename);
|
if (!vfs_file_is_local (real_filename_vpath)
|
||||||
if (!vfs_file_is_local (vpath) || (fd = mc_open (real_filename, O_RDONLY | O_BINARY)) == -1)
|
|| (fd = mc_open (real_filename, O_RDONLY | O_BINARY)) == -1)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The file does not exists yet, so no safe save or
|
* The file does not exists yet, so no safe save or
|
||||||
@ -153,7 +155,6 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
*/
|
*/
|
||||||
this_save_mode = EDIT_QUICK_SAVE;
|
this_save_mode = EDIT_QUICK_SAVE;
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath);
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
mc_close (fd);
|
mc_close (fd);
|
||||||
}
|
}
|
||||||
@ -163,7 +164,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
int rv;
|
int rv;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
rv = mc_stat (real_filename, &sb);
|
rv = mc_stat (real_filename_vpath, &sb);
|
||||||
if (rv == 0 && sb.st_nlink > 1)
|
if (rv == 0 && sb.st_nlink > 1)
|
||||||
{
|
{
|
||||||
rv = edit_query_dialog3 (_("Warning"),
|
rv = edit_query_dialog3 (_("Warning"),
|
||||||
@ -179,6 +180,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
|
vfs_path_free (real_filename_vpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,6 +198,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
{
|
{
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
|
vfs_path_free (real_filename_vpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,6 +223,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
if (!savename)
|
if (!savename)
|
||||||
{
|
{
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
|
vfs_path_free (real_filename_vpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* FIXME:
|
/* FIXME:
|
||||||
@ -278,6 +282,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
}
|
}
|
||||||
else if (edit->lb == LB_ASIS)
|
else if (edit->lb == LB_ASIS)
|
||||||
{ /* do not change line breaks */
|
{ /* do not change line breaks */
|
||||||
|
vfs_path_t *savename_vpath;
|
||||||
long buf;
|
long buf;
|
||||||
buf = 0;
|
buf = 0;
|
||||||
filelen = edit->last_byte;
|
filelen = edit->last_byte;
|
||||||
@ -325,8 +330,13 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
goto error_save;
|
goto error_save;
|
||||||
|
|
||||||
/* Update the file information, especially the mtime. */
|
/* 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;
|
goto error_save;
|
||||||
|
}
|
||||||
|
vfs_path_free (savename_vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* change line breaks */
|
{ /* change line breaks */
|
||||||
@ -373,6 +383,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
goto error_save;
|
goto error_save;
|
||||||
g_free (savename);
|
g_free (savename);
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
|
vfs_path_free (real_filename_vpath);
|
||||||
return 1;
|
return 1;
|
||||||
error_save:
|
error_save:
|
||||||
/* FIXME: Is this safe ?
|
/* FIXME: Is this safe ?
|
||||||
@ -380,6 +391,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
* mc_unlink (savename);
|
* mc_unlink (savename);
|
||||||
*/
|
*/
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
|
vfs_path_free (real_filename_vpath);
|
||||||
g_free (savename);
|
g_free (savename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1661,6 +1673,7 @@ edit_save_as_cmd (WEdit * edit)
|
|||||||
{
|
{
|
||||||
/* This heads the 'Save As' dialog box */
|
/* This heads the 'Save As' dialog box */
|
||||||
char *exp;
|
char *exp;
|
||||||
|
vfs_path_t *exp_vpath;
|
||||||
int save_lock = 0;
|
int save_lock = 0;
|
||||||
int different_filename = 0;
|
int different_filename = 0;
|
||||||
|
|
||||||
@ -1686,15 +1699,18 @@ edit_save_as_cmd (WEdit * edit)
|
|||||||
int file;
|
int file;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if (mc_stat (exp, &sb) == 0 && !S_ISREG (sb.st_mode))
|
exp_vpath = vfs_path_from_str (exp);
|
||||||
|
if (mc_stat (exp_vpath, &sb) == 0 && !S_ISREG (sb.st_mode))
|
||||||
{
|
{
|
||||||
edit_error_dialog (_("Save as"),
|
edit_error_dialog (_("Save as"),
|
||||||
get_sys_error (_
|
get_sys_error (_
|
||||||
("Cannot save: destination is not a regular file")));
|
("Cannot save: destination is not a regular file")));
|
||||||
g_free (exp);
|
g_free (exp);
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
|
vfs_path_free (exp_vpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (exp_vpath);
|
||||||
|
|
||||||
different_filename = 1;
|
different_filename = 1;
|
||||||
file = mc_open (exp, O_RDONLY | O_BINARY);
|
file = mc_open (exp, O_RDONLY | O_BINARY);
|
||||||
|
@ -443,6 +443,7 @@ execute_with_vfs_arg (const char *command, const char *filename)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
vfs_path_t *vpath = vfs_path_from_str (filename);
|
vfs_path_t *vpath = vfs_path_from_str (filename);
|
||||||
|
vfs_path_t *localcopy_vpath;
|
||||||
|
|
||||||
/* Simplest case, this file is local */
|
/* Simplest case, this file is local */
|
||||||
if (!filename || vfs_file_is_local (vpath))
|
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);
|
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"), filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
localcopy_vpath = vfs_path_from_str (localcopy);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* filename can be an entry on panel, it can be changed by executing
|
* 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.
|
* below unnecessary.
|
||||||
*/
|
*/
|
||||||
fn = g_strdup (filename);
|
fn = g_strdup (filename);
|
||||||
mc_stat (localcopy, &st);
|
mc_stat (localcopy_vpath, &st);
|
||||||
mtime = st.st_mtime;
|
mtime = st.st_mtime;
|
||||||
do_execute (command, localcopy, EXECUTE_INTERNAL);
|
do_execute (command, localcopy, EXECUTE_INTERNAL);
|
||||||
mc_stat (localcopy, &st);
|
mc_stat (localcopy_vpath, &st);
|
||||||
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
|
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
|
||||||
g_free (localcopy);
|
g_free (localcopy);
|
||||||
|
vfs_path_free (localcopy_vpath);
|
||||||
g_free (fn);
|
g_free (fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,10 +743,16 @@ apply_advanced_chowns (struct stat *sf)
|
|||||||
|
|
||||||
do
|
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;
|
break;
|
||||||
|
}
|
||||||
ch_cmode = sf->st_mode;
|
ch_cmode = sf->st_mode;
|
||||||
if (mc_chmod (lc_fname, get_mode ()) == -1)
|
if (mc_chmod (lc_fname, get_mode ()) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
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));
|
lc_fname, unix_error_string (errno));
|
||||||
|
|
||||||
do_file_mark (current_panel, current_file, 0);
|
do_file_mark (current_panel, current_file, 0);
|
||||||
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
while (current_panel->marked);
|
while (current_panel->marked);
|
||||||
}
|
}
|
||||||
@ -774,16 +781,19 @@ chown_advanced_cmd (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{ /* do while any files remaining */
|
{ /* do while any files remaining */
|
||||||
|
vfs_path_t *vpath;
|
||||||
init_chown_advanced ();
|
init_chown_advanced ();
|
||||||
|
|
||||||
if (current_panel->marked)
|
if (current_panel->marked)
|
||||||
fname = next_file (); /* next marked file */
|
fname = next_file (); /* next marked file */
|
||||||
else
|
else
|
||||||
fname = selection (current_panel)->fname; /* single file */
|
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 */
|
{ /* get status of file */
|
||||||
destroy_dlg (ch_dlg);
|
destroy_dlg (ch_dlg);
|
||||||
|
vfs_path_free (vpath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ch_cmode = sf_stat->st_mode;
|
ch_cmode = sf_stat->st_mode;
|
||||||
@ -827,6 +837,8 @@ chown_advanced_cmd (void)
|
|||||||
need_update = 1;
|
need_update = 1;
|
||||||
}
|
}
|
||||||
destroy_dlg (ch_dlg);
|
destroy_dlg (ch_dlg);
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
}
|
}
|
||||||
while (current_panel->marked && !end_chown);
|
while (current_panel->marked && !end_chown);
|
||||||
|
|
||||||
|
@ -389,9 +389,14 @@ apply_mask (struct stat *sf)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
char *fname;
|
char *fname;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
gboolean ok;
|
||||||
|
|
||||||
fname = next_file ();
|
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;
|
return;
|
||||||
|
|
||||||
c_stat = sf->st_mode;
|
c_stat = sf->st_mode;
|
||||||
@ -412,6 +417,7 @@ chmod_cmd (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{ /* do while any files remaining */
|
{ /* do while any files remaining */
|
||||||
|
vfs_path_t *vpath;
|
||||||
Dlg_head *ch_dlg;
|
Dlg_head *ch_dlg;
|
||||||
struct stat sf_stat;
|
struct stat sf_stat;
|
||||||
char *fname;
|
char *fname;
|
||||||
@ -430,8 +436,14 @@ chmod_cmd (void)
|
|||||||
else
|
else
|
||||||
fname = selection (current_panel)->fname; /* single file */
|
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;
|
break;
|
||||||
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
c_stat = sf_stat.st_mode;
|
c_stat = sf_stat.st_mode;
|
||||||
|
|
||||||
|
@ -284,6 +284,7 @@ chown_cmd (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{ /* do while any files remaining */
|
{ /* do while any files remaining */
|
||||||
|
vfs_path_t *vpath;
|
||||||
ch_dlg = init_chown ();
|
ch_dlg = init_chown ();
|
||||||
new_user = new_group = -1;
|
new_user = new_group = -1;
|
||||||
|
|
||||||
@ -292,11 +293,14 @@ chown_cmd (void)
|
|||||||
else
|
else
|
||||||
fname = selection (current_panel)->fname; /* single file */
|
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 */
|
{ /* get status of file */
|
||||||
destroy_dlg (ch_dlg);
|
destroy_dlg (ch_dlg);
|
||||||
|
vfs_path_free (vpath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
/* select in listboxes */
|
/* select in listboxes */
|
||||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
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,
|
handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
|
||||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
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)
|
if (dp->d_name[0] == '.' && dp->d_name[1] == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 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] == '~')
|
if (!panels_options.show_backups && dp->d_name[NLENGTH (dp) - 1] == '~')
|
||||||
return 0;
|
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
|
* 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))
|
if (S_ISLNK (buf1->st_mode))
|
||||||
{
|
{
|
||||||
struct stat buf2;
|
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;
|
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||||
else
|
else
|
||||||
*stale_link = 1;
|
*stale_link = 1;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && (fltr != NULL)
|
if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && (fltr != NULL)
|
||||||
&& !mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB))
|
&& !mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB))
|
||||||
return 0;
|
return 0;
|
||||||
@ -199,13 +203,12 @@ get_dotdot_dir_stat (const char *path, struct stat *st)
|
|||||||
|
|
||||||
if ((path != NULL) && (path[0] != '\0') && (st != NULL))
|
if ((path != NULL) && (path[0] != '\0') && (st != NULL))
|
||||||
{
|
{
|
||||||
char *dotdot_dir;
|
vfs_path_t *vpath;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
dotdot_dir = g_strdup_printf ("%s/../", path);
|
vpath = vfs_path_build_filename (path, "..", NULL);
|
||||||
canonicalize_pathname (dotdot_dir);
|
ret = mc_stat (vpath, &s) == 0;
|
||||||
ret = mc_stat (dotdot_dir, &s) == 0;
|
vfs_path_free (vpath);
|
||||||
g_free (dotdot_dir);
|
|
||||||
*st = s;
|
*st = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,12 +483,19 @@ int
|
|||||||
handle_path (dir_list * list, const char *path,
|
handle_path (dir_list * list, const char *path,
|
||||||
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
struct stat *buf1, int next_free, int *link_to_dir, int *stale_link)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (path[0] == '.' && path[1] == 0)
|
if (path[0] == '.' && path[1] == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (path[0] == '.' && path[1] == '.' && path[2] == 0)
|
if (path[0] == '.' && path[1] == '.' && path[2] == 0)
|
||||||
return 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;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (S_ISDIR (buf1->st_mode))
|
if (S_ISDIR (buf1->st_mode))
|
||||||
tree_store_mark_checked (path);
|
tree_store_mark_checked (path);
|
||||||
@ -496,17 +506,18 @@ handle_path (dir_list * list, const char *path,
|
|||||||
if (S_ISLNK (buf1->st_mode))
|
if (S_ISLNK (buf1->st_mode))
|
||||||
{
|
{
|
||||||
struct stat buf2;
|
struct stat buf2;
|
||||||
if (!mc_stat (path, &buf2))
|
if (mc_stat (vpath, &buf2) == 0)
|
||||||
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
*link_to_dir = S_ISDIR (buf2.st_mode) != 0;
|
||||||
else
|
else
|
||||||
*stale_link = 1;
|
*stale_link = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
/* Need to grow the *list? */
|
/* Need to grow the *list? */
|
||||||
if (next_free == list->size)
|
if (next_free == list->size)
|
||||||
{
|
{
|
||||||
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
|
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
|
||||||
if (list->list == NULL)
|
|
||||||
return -1;
|
return -1;
|
||||||
list->size += RESIZE_STEPS;
|
list->size += RESIZE_STEPS;
|
||||||
}
|
}
|
||||||
@ -587,9 +598,14 @@ gboolean
|
|||||||
if_link_is_exe (const char *full_name, const file_entry * file)
|
if_link_is_exe (const char *full_name, const file_entry * file)
|
||||||
{
|
{
|
||||||
struct stat b;
|
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);
|
return is_exe (b.st_mode);
|
||||||
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +228,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
{
|
{
|
||||||
if (do_local_copy)
|
if (do_local_copy)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *vpath_local;
|
||||||
localcopy = mc_getlocalcopy (filename);
|
localcopy = mc_getlocalcopy (filename);
|
||||||
if (localcopy == NULL)
|
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);
|
vfs_path_free (vpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mc_stat (localcopy, &mystat);
|
vpath_local = vfs_path_from_str (localcopy);
|
||||||
|
mc_stat (vpath_local, &mystat);
|
||||||
localmtime = mystat.st_mtime;
|
localmtime = mystat.st_mtime;
|
||||||
text = quote_func (localcopy, 0);
|
text = quote_func (localcopy, 0);
|
||||||
|
vfs_path_free (vpath_local);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -377,8 +380,12 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
|
|
||||||
if (localcopy)
|
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);
|
mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);
|
||||||
|
vfs_path_free (vpath_local);
|
||||||
g_free (localcopy);
|
g_free (localcopy);
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
@ -698,7 +705,14 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
|||||||
g_free (title);
|
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 = NULL;
|
||||||
include_target_len = 0;
|
include_target_len = 0;
|
||||||
|
@ -295,12 +295,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)
|
if (lp->vfs == my_vfs && lp->ino == ino && lp->dev == dev)
|
||||||
{
|
{
|
||||||
struct vfs_class *lp_name_class;
|
struct vfs_class *lp_name_class;
|
||||||
|
int stat_result;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (lp->name);
|
vpath = vfs_path_from_str (lp->name);
|
||||||
lp_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
lp_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||||
|
stat_result = mc_stat (vpath, &link_stat);
|
||||||
vfs_path_free (vpath);
|
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)
|
&& link_stat.st_dev == dev && lp_name_class == my_vfs)
|
||||||
{
|
{
|
||||||
struct vfs_class *p_class, *dst_name_class;
|
struct vfs_class *p_class, *dst_name_class;
|
||||||
@ -308,22 +310,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
|
p = strchr (lp->name, 0) + 1; /* i.e. where the `name' file
|
||||||
was copied to */
|
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);
|
vpath = vfs_path_from_str (dst_name);
|
||||||
dst_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
dst_name_class = vfs_path_get_by_index (vpath, -1)->class;
|
||||||
vfs_path_free (vpath);
|
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 (dst_name_class == p_class)
|
||||||
{
|
{
|
||||||
if (!mc_stat (p, &link_stat))
|
if (!mc_stat (vpath, &link_stat))
|
||||||
{
|
{
|
||||||
if (!mc_link (p, dst_name))
|
if (!mc_link (p, dst_name))
|
||||||
|
{
|
||||||
|
vfs_path_free (vpath);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
}
|
}
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot make the hardlink"));
|
message (D_ERROR, MSG_ERROR, _("Cannot make the hardlink"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -363,7 +369,10 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
gboolean dst_is_symlink;
|
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:
|
retry_src_readlink:
|
||||||
len = mc_readlink (src_path, link_target, MC_MAXPATHLEN - 1);
|
len = mc_readlink (src_path, link_target, MC_MAXPATHLEN - 1);
|
||||||
@ -385,18 +394,14 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
|
|
||||||
if (ctx->stable_symlinks)
|
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,
|
message (D_ERROR, MSG_ERROR,
|
||||||
_("Cannot make stable symlinks across"
|
_("Cannot make stable symlinks across"
|
||||||
"non-local filesystems:\n\nOption Stable Symlinks will be disabled"));
|
"non-local filesystems:\n\nOption Stable Symlinks will be disabled"));
|
||||||
ctx->stable_symlinks = FALSE;
|
ctx->stable_symlinks = FALSE;
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath1);
|
|
||||||
vfs_path_free (vpath2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->stable_symlinks && !g_path_is_absolute (link_target))
|
if (ctx->stable_symlinks && !g_path_is_absolute (link_target))
|
||||||
@ -434,8 +439,12 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
}
|
}
|
||||||
retry_dst_symlink:
|
retry_dst_symlink:
|
||||||
if (mc_symlink (link_target, dst_path) == 0)
|
if (mc_symlink (link_target, dst_path) == 0)
|
||||||
|
{
|
||||||
/* Success */
|
/* Success */
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return FILE_CONT;
|
return FILE_CONT;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* if dst_exists, it is obvious that this had failed.
|
* if dst_exists, it is obvious that this had failed.
|
||||||
* We can delete the old symlink and try again...
|
* We can delete the old symlink and try again...
|
||||||
@ -444,8 +453,13 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
{
|
{
|
||||||
if (!mc_unlink (dst_path))
|
if (!mc_unlink (dst_path))
|
||||||
if (mc_symlink (link_target, dst_path) == 0)
|
if (mc_symlink (link_target, dst_path) == 0)
|
||||||
|
{
|
||||||
/* Success */
|
/* Success */
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
|
|
||||||
return FILE_CONT;
|
return FILE_CONT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
return_status = FILE_SKIPALL;
|
return_status = FILE_SKIPALL;
|
||||||
@ -457,6 +471,8 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
goto retry_dst_symlink;
|
goto retry_dst_symlink;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,6 +792,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
FileProgressStatus return_status = FILE_CONT;
|
FileProgressStatus return_status = FILE_CONT;
|
||||||
gboolean copy_done = FALSE;
|
gboolean copy_done = FALSE;
|
||||||
gboolean old_ask_overwrite;
|
gboolean old_ask_overwrite;
|
||||||
|
vfs_path_t *src_vpath, *dst_vpath;
|
||||||
|
|
||||||
file_progress_show_source (ctx, s);
|
file_progress_show_source (ctx, s);
|
||||||
file_progress_show_target (ctx, d);
|
file_progress_show_target (ctx, d);
|
||||||
@ -783,8 +800,10 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
mc_refresh ();
|
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 */
|
/* Source doesn't exist */
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
@ -796,10 +815,14 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
}
|
}
|
||||||
if (return_status != FILE_RETRY)
|
if (return_status != FILE_RETRY)
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
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)
|
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);
|
return warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same file"), s, d);
|
||||||
@ -808,6 +831,8 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot overwrite directory \"%s\""), d);
|
message (D_ERROR, MSG_ERROR, _("Cannot overwrite directory \"%s\""), d);
|
||||||
do_refresh ();
|
do_refresh ();
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return FILE_SKIP;
|
return FILE_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +840,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
{
|
{
|
||||||
return_status = query_replace (ctx, d, &src_stats, &dst_stats);
|
return_status = query_replace (ctx, d, &src_stats, &dst_stats);
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Ok to overwrite */
|
/* Ok to overwrite */
|
||||||
}
|
}
|
||||||
@ -828,11 +857,19 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
if (return_status == FILE_CONT)
|
if (return_status == FILE_CONT)
|
||||||
goto retry_src_remove;
|
goto retry_src_remove;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc_rename (s, d) == 0)
|
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);
|
return progress_update_one (tctx, ctx, src_stats.st_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
/* Comparison to EXDEV seems not to work in nfs if you're moving from
|
/* Comparison to EXDEV seems not to work in nfs if you're moving from
|
||||||
@ -854,6 +891,9 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
goto retry_rename;
|
goto retry_rename;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
|
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -864,7 +904,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
return_status = copy_file_file (tctx, ctx, s, d);
|
return_status = copy_file_file (tctx, ctx, s, d);
|
||||||
tctx->ask_overwrite = old_ask_overwrite;
|
tctx->ask_overwrite = old_ask_overwrite;
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
|
|
||||||
copy_done = TRUE;
|
copy_done = TRUE;
|
||||||
|
|
||||||
@ -873,7 +917,11 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
|
|
||||||
return_status = check_progress_buttons (ctx);
|
return_status = check_progress_buttons (ctx);
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
|
|
||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
@ -885,12 +933,18 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
goto retry_src_remove;
|
goto retry_src_remove;
|
||||||
if (return_status == FILE_SKIPALL)
|
if (return_status == FILE_SKIPALL)
|
||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
|
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!copy_done)
|
if (!copy_done)
|
||||||
return_status = progress_update_one (tctx, ctx, src_stats.st_size);
|
return_status = progress_update_one (tctx, ctx, src_stats.st_size);
|
||||||
|
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
|
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,13 +959,14 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
{
|
{
|
||||||
int return_status;
|
int return_status;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
vfs_path_t *vpath = vfs_path_from_str (s);
|
||||||
|
|
||||||
file_progress_show_deleting (ctx, s);
|
file_progress_show_deleting (ctx, s);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
mc_refresh ();
|
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 */
|
/* ignore, most likely the mc_unlink fails, too */
|
||||||
buf.st_size = 0;
|
buf.st_size = 0;
|
||||||
@ -921,7 +976,10 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
{
|
{
|
||||||
return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s);
|
return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s);
|
||||||
if (return_status == FILE_ABORT)
|
if (return_status == FILE_ABORT)
|
||||||
|
{
|
||||||
|
vfs_path_free (vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
continue;
|
continue;
|
||||||
if (return_status == FILE_SKIPALL)
|
if (return_status == FILE_SKIPALL)
|
||||||
@ -929,6 +987,7 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfs_path_free (vpath);
|
||||||
if (tctx->progress_count == 0)
|
if (tctx->progress_count == 0)
|
||||||
return FILE_CONT;
|
return FILE_CONT;
|
||||||
return progress_update_one (tctx, ctx, buf.st_size);
|
return progress_update_one (tctx, ctx, buf.st_size);
|
||||||
@ -950,40 +1009,55 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
DIR *reading;
|
DIR *reading;
|
||||||
char *path;
|
char *path;
|
||||||
FileProgressStatus return_status = FILE_CONT;
|
FileProgressStatus return_status = FILE_CONT;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (!strcmp (s, ".."))
|
if (strcmp (s, "..") == 0)
|
||||||
return FILE_RETRY;
|
return FILE_RETRY;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (s);
|
||||||
reading = mc_opendir (s);
|
reading = mc_opendir (s);
|
||||||
|
|
||||||
if (!reading)
|
if (reading == NULL)
|
||||||
return FILE_RETRY;
|
{
|
||||||
|
return_status = FILE_RETRY;
|
||||||
|
goto ret;
|
||||||
|
}
|
||||||
|
|
||||||
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
if (!strcmp (next->d_name, "."))
|
if (!strcmp (next->d_name, "."))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp (next->d_name, ".."))
|
if (!strcmp (next->d_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
path = concat_dir_and_file (s, next->d_name);
|
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);
|
g_free (path);
|
||||||
mc_closedir (reading);
|
mc_closedir (reading);
|
||||||
return FILE_RETRY;
|
vfs_path_free (tmp_vpath);
|
||||||
|
return_status = FILE_RETRY;
|
||||||
|
goto ret;
|
||||||
}
|
}
|
||||||
if (S_ISDIR (buf.st_mode))
|
if (S_ISDIR (buf.st_mode))
|
||||||
return_status = recursive_erase (tctx, ctx, path);
|
return_status = recursive_erase (tctx, ctx, path);
|
||||||
else
|
else
|
||||||
return_status = erase_file (tctx, ctx, path);
|
return_status = erase_file (tctx, ctx, path);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
mc_closedir (reading);
|
mc_closedir (reading);
|
||||||
if (return_status == FILE_ABORT)
|
if (return_status == FILE_ABORT)
|
||||||
return return_status;
|
goto ret;
|
||||||
|
|
||||||
file_progress_show_deleting (ctx, s);
|
file_progress_show_deleting (ctx, s);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
{
|
||||||
|
return_status = FILE_ABORT;
|
||||||
|
goto ret;
|
||||||
|
}
|
||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
while (my_rmdir (s) != 0 && !ctx->skip_all)
|
while (my_rmdir (s) != 0 && !ctx->skip_all)
|
||||||
@ -992,13 +1066,15 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
continue;
|
continue;
|
||||||
if (return_status == FILE_ABORT)
|
if (return_status == FILE_ABORT)
|
||||||
return return_status;
|
goto ret;
|
||||||
if (return_status == FILE_SKIPALL)
|
if (return_status == FILE_SKIPALL)
|
||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FILE_CONT;
|
ret:
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -1336,6 +1412,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
dest_status_t dst_status = DEST_NONE;
|
dest_status_t dst_status = DEST_NONE;
|
||||||
int open_flags;
|
int open_flags;
|
||||||
gboolean is_first_time = TRUE;
|
gboolean is_first_time = TRUE;
|
||||||
|
vfs_path_t *src_vpath, *dst_vpath;
|
||||||
|
|
||||||
/* FIXME: We should not be using global variables! */
|
/* FIXME: We should not be using global variables! */
|
||||||
ctx->do_reget = 0;
|
ctx->do_reget = 0;
|
||||||
@ -1348,7 +1425,8 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
|
|
||||||
mc_refresh ();
|
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))
|
if (S_ISDIR (sb2.st_mode))
|
||||||
{
|
{
|
||||||
@ -1367,8 +1445,10 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
dst_exists = TRUE;
|
dst_exists = TRUE;
|
||||||
break;
|
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)
|
if (ctx->skip_all)
|
||||||
return_status = FILE_SKIPALL;
|
return_status = FILE_SKIPALL;
|
||||||
@ -1379,8 +1459,12 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
}
|
}
|
||||||
if (return_status != FILE_RETRY)
|
if (return_status != FILE_RETRY)
|
||||||
|
{
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
|
||||||
if (dst_exists)
|
if (dst_exists)
|
||||||
{
|
{
|
||||||
@ -1809,12 +1893,17 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
struct utimbuf utb;
|
struct utimbuf utb;
|
||||||
struct link *lp;
|
struct link *lp;
|
||||||
char *d;
|
char *d;
|
||||||
|
vfs_path_t *src_vpath, *dst_vpath;
|
||||||
|
|
||||||
d = g_strdup (_d);
|
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 */
|
/* First get the mode of the source dir */
|
||||||
|
|
||||||
retry_src_stat:
|
retry_src_stat:
|
||||||
if ((*ctx->stat_func) (s, &cbuf) != 0)
|
if ((*ctx->stat_func) (src_vpath, &cbuf) != 0)
|
||||||
{
|
{
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
return_status = FILE_SKIPALL;
|
return_status = FILE_SKIPALL;
|
||||||
@ -1872,11 +1961,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp = g_new (struct link, 1);
|
lp = g_new (struct link, 1);
|
||||||
{
|
lp->vfs = vfs_path_get_by_index (src_vpath, -1)->class;
|
||||||
vfs_path_t *vpath = vfs_path_from_str (s);
|
|
||||||
lp->vfs = vfs_path_get_by_index (vpath, -1)->class;
|
|
||||||
vfs_path_free (vpath);
|
|
||||||
}
|
|
||||||
lp->ino = cbuf.st_ino;
|
lp->ino = cbuf.st_ino;
|
||||||
lp->dev = cbuf.st_dev;
|
lp->dev = cbuf.st_dev;
|
||||||
lp->next = parent_dirs;
|
lp->next = parent_dirs;
|
||||||
@ -1884,7 +1969,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
retry_dst_stat:
|
retry_dst_stat:
|
||||||
/* Now, check if the dest dir exists, if not, create it. */
|
/* 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 ! */
|
/* Here the dir doesn't exist : make it ! */
|
||||||
if (move_over)
|
if (move_over)
|
||||||
@ -1949,11 +2034,12 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp = g_new (struct link, 1);
|
lp = g_new (struct link, 1);
|
||||||
mc_stat (dest_dir, &buf);
|
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath = vfs_path_from_str (dest_dir);
|
vfs_path_t *tmp_vpath = vfs_path_from_str (dest_dir);
|
||||||
lp->vfs = vfs_path_get_by_index (vpath, -1)->class;
|
mc_stat (tmp_vpath, &buf);
|
||||||
vfs_path_free (vpath);
|
|
||||||
|
lp->vfs = vfs_path_get_by_index (tmp_vpath, -1)->class;
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
}
|
}
|
||||||
lp->ino = buf.st_ino;
|
lp->ino = buf.st_ino;
|
||||||
lp->dev = buf.st_dev;
|
lp->dev = buf.st_dev;
|
||||||
@ -1987,6 +2073,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
vfs_path_t *tmp_vpath;
|
||||||
/*
|
/*
|
||||||
* Now, we don't want '.' and '..' to be created / copied at any time
|
* Now, we don't want '.' and '..' to be created / copied at any time
|
||||||
*/
|
*/
|
||||||
@ -1997,8 +2084,9 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
/* get the filename and add it to the src directory */
|
/* get the filename and add it to the src directory */
|
||||||
path = concat_dir_and_file (s, next->d_name);
|
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))
|
if (S_ISDIR (buf.st_mode))
|
||||||
{
|
{
|
||||||
char *mdpath;
|
char *mdpath;
|
||||||
@ -2051,6 +2139,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
}
|
}
|
||||||
mc_closedir (reading);
|
mc_closedir (reading);
|
||||||
|
|
||||||
@ -2074,6 +2163,8 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
g_free (parent_dirs);
|
g_free (parent_dirs);
|
||||||
ret_fast:
|
ret_fast:
|
||||||
g_free (d);
|
g_free (d);
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2091,6 +2182,10 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
FileProgressStatus return_status;
|
FileProgressStatus return_status;
|
||||||
gboolean move_over = FALSE;
|
gboolean move_over = FALSE;
|
||||||
gboolean dstat_ok;
|
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_source (ctx, s);
|
||||||
file_progress_show_target (ctx, d);
|
file_progress_show_target (ctx, d);
|
||||||
@ -2099,8 +2194,9 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
mc_stat (s, &sbuf);
|
mc_stat (src_vpath, &sbuf);
|
||||||
dstat_ok = (mc_stat (d, &dbuf) == 0);
|
|
||||||
|
dstat_ok = (mc_stat (dst_vpath, &dbuf) == 0);
|
||||||
|
|
||||||
if (dstat_ok && sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino)
|
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);
|
return warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same directory"), s, d);
|
||||||
@ -2115,9 +2211,11 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
else
|
else
|
||||||
destdir = concat_dir_and_file (d, x_basename (s));
|
destdir = concat_dir_and_file (d, x_basename (s));
|
||||||
|
|
||||||
|
destdir_vpath = vfs_path_from_str (destdir);
|
||||||
|
|
||||||
/* Check if the user inputted an existing dir */
|
/* Check if the user inputted an existing dir */
|
||||||
retry_dst_stat:
|
retry_dst_stat:
|
||||||
if (mc_stat (destdir, &destbuf) == 0)
|
if (mc_stat (destdir_vpath, &destbuf) == 0)
|
||||||
{
|
{
|
||||||
if (move_over)
|
if (move_over)
|
||||||
{
|
{
|
||||||
@ -2141,6 +2239,9 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
goto retry_dst_stat;
|
goto retry_dst_stat;
|
||||||
}
|
}
|
||||||
g_free (destdir);
|
g_free (destdir);
|
||||||
|
vfs_path_free (destdir_vpath);
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2196,12 +2297,15 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
ret:
|
ret:
|
||||||
g_free (destdir);
|
g_free (destdir);
|
||||||
|
vfs_path_free (destdir_vpath);
|
||||||
while (erase_list)
|
while (erase_list)
|
||||||
{
|
{
|
||||||
lp = erase_list;
|
lp = erase_list;
|
||||||
erase_list = erase_list->next;
|
erase_list = erase_list->next;
|
||||||
g_free (lp);
|
g_free (lp);
|
||||||
}
|
}
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2356,30 +2460,34 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
FileProgressStatus ret = FILE_CONT;
|
FileProgressStatus ret = FILE_CONT;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (dirname);
|
||||||
|
|
||||||
if (!compute_symlinks)
|
if (!compute_symlinks)
|
||||||
{
|
{
|
||||||
res = mc_lstat (dirname, &s);
|
res = mc_lstat (vpath, &s);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
return ret;
|
goto ret;
|
||||||
|
|
||||||
/* don't scan symlink to directory */
|
/* don't scan symlink to directory */
|
||||||
if (S_ISLNK (s.st_mode))
|
if (S_ISLNK (s.st_mode))
|
||||||
{
|
{
|
||||||
(*ret_marked)++;
|
(*ret_marked)++;
|
||||||
*ret_total += (uintmax_t) s.st_size;
|
*ret_total += (uintmax_t) s.st_size;
|
||||||
return ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = mc_opendir (dirname);
|
dir = mc_opendir (dirname);
|
||||||
|
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return ret;
|
goto ret;
|
||||||
|
|
||||||
while ((dirent = mc_readdir (dir)) != NULL)
|
while ((dirent = mc_readdir (dir)) != NULL)
|
||||||
{
|
{
|
||||||
char *fullname;
|
char *fullname;
|
||||||
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
ret = (cback != NULL) ? cback (ui, dirname) : FILE_CONT;
|
ret = (cback != NULL) ? cback (ui, dirname) : FILE_CONT;
|
||||||
|
|
||||||
@ -2392,11 +2500,13 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
fullname = concat_dir_and_file (dirname, dirent->d_name);
|
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)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
g_free (fullname);
|
g_free (fullname);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2412,6 +2522,7 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||||||
if (ret != FILE_CONT)
|
if (ret != FILE_CONT)
|
||||||
{
|
{
|
||||||
g_free (fullname);
|
g_free (fullname);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2425,10 +2536,12 @@ compute_dir_size (const char *dirname, const void *ui,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (fullname);
|
g_free (fullname);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
mc_closedir (dir);
|
mc_closedir (dir);
|
||||||
|
ret:
|
||||||
|
vfs_path_free (vpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2484,6 +2597,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
|
|
||||||
if (single_entry)
|
if (single_entry)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *source_vpath;
|
||||||
|
|
||||||
if (force_single)
|
if (force_single)
|
||||||
source = selection (panel)->fname;
|
source = selection (panel)->fname;
|
||||||
else
|
else
|
||||||
@ -2495,8 +2610,9 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source_vpath = vfs_path_from_str (source);
|
||||||
/* Update stat to get actual info */
|
/* Update stat to get actual info */
|
||||||
if (mc_lstat (source, &src_stat) != 0)
|
if (mc_lstat (source_vpath, &src_stat) != 0)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot stat \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot stat \"%s\"\n%s"),
|
||||||
path_trunc (source, 30), unix_error_string (errno));
|
path_trunc (source, 30), unix_error_string (errno));
|
||||||
@ -2512,9 +2628,10 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
|
|
||||||
update_panels (flags, UP_KEEPSEL);
|
update_panels (flags, UP_KEEPSEL);
|
||||||
}
|
}
|
||||||
|
vfs_path_free (source_vpath);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
vfs_path_free (source_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = file_op_context_new (operation);
|
ctx = file_op_context_new (operation);
|
||||||
@ -2718,7 +2835,11 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
{
|
{
|
||||||
case OP_COPY:
|
case OP_COPY:
|
||||||
/* we use file_mask_op_follow_links only with 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))
|
if (S_ISDIR (src_stat.st_mode))
|
||||||
value = copy_dir_dir (tctx, ctx, source_with_path, dest,
|
value = copy_dir_dir (tctx, ctx, source_with_path, dest,
|
||||||
@ -2754,8 +2875,10 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
{
|
{
|
||||||
int dst_result;
|
int dst_result;
|
||||||
struct stat dst_stat;
|
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))
|
if ((dst_result != 0) || S_ISDIR (dst_stat.st_mode))
|
||||||
break;
|
break;
|
||||||
@ -2816,7 +2939,13 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
|||||||
{
|
{
|
||||||
case OP_COPY:
|
case OP_COPY:
|
||||||
/* we use file_mask_op_follow_links only with 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))
|
if (S_ISDIR (src_stat.st_mode))
|
||||||
value = copy_dir_dir (tctx, ctx, source_with_path, temp2,
|
value = copy_dir_dir (tctx, ctx, source_with_path, temp2,
|
||||||
TRUE, FALSE, FALSE, NULL);
|
TRUE, FALSE, FALSE, NULL);
|
||||||
|
@ -1073,6 +1073,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
QuickDialog Quick_input = {
|
QuickDialog Quick_input = {
|
||||||
fmd_xlen, FMDY, -1, -1, op_names[operation],
|
fmd_xlen, FMDY, -1, -1, op_names[operation],
|
||||||
@ -1137,6 +1138,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||||||
tmp = dest_dir;
|
tmp = dest_dir;
|
||||||
dest_dir = tilde_expand (tmp);
|
dest_dir = tilde_expand (tmp);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
vpath = vfs_path_from_str (dest_dir);
|
||||||
|
|
||||||
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
|
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
|
||||||
if (ctx->dest_mask == NULL)
|
if (ctx->dest_mask == NULL)
|
||||||
@ -1144,13 +1146,13 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||||||
else
|
else
|
||||||
ctx->dest_mask++;
|
ctx->dest_mask++;
|
||||||
orig_mask = 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)
|
|| (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask)
|
||||||
&& (!only_one
|
&& (!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
|
|| (ctx->dive_into_subdirs
|
||||||
&& ((!only_one && !is_wildcarded (ctx->dest_mask))
|
&& ((!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");
|
ctx->dest_mask = g_strdup ("\\0");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1162,6 +1164,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
|||||||
g_free (dest_dir);
|
g_free (dest_dir);
|
||||||
dest_dir = g_strdup ("./");
|
dest_dir = g_strdup ("./");
|
||||||
}
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
if (val == B_USER)
|
if (val == B_USER)
|
||||||
*do_bg = TRUE;
|
*do_bg = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
#include <inttypes.h> /* uintmax_t */
|
#include <inttypes.h> /* uintmax_t */
|
||||||
|
|
||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
|
#include "lib/vfs/vfs.h"
|
||||||
|
|
||||||
|
|
||||||
/*** typedefs(not structures) and defined constants **********************************************/
|
/*** 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 ***************************************************************************************/
|
/*** enums ***************************************************************************************/
|
||||||
|
|
||||||
|
@ -968,17 +968,21 @@ search_content (Dlg_head * h, const char *directory, const char *filename)
|
|||||||
char *fname = NULL;
|
char *fname = NULL;
|
||||||
int file_fd;
|
int file_fd;
|
||||||
gboolean ret_val = FALSE;
|
gboolean ret_val = FALSE;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
fname = mc_build_filename (directory, filename, (char *) NULL);
|
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);
|
g_free (fname);
|
||||||
|
vfs_path_free (vpath);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_fd = mc_open (fname, O_RDONLY);
|
file_fd = mc_open (fname, O_RDONLY);
|
||||||
g_free (fname);
|
g_free (fname);
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
if (file_fd == -1)
|
if (file_fd == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1175,6 +1179,7 @@ do_search (Dlg_head * h)
|
|||||||
while (dirp == NULL)
|
while (dirp == NULL)
|
||||||
{
|
{
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
tty_setcolor (REVERSE_COLOR);
|
tty_setcolor (REVERSE_COLOR);
|
||||||
|
|
||||||
@ -1210,6 +1215,7 @@ do_search (Dlg_head * h)
|
|||||||
|
|
||||||
g_free (directory);
|
g_free (directory);
|
||||||
directory = tmp;
|
directory = tmp;
|
||||||
|
tmp_vpath = vfs_path_from_str (directory);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
@ -1222,12 +1228,13 @@ do_search (Dlg_head * h)
|
|||||||
/* mc_stat should not be called after mc_opendir
|
/* mc_stat should not be called after mc_opendir
|
||||||
because vfs_s_opendir modifies the st_nlink
|
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;
|
subdirs_left = tmp_stat.st_nlink - 2;
|
||||||
else
|
else
|
||||||
subdirs_left = 0;
|
subdirs_left = 0;
|
||||||
|
|
||||||
dirp = mc_opendir (directory);
|
dirp = mc_opendir (directory);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
} /* while (!dirp) */
|
} /* while (!dirp) */
|
||||||
|
|
||||||
/* skip invalid filenames */
|
/* skip invalid filenames */
|
||||||
@ -1255,17 +1262,18 @@ do_search (Dlg_head * h)
|
|||||||
ignore_count++;
|
ignore_count++;
|
||||||
else
|
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--;
|
subdirs_left--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_free (tmp_name);
|
vfs_path_free (tmp_vpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1627,9 +1627,17 @@ save_cwds_stat (void)
|
|||||||
{
|
{
|
||||||
if (panels_options.fast_reload)
|
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)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2467,12 +2467,20 @@ chdir_to_readlink (WPanel * panel)
|
|||||||
char buffer[MC_MAXPATHLEN], *p;
|
char buffer[MC_MAXPATHLEN], *p;
|
||||||
int i;
|
int i;
|
||||||
struct stat st;
|
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);
|
i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
{
|
||||||
|
vfs_path_free (panel_fname_vpath);
|
||||||
return;
|
return;
|
||||||
if (mc_stat (selection (panel)->fname, &st) < 0)
|
}
|
||||||
|
if (mc_stat (panel_fname_vpath, &st) < 0)
|
||||||
|
{
|
||||||
|
vfs_path_free (panel_fname_vpath);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
vfs_path_free (panel_fname_vpath);
|
||||||
buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
if (!S_ISDIR (st.st_mode))
|
if (!S_ISDIR (st.st_mode))
|
||||||
{
|
{
|
||||||
@ -3384,11 +3392,11 @@ reload_panelized (WPanel * panel)
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
dir_list *list = &panel->dir;
|
dir_list *list = &panel->dir;
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
if (panel != current_panel)
|
if (panel != current_panel)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
vfs_path_t *vpath;
|
|
||||||
|
|
||||||
vpath = vfs_path_from_str (panel->cwd);
|
vpath = vfs_path_from_str (panel->cwd);
|
||||||
ret = mc_chdir (vpath);
|
ret = mc_chdir (vpath);
|
||||||
@ -3407,9 +3415,11 @@ reload_panelized (WPanel * panel)
|
|||||||
*/
|
*/
|
||||||
do_file_mark (panel, i, 0);
|
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);
|
g_free (list->list[i].fname);
|
||||||
|
vfs_path_free (vpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (list->list[i].f.marked)
|
if (list->list[i].f.marked)
|
||||||
@ -3417,6 +3427,7 @@ reload_panelized (WPanel * panel)
|
|||||||
if (j != i)
|
if (j != i)
|
||||||
list->list[j] = list->list[i];
|
list->list[j] = list->list[i];
|
||||||
j++;
|
j++;
|
||||||
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
panel->count = set_zero_dir (list) ? 1 : 0;
|
panel->count = set_zero_dir (list) ? 1 : 0;
|
||||||
@ -3426,7 +3437,6 @@ reload_panelized (WPanel * panel)
|
|||||||
if (panel != current_panel)
|
if (panel != current_panel)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
vfs_path_t *vpath;
|
|
||||||
|
|
||||||
vpath = vfs_path_from_str (current_panel->cwd);
|
vpath = vfs_path_from_str (current_panel->cwd);
|
||||||
ret = mc_chdir (vpath);
|
ret = mc_chdir (vpath);
|
||||||
|
@ -795,7 +795,7 @@ tree_entry *
|
|||||||
tree_store_start_check (const char *path)
|
tree_store_start_check (const char *path)
|
||||||
{
|
{
|
||||||
tree_entry *current, *retval;
|
tree_entry *current, *retval;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
if (!ts.loaded)
|
if (!ts.loaded)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -808,9 +808,14 @@ tree_store_start_check (const char *path)
|
|||||||
if (!current)
|
if (!current)
|
||||||
{
|
{
|
||||||
struct stat s;
|
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;
|
return NULL;
|
||||||
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
if (!S_ISDIR (s.st_mode))
|
if (!S_ISDIR (s.st_mode))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -909,7 +914,7 @@ tree_store_rescan (const char *dir)
|
|||||||
{
|
{
|
||||||
for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp))
|
for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp))
|
||||||
{
|
{
|
||||||
char *full_name;
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
if (dp->d_name[0] == '.')
|
if (dp->d_name[0] == '.')
|
||||||
{
|
{
|
||||||
@ -917,13 +922,13 @@ tree_store_rescan (const char *dir)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
full_name = concat_dir_and_file (dir, dp->d_name);
|
tmp_vpath = vfs_path_build_filename (dir, dp->d_name, NULL);
|
||||||
if (mc_lstat (full_name, &buf) != -1)
|
if (mc_lstat (tmp_vpath, &buf) != -1)
|
||||||
{
|
{
|
||||||
if (S_ISDIR (buf.st_mode))
|
if (S_ISDIR (buf.st_mode))
|
||||||
tree_store_mark_checked (dp->d_name);
|
tree_store_mark_checked (dp->d_name);
|
||||||
}
|
}
|
||||||
g_free (full_name);
|
vfs_path_free (tmp_vpath);
|
||||||
}
|
}
|
||||||
mc_closedir (dirp);
|
mc_closedir (dirp);
|
||||||
}
|
}
|
||||||
|
@ -215,17 +215,19 @@ cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
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;
|
int fd, type;
|
||||||
cpio_super_data_t *arch;
|
cpio_super_data_t *arch;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
struct vfs_s_inode *root;
|
struct vfs_s_inode *root;
|
||||||
|
char *name = vfs_path_to_str (vpath);
|
||||||
|
|
||||||
fd = mc_open (name, O_RDONLY);
|
fd = mc_open (name, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
|
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
|
||||||
|
g_free (name);
|
||||||
return -1;
|
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);
|
super->data = g_new (cpio_super_data_t, 1);
|
||||||
arch = (cpio_super_data_t *) super->data;
|
arch = (cpio_super_data_t *) super->data;
|
||||||
arch->fd = -1; /* for now */
|
arch->fd = -1; /* for now */
|
||||||
mc_stat (name, &arch->st);
|
mc_stat (vpath, &arch->st);
|
||||||
arch->type = CPIO_UNKNOWN;
|
arch->type = CPIO_UNKNOWN;
|
||||||
arch->deferred = NULL;
|
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);
|
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
|
||||||
g_free (s);
|
g_free (s);
|
||||||
|
g_free (name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_free (s);
|
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;
|
super->root = root;
|
||||||
|
|
||||||
CPIO_SEEK_SET (super, 0);
|
CPIO_SEEK_SET (super, 0);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
return fd;
|
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)
|
const vfs_path_element_t * vpath_element)
|
||||||
{
|
{
|
||||||
int status = STATUS_START;
|
int status = STATUS_START;
|
||||||
char *archive_name = vfs_path_to_str (vpath);
|
|
||||||
|
|
||||||
(void) vpath_element;
|
(void) vpath_element;
|
||||||
|
|
||||||
if (cpio_open_cpio_file (vpath_element->class, super, archive_name) == -1)
|
if (cpio_open_cpio_file (vpath_element->class, super, vpath) == -1)
|
||||||
{
|
|
||||||
g_free (archive_name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@ -740,8 +740,14 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
|||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case STATUS_EOF:
|
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:
|
case STATUS_OK:
|
||||||
continue;
|
continue;
|
||||||
case STATUS_TRAIL:
|
case STATUS_TRAIL:
|
||||||
@ -750,7 +756,6 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (archive_name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,11 +766,9 @@ static void *
|
|||||||
cpio_super_check (const vfs_path_t * vpath)
|
cpio_super_check (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
static struct stat sb;
|
static struct stat sb;
|
||||||
char *archive_name = vfs_path_to_str (vpath);
|
|
||||||
int stat_result;
|
int stat_result;
|
||||||
|
|
||||||
stat_result = mc_stat (archive_name, &sb);
|
stat_result = mc_stat (vpath, &sb);
|
||||||
g_free (archive_name);
|
|
||||||
return (stat_result == 0 ? &sb : NULL);
|
return (stat_result == 0 ? &sb : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,8 +375,11 @@ extfs_free_archive (struct archive *archive)
|
|||||||
if (archive->local_name != NULL)
|
if (archive->local_name != NULL)
|
||||||
{
|
{
|
||||||
struct stat my;
|
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,
|
mc_ungetlocalcopy (archive->name, archive->local_name,
|
||||||
archive->local_stat.st_mtime != my.st_mtime);
|
archive->local_stat.st_mtime != my.st_mtime);
|
||||||
g_free (archive->local_name);
|
g_free (archive->local_name);
|
||||||
@ -392,7 +395,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
{
|
{
|
||||||
const extfs_plugin_info_t *info;
|
const extfs_plugin_info_t *info;
|
||||||
static dev_t archive_counter = 0;
|
static dev_t archive_counter = 0;
|
||||||
FILE *result;
|
FILE *result = NULL;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
@ -410,14 +413,14 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
|
|
||||||
if (info->need_archive)
|
if (info->need_archive)
|
||||||
{
|
{
|
||||||
if (mc_stat (name, &mystat) == -1)
|
if (mc_stat (vpath, &mystat) == -1)
|
||||||
return NULL;
|
goto ret;
|
||||||
|
|
||||||
if (!vfs_file_is_local (vpath))
|
if (!vfs_file_is_local (vpath))
|
||||||
{
|
{
|
||||||
local_name = mc_getlocalcopy (name);
|
local_name = mc_getlocalcopy (name);
|
||||||
if (local_name == NULL)
|
if (local_name == NULL)
|
||||||
return NULL;
|
goto ret;
|
||||||
}
|
}
|
||||||
tmp = name_quote ((vpath != NULL) ? path_element->path : name, 0);
|
tmp = name_quote ((vpath != NULL) ? path_element->path : name, 0);
|
||||||
}
|
}
|
||||||
@ -437,8 +440,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
mc_ungetlocalcopy (name, local_name, 0);
|
mc_ungetlocalcopy (name, local_name, 0);
|
||||||
g_free (local_name);
|
g_free (local_name);
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath);
|
goto ret;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ___QNXNTO__
|
#ifdef ___QNXNTO__
|
||||||
@ -451,7 +453,11 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
current_archive->local_name = local_name;
|
current_archive->local_name = local_name;
|
||||||
|
|
||||||
if (local_name != NULL)
|
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->inode_counter = 0;
|
||||||
current_archive->fd_usage = 0;
|
current_archive->fd_usage = 0;
|
||||||
current_archive->rdev = archive_counter++;
|
current_archive->rdev = archive_counter++;
|
||||||
@ -475,6 +481,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
|
|
||||||
*pparc = current_archive;
|
*pparc = current_archive;
|
||||||
|
|
||||||
|
ret:
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
return result;
|
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->name = archive_name;
|
||||||
archive->data = g_new (tar_super_data_t, 1);
|
archive->data = g_new (tar_super_data_t, 1);
|
||||||
arch = (tar_super_data_t *) archive->data;
|
arch = (tar_super_data_t *) archive->data;
|
||||||
mc_stat (archive_name, &arch->st);
|
mc_stat (vpath, &arch->st);
|
||||||
arch->fd = -1;
|
arch->fd = -1;
|
||||||
arch->type = TAR_UNKNOWN;
|
arch->type = TAR_UNKNOWN;
|
||||||
|
|
||||||
@ -819,11 +819,9 @@ static void *
|
|||||||
tar_super_check (const vfs_path_t * vpath)
|
tar_super_check (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
static struct stat stat_buf;
|
static struct stat stat_buf;
|
||||||
char *archive_name = vfs_path_to_str (vpath);
|
|
||||||
int stat_result;
|
int stat_result;
|
||||||
|
|
||||||
stat_result = mc_stat (archive_name, &stat_buf);
|
stat_result = mc_stat (vpath, &stat_buf);
|
||||||
g_free (archive_name);
|
|
||||||
|
|
||||||
return (stat_result != 0) ? NULL : &stat_buf;
|
return (stat_result != 0) ? NULL : &stat_buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user