mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Changed interface of following functions to handle vfs_path_t object as parameter:
* mc_chmod() * mc_chown() * mc_utime() * mc_readlink() * mc_unlink() * mc_mkdir() * mc_rmdir() * mc_mknod() Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
cb2ad816f6
commit
a78f87d30d
10
lib/util.c
10
lib/util.c
@ -150,7 +150,7 @@ resolve_symlinks (const char *path)
|
|||||||
strcpy (r, p + 1);
|
strcpy (r, p + 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1);
|
len = mc_readlink (vpath, buf2, MC_MAXPATHLEN - 1);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
@ -1521,7 +1521,13 @@ mc_util_unlink_backup_if_possible (const char *file_name, const char *backup_suf
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (exist_file (backup_path))
|
if (exist_file (backup_path))
|
||||||
mc_unlink (backup_path);
|
{
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (backup_path);
|
||||||
|
mc_unlink (vpath);
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (backup_path);
|
g_free (backup_path);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -225,35 +225,31 @@ mc_open (const char *filename, int flags, ...)
|
|||||||
int mc_##name inarg \
|
int mc_##name inarg \
|
||||||
{ \
|
{ \
|
||||||
int result; \
|
int result; \
|
||||||
vfs_path_t *vpath; \
|
|
||||||
vfs_path_element_t *path_element; \
|
vfs_path_element_t *path_element; \
|
||||||
\
|
\
|
||||||
vpath = vfs_path_from_str (path); \
|
|
||||||
if (vpath == NULL) \
|
if (vpath == NULL) \
|
||||||
return -1; \
|
return -1; \
|
||||||
\
|
\
|
||||||
path_element = vfs_path_get_by_index (vpath, -1); \
|
path_element = vfs_path_get_by_index (vpath, -1); \
|
||||||
if (!vfs_path_element_valid (path_element)) \
|
if (!vfs_path_element_valid (path_element)) \
|
||||||
{ \
|
{ \
|
||||||
vfs_path_free(vpath); \
|
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
result = path_element->class->name != NULL ? path_element->class->name callarg : -1; \
|
result = path_element->class->name != NULL ? path_element->class->name callarg : -1; \
|
||||||
if (result == -1) \
|
if (result == -1) \
|
||||||
errno = path_element->class->name != NULL ? vfs_ferrno (path_element->class) : E_NOTSUPP; \
|
errno = path_element->class->name != NULL ? vfs_ferrno (path_element->class) : E_NOTSUPP; \
|
||||||
vfs_path_free(vpath); \
|
|
||||||
return result; \
|
return result; \
|
||||||
}
|
}
|
||||||
|
|
||||||
MC_NAMEOP (chmod, (const char *path, mode_t mode), (vpath, mode))
|
MC_NAMEOP (chmod, (const vfs_path_t *vpath, mode_t mode), (vpath, mode))
|
||||||
MC_NAMEOP (chown, (const char *path, uid_t owner, gid_t group), (vpath, owner, group))
|
MC_NAMEOP (chown, (const vfs_path_t *vpath, uid_t owner, gid_t group), (vpath, owner, group))
|
||||||
MC_NAMEOP (utime, (const char *path, struct utimbuf * times), (vpath, times))
|
MC_NAMEOP (utime, (const vfs_path_t *vpath, struct utimbuf * times), (vpath, times))
|
||||||
MC_NAMEOP (readlink, (const char *path, char *buf, size_t bufsiz), (vpath, buf, bufsiz))
|
MC_NAMEOP (readlink, (const vfs_path_t *vpath, char *buf, size_t bufsiz), (vpath, buf, bufsiz))
|
||||||
MC_NAMEOP (unlink, (const char *path), (vpath))
|
MC_NAMEOP (unlink, (const vfs_path_t *vpath), (vpath))
|
||||||
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (vpath, mode))
|
MC_NAMEOP (mkdir, (const vfs_path_t *vpath, mode_t mode), (vpath, mode))
|
||||||
MC_NAMEOP (rmdir, (const char *path), (vpath))
|
MC_NAMEOP (rmdir, (const vfs_path_t *vpath), (vpath))
|
||||||
MC_NAMEOP (mknod, (const char *path, mode_t mode, dev_t dev), (vpath, mode, dev))
|
MC_NAMEOP (mknod, (const vfs_path_t *vpath, mode_t mode, dev_t dev), (vpath, mode, dev))
|
||||||
|
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
@ -277,26 +277,26 @@ int vfs_preallocate (int dest_desc, off_t src_fsize, off_t dest_fsize);
|
|||||||
*/
|
*/
|
||||||
ssize_t mc_read (int handle, void *buffer, size_t count);
|
ssize_t mc_read (int handle, void *buffer, size_t count);
|
||||||
ssize_t mc_write (int handle, const void *buffer, size_t count);
|
ssize_t mc_write (int handle, const void *buffer, size_t count);
|
||||||
int mc_utime (const char *path, struct utimbuf *times);
|
int mc_utime (const vfs_path_t * vpath, struct utimbuf *times);
|
||||||
int mc_readlink (const char *path, char *buf, size_t bufsiz);
|
int mc_readlink (const vfs_path_t * vpath, char *buf, size_t bufsiz);
|
||||||
int mc_close (int handle);
|
int mc_close (int handle);
|
||||||
off_t mc_lseek (int fd, off_t offset, int whence);
|
off_t mc_lseek (int fd, off_t offset, int whence);
|
||||||
DIR *mc_opendir (const vfs_path_t * vpath);
|
DIR *mc_opendir (const vfs_path_t * vpath);
|
||||||
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 vfs_path_t * vpath, 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 vfs_path_t * vpath, 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 vfs_path_t * vpath, mode_t mode);
|
||||||
int mc_rmdir (const char *path);
|
int mc_rmdir (const vfs_path_t * vpath);
|
||||||
int mc_fstat (int fd, struct stat *buf);
|
int mc_fstat (int fd, struct stat *buf);
|
||||||
int mc_lstat (const vfs_path_t * vpath, 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 vfs_path_t * vpath, mode_t mode);
|
||||||
int mc_chown (const char *path, uid_t owner, gid_t group);
|
int mc_chown (const vfs_path_t * vpath, uid_t owner, gid_t group);
|
||||||
int mc_chdir (const vfs_path_t * vpath);
|
int mc_chdir (const vfs_path_t * vpath);
|
||||||
int mc_unlink (const char *path);
|
int mc_unlink (const vfs_path_t * vpath);
|
||||||
int mc_ctl (int fd, int ctlop, void *arg);
|
int mc_ctl (int fd, int ctlop, void *arg);
|
||||||
int mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg);
|
int mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg);
|
||||||
int mc_open (const char *filename, int flags, ...);
|
int mc_open (const char *filename, int flags, ...);
|
||||||
|
@ -235,10 +235,15 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
savename = g_strdup (real_filename);
|
savename = g_strdup (real_filename);
|
||||||
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
|
vfs_path_t *savename_vpath;
|
||||||
ret = mc_chmod (savename, edit->stat1.st_mode);
|
|
||||||
|
savename_vpath = vfs_path_from_str (savename);
|
||||||
|
ret = mc_chown (savename_vpath, edit->stat1.st_uid, edit->stat1.st_gid);
|
||||||
|
ret = mc_chmod (savename_vpath, edit->stat1.st_mode);
|
||||||
|
vfs_path_free (savename_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, edit->stat1.st_mode);
|
fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, edit->stat1.st_mode);
|
||||||
|
@ -725,26 +725,27 @@ next_file (void)
|
|||||||
static void
|
static void
|
||||||
apply_advanced_chowns (struct stat *sf)
|
apply_advanced_chowns (struct stat *sf)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *vpath;
|
||||||
char *lc_fname;
|
char *lc_fname;
|
||||||
gid_t a_gid = sf->st_gid;
|
gid_t a_gid = sf->st_gid;
|
||||||
uid_t a_uid = sf->st_uid;
|
uid_t a_uid = sf->st_uid;
|
||||||
|
|
||||||
lc_fname = current_panel->dir.list[current_file].fname;
|
lc_fname = current_panel->dir.list[current_file].fname;
|
||||||
|
vpath = vfs_path_from_str (lc_fname);
|
||||||
need_update = end_chown = 1;
|
need_update = end_chown = 1;
|
||||||
if (mc_chmod (lc_fname, get_mode ()) == -1)
|
if (mc_chmod (vpath, get_mode ()) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||||
lc_fname, unix_error_string (errno));
|
lc_fname, unix_error_string (errno));
|
||||||
/* call mc_chown only, if mc_chmod didn't fail */
|
/* call mc_chown only, if mc_chmod didn't fail */
|
||||||
else if (mc_chown (lc_fname, (ch_flags[9] == '+') ? sf->st_uid : (uid_t) - 1,
|
else if (mc_chown (vpath, (ch_flags[9] == '+') ? sf->st_uid : (uid_t) - 1,
|
||||||
(ch_flags[10] == '+') ? sf->st_gid : (gid_t) - 1) == -1)
|
(ch_flags[10] == '+') ? sf->st_gid : (gid_t) - 1) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
||||||
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);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
|
||||||
|
|
||||||
lc_fname = next_file ();
|
lc_fname = next_file ();
|
||||||
vpath = vfs_path_from_str (lc_fname);
|
vpath = vfs_path_from_str (lc_fname);
|
||||||
|
|
||||||
@ -754,11 +755,11 @@ apply_advanced_chowns (struct stat *sf)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ch_cmode = sf->st_mode;
|
ch_cmode = sf->st_mode;
|
||||||
if (mc_chmod (lc_fname, get_mode ()) == -1)
|
if (mc_chmod (vpath, get_mode ()) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||||
lc_fname, unix_error_string (errno));
|
lc_fname, unix_error_string (errno));
|
||||||
/* call mc_chown only, if mc_chmod didn't fail */
|
/* call mc_chown only, if mc_chmod didn't fail */
|
||||||
else if (mc_chown (lc_fname, (ch_flags[9] == '+') ? a_uid : (uid_t) - 1,
|
else if (mc_chown (vpath, (ch_flags[9] == '+') ? a_uid : (uid_t) - 1,
|
||||||
(ch_flags[10] == '+') ? a_gid : (gid_t) - 1) == -1)
|
(ch_flags[10] == '+') ? a_gid : (gid_t) - 1) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
||||||
lc_fname, unix_error_string (errno));
|
lc_fname, unix_error_string (errno));
|
||||||
@ -776,7 +777,6 @@ apply_advanced_chowns (struct stat *sf)
|
|||||||
void
|
void
|
||||||
chown_advanced_cmd (void)
|
chown_advanced_cmd (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
files_on_begin = current_panel->marked;
|
files_on_begin = current_panel->marked;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -812,15 +812,22 @@ chown_advanced_cmd (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_ENTER:
|
case B_ENTER:
|
||||||
need_update = 1;
|
{
|
||||||
if (mc_chmod (fname, get_mode ()) == -1)
|
vfs_path_t *fname_vpath;
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
|
||||||
fname, unix_error_string (errno));
|
fname_vpath = vfs_path_from_str (fname);
|
||||||
/* call mc_chown only, if mc_chmod didn't fail */
|
need_update = 1;
|
||||||
else if (mc_chown (fname, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) - 1,
|
if (mc_chmod (fname_vpath, get_mode ()) == -1)
|
||||||
(ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) - 1) == -1)
|
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
fname, unix_error_string (errno));
|
||||||
fname, unix_error_string (errno));
|
/* call mc_chown only, if mc_chmod didn't fail */
|
||||||
|
else if (mc_chown
|
||||||
|
(fname_vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) - 1,
|
||||||
|
(ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) - 1) == -1)
|
||||||
|
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname,
|
||||||
|
unix_error_string (errno));
|
||||||
|
vfs_path_free (fname_vpath);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case B_SETALL:
|
case B_SETALL:
|
||||||
apply_advanced_chowns (sf_stat);
|
apply_advanced_chowns (sf_stat);
|
||||||
|
@ -366,13 +366,16 @@ next_file (void)
|
|||||||
static void
|
static void
|
||||||
do_chmod (struct stat *sf)
|
do_chmod (struct stat *sf)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *vpath;
|
||||||
sf->st_mode &= and_mask;
|
sf->st_mode &= and_mask;
|
||||||
sf->st_mode |= or_mask;
|
sf->st_mode |= or_mask;
|
||||||
|
|
||||||
if (mc_chmod (current_panel->dir.list[c_file].fname, sf->st_mode) == -1)
|
vpath = vfs_path_from_str (current_panel->dir.list[c_file].fname);
|
||||||
|
if (mc_chmod (vpath, sf->st_mode) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||||
current_panel->dir.list[c_file].fname, unix_error_string (errno));
|
current_panel->dir.list[c_file].fname, unix_error_string (errno));
|
||||||
|
|
||||||
|
vfs_path_free (vpath);
|
||||||
do_file_mark (current_panel, c_file, 0);
|
do_file_mark (current_panel, c_file, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +446,6 @@ chmod_cmd (void)
|
|||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath);
|
|
||||||
|
|
||||||
c_stat = sf_stat.st_mode;
|
c_stat = sf_stat.st_mode;
|
||||||
|
|
||||||
@ -455,7 +457,7 @@ chmod_cmd (void)
|
|||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case B_ENTER:
|
case B_ENTER:
|
||||||
if (mode_change && mc_chmod (fname, c_stat) == -1)
|
if (mode_change && mc_chmod (vpath, c_stat) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
|
||||||
fname, unix_error_string (errno));
|
fname, unix_error_string (errno));
|
||||||
need_update = TRUE;
|
need_update = TRUE;
|
||||||
@ -511,6 +513,8 @@ chmod_cmd (void)
|
|||||||
need_update = TRUE;
|
need_update = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
destroy_dlg (ch_dlg);
|
destroy_dlg (ch_dlg);
|
||||||
}
|
}
|
||||||
while (current_panel->marked != 0 && !end_chmod);
|
while (current_panel->marked != 0 && !end_chmod);
|
||||||
|
@ -242,10 +242,14 @@ chown_done (void)
|
|||||||
static void
|
static void
|
||||||
do_chown (uid_t u, gid_t g)
|
do_chown (uid_t u, gid_t g)
|
||||||
{
|
{
|
||||||
if (mc_chown (current_panel->dir.list[current_file].fname, u, g) == -1)
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (current_panel->dir.list[current_file].fname);
|
||||||
|
if (mc_chown (vpath, u, g) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
||||||
current_panel->dir.list[current_file].fname, unix_error_string (errno));
|
current_panel->dir.list[current_file].fname, unix_error_string (errno));
|
||||||
|
|
||||||
|
vfs_path_free (vpath);
|
||||||
do_file_mark (current_panel, current_file, 0);
|
do_file_mark (current_panel, current_file, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,6 +289,7 @@ chown_cmd (void)
|
|||||||
do
|
do
|
||||||
{ /* do while any files remaining */
|
{ /* do while any files remaining */
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
ch_dlg = init_chown ();
|
ch_dlg = init_chown ();
|
||||||
new_user = new_group = -1;
|
new_user = new_group = -1;
|
||||||
|
|
||||||
@ -366,10 +371,14 @@ chown_cmd (void)
|
|||||||
new_user = user->pw_uid;
|
new_user = user->pw_uid;
|
||||||
if (ch_dlg->ret_value == B_ENTER)
|
if (ch_dlg->ret_value == B_ENTER)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *fname_vpath;
|
||||||
|
|
||||||
|
fname_vpath = vfs_path_from_str (fname);
|
||||||
need_update = 1;
|
need_update = 1;
|
||||||
if (mc_chown (fname, new_user, new_group) == -1)
|
if (mc_chown (fname_vpath, new_user, new_group) == -1)
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
|
||||||
fname, unix_error_string (errno));
|
fname, unix_error_string (errno));
|
||||||
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
apply_chowns (new_user, new_group);
|
apply_chowns (new_user, new_group);
|
||||||
|
@ -1324,8 +1324,10 @@ edit_symlink_cmd (void)
|
|||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
int i;
|
int i;
|
||||||
char *dest, *q;
|
char *dest, *q;
|
||||||
|
vfs_path_t *p_vpath;
|
||||||
|
|
||||||
p = selection (current_panel)->fname;
|
p = selection (current_panel)->fname;
|
||||||
|
p_vpath = vfs_path_from_str (p);
|
||||||
|
|
||||||
q = g_strdup_printf (_("Symlink `%s\' points to:"), str_trunc (p, 32));
|
q = g_strdup_printf (_("Symlink `%s\' points to:"), str_trunc (p, 32));
|
||||||
|
|
||||||
@ -1339,7 +1341,7 @@ edit_symlink_cmd (void)
|
|||||||
if (*dest && strcmp (buffer, dest))
|
if (*dest && strcmp (buffer, dest))
|
||||||
{
|
{
|
||||||
save_cwds_stat ();
|
save_cwds_stat ();
|
||||||
if (-1 == mc_unlink (p))
|
if (mc_unlink (p_vpath) == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("edit symlink, unable to remove %s: %s"),
|
message (D_ERROR, MSG_ERROR, _("edit symlink, unable to remove %s: %s"),
|
||||||
p, unix_error_string (errno));
|
p, unix_error_string (errno));
|
||||||
@ -1357,6 +1359,7 @@ edit_symlink_cmd (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (q);
|
g_free (q);
|
||||||
|
vfs_path_free (p_vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -375,7 +375,7 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
dst_is_symlink = (mc_lstat (dst_vpath, &sb) == 0) && S_ISLNK (sb.st_mode);
|
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_vpath, link_target, MC_MAXPATHLEN - 1);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
@ -451,7 +451,7 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
|
|||||||
*/
|
*/
|
||||||
if (dst_is_symlink)
|
if (dst_is_symlink)
|
||||||
{
|
{
|
||||||
if (!mc_unlink (dst_path))
|
if (mc_unlink (dst_vpath) == 0)
|
||||||
if (mc_symlink (link_target, dst_path) == 0)
|
if (mc_symlink (link_target, dst_path) == 0)
|
||||||
{
|
{
|
||||||
/* Success */
|
/* Success */
|
||||||
@ -926,7 +926,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
|
|||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
retry_src_remove:
|
retry_src_remove:
|
||||||
if (mc_unlink (s) != 0 && !ctx->skip_all)
|
if (mc_unlink (src_vpath) != 0 && !ctx->skip_all)
|
||||||
{
|
{
|
||||||
return_status = file_error (_("Cannot remove file \"%s\"\n%s"), s);
|
return_status = file_error (_("Cannot remove file \"%s\"\n%s"), s);
|
||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
@ -972,7 +972,7 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
|
|||||||
buf.st_size = 0;
|
buf.st_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mc_unlink (s) != 0 && !ctx->skip_all)
|
while (mc_unlink (vpath) != 0 && !ctx->skip_all)
|
||||||
{
|
{
|
||||||
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)
|
||||||
@ -1417,7 +1417,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;
|
vfs_path_t *src_vpath = NULL, *dst_vpath = NULL;
|
||||||
|
|
||||||
/* FIXME: We should not be using global variables! */
|
/* FIXME: We should not be using global variables! */
|
||||||
ctx->do_reget = 0;
|
ctx->do_reget = 0;
|
||||||
@ -1445,12 +1445,11 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return return_status;
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
dst_exists = TRUE;
|
dst_exists = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vfs_path_free (dst_vpath);
|
|
||||||
|
|
||||||
src_vpath = vfs_path_from_str (src_path);
|
src_vpath = vfs_path_from_str (src_path);
|
||||||
while ((*ctx->stat_func) (src_vpath, &sb) != 0)
|
while ((*ctx->stat_func) (src_vpath, &sb) != 0)
|
||||||
@ -1464,25 +1463,25 @@ 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)
|
||||||
{
|
goto ret_fast;
|
||||||
vfs_path_free (src_vpath);
|
|
||||||
return return_status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
vfs_path_free (src_vpath);
|
|
||||||
|
|
||||||
if (dst_exists)
|
if (dst_exists)
|
||||||
{
|
{
|
||||||
/* Destination already exists */
|
/* Destination already exists */
|
||||||
if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino)
|
if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino)
|
||||||
return warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same file"), src_path, dst_path);
|
{
|
||||||
|
return_status = warn_same_file (_("\"%s\"\nand\n\"%s\"\nare the same file"),
|
||||||
|
src_path, dst_path);
|
||||||
|
goto ret_fast;
|
||||||
|
}
|
||||||
/* Should we replace destination? */
|
/* Should we replace destination? */
|
||||||
if (tctx->ask_overwrite)
|
if (tctx->ask_overwrite)
|
||||||
{
|
{
|
||||||
ctx->do_reget = 0;
|
ctx->do_reget = 0;
|
||||||
return_status = query_replace (ctx, dst_path, &sb, &sb2);
|
return_status = query_replace (ctx, dst_path, &sb, &sb2);
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
return return_status;
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1492,16 +1491,20 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
if (!ctx->follow_links && sb.st_nlink > 1 && check_hardlinks (src_path, dst_path, &sb))
|
if (!ctx->follow_links && sb.st_nlink > 1 && check_hardlinks (src_path, dst_path, &sb))
|
||||||
{
|
{
|
||||||
/* We have made a hardlink - no more processing is necessary */
|
/* We have made a hardlink - no more processing is necessary */
|
||||||
return FILE_CONT;
|
return_status = FILE_CONT;
|
||||||
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISLNK (sb.st_mode))
|
if (S_ISLNK (sb.st_mode))
|
||||||
return make_symlink (ctx, src_path, dst_path);
|
{
|
||||||
|
return_status = make_symlink (ctx, src_path, dst_path);
|
||||||
|
goto ret_fast;
|
||||||
|
}
|
||||||
|
|
||||||
if (S_ISCHR (sb.st_mode) || S_ISBLK (sb.st_mode) ||
|
if (S_ISCHR (sb.st_mode) || S_ISBLK (sb.st_mode) ||
|
||||||
S_ISFIFO (sb.st_mode) || S_ISNAM (sb.st_mode) || S_ISSOCK (sb.st_mode))
|
S_ISFIFO (sb.st_mode) || S_ISNAM (sb.st_mode) || S_ISSOCK (sb.st_mode))
|
||||||
{
|
{
|
||||||
while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, sb.st_rdev) < 0
|
while (mc_mknod (dst_vpath, sb.st_mode & ctx->umask_kill, sb.st_rdev) < 0
|
||||||
&& !ctx->skip_all)
|
&& !ctx->skip_all)
|
||||||
{
|
{
|
||||||
return_status = file_error (_("Cannot create special file \"%s\"\n%s"), dst_path);
|
return_status = file_error (_("Cannot create special file \"%s\"\n%s"), dst_path);
|
||||||
@ -1509,11 +1512,11 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
continue;
|
continue;
|
||||||
if (return_status == FILE_SKIPALL)
|
if (return_status == FILE_SKIPALL)
|
||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
return return_status;
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
/* Success */
|
/* Success */
|
||||||
|
|
||||||
while (ctx->preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid) != 0
|
while (ctx->preserve_uidgid && mc_chown (dst_vpath, sb.st_uid, sb.st_gid) != 0
|
||||||
&& !ctx->skip_all)
|
&& !ctx->skip_all)
|
||||||
{
|
{
|
||||||
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
|
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
|
||||||
@ -1522,10 +1525,13 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
if (temp_status == FILE_SKIPALL)
|
if (temp_status == FILE_SKIPALL)
|
||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
if (temp_status != FILE_RETRY)
|
if (temp_status != FILE_RETRY)
|
||||||
return temp_status;
|
{
|
||||||
|
return_status = temp_status;
|
||||||
|
goto ret_fast;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ctx->preserve && mc_chmod (dst_path, sb.st_mode & ctx->umask_kill) != 0
|
while (ctx->preserve && mc_chmod (dst_vpath, sb.st_mode & ctx->umask_kill) != 0
|
||||||
&& !ctx->skip_all)
|
&& !ctx->skip_all)
|
||||||
{
|
{
|
||||||
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
|
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
|
||||||
@ -1534,10 +1540,14 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
if (temp_status == FILE_SKIPALL)
|
if (temp_status == FILE_SKIPALL)
|
||||||
ctx->skip_all = TRUE;
|
ctx->skip_all = TRUE;
|
||||||
if (temp_status != FILE_RETRY)
|
if (temp_status != FILE_RETRY)
|
||||||
return temp_status;
|
{
|
||||||
|
return_status = temp_status;
|
||||||
|
goto ret_fast;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FILE_CONT;
|
return_status = FILE_CONT;
|
||||||
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1553,7 +1563,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
if (return_status == FILE_SKIP)
|
if (return_status == FILE_SKIP)
|
||||||
break;
|
break;
|
||||||
ctx->do_append = 0;
|
ctx->do_append = 0;
|
||||||
return return_status;
|
goto ret_fast;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->do_reget != 0)
|
if (ctx->do_reget != 0)
|
||||||
@ -1659,7 +1669,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
}
|
}
|
||||||
mc_close (dest_desc);
|
mc_close (dest_desc);
|
||||||
dest_desc = -1;
|
dest_desc = -1;
|
||||||
mc_unlink (dst_path);
|
mc_unlink (dst_vpath);
|
||||||
dst_status = DEST_NONE;
|
dst_status = DEST_NONE;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1815,18 +1825,19 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
{
|
{
|
||||||
/* Remove short file */
|
/* Remove short file */
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = query_dialog (Q_ ("DialogTitle|Copy"),
|
result = query_dialog (Q_ ("DialogTitle|Copy"),
|
||||||
_("Incomplete file was retrieved. Keep it?"),
|
_("Incomplete file was retrieved. Keep it?"),
|
||||||
D_ERROR, 2, _("&Delete"), _("&Keep"));
|
D_ERROR, 2, _("&Delete"), _("&Keep"));
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
mc_unlink (dst_path);
|
mc_unlink (dst_vpath);
|
||||||
}
|
}
|
||||||
else if (dst_status == DEST_FULL)
|
else if (dst_status == DEST_FULL)
|
||||||
{
|
{
|
||||||
/* Copy has succeeded */
|
/* Copy has succeeded */
|
||||||
if (!appending && ctx->preserve_uidgid)
|
if (!appending && ctx->preserve_uidgid)
|
||||||
{
|
{
|
||||||
while (mc_chown (dst_path, src_uid, src_gid) != 0 && !ctx->skip_all)
|
while (mc_chown (dst_vpath, src_uid, src_gid) != 0 && !ctx->skip_all)
|
||||||
{
|
{
|
||||||
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
|
temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path);
|
||||||
if (temp_status == FILE_RETRY)
|
if (temp_status == FILE_RETRY)
|
||||||
@ -1846,7 +1857,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
{
|
{
|
||||||
if (ctx->preserve)
|
if (ctx->preserve)
|
||||||
{
|
{
|
||||||
while (mc_chmod (dst_path, (src_mode & ctx->umask_kill)) != 0 && !ctx->skip_all)
|
while (mc_chmod (dst_vpath, (src_mode & ctx->umask_kill)) != 0 && !ctx->skip_all)
|
||||||
{
|
{
|
||||||
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
|
temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path);
|
||||||
if (temp_status == FILE_RETRY)
|
if (temp_status == FILE_RETRY)
|
||||||
@ -1866,15 +1877,18 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
|||||||
src_mode = umask (-1);
|
src_mode = umask (-1);
|
||||||
umask (src_mode);
|
umask (src_mode);
|
||||||
src_mode = 0100666 & ~src_mode;
|
src_mode = 0100666 & ~src_mode;
|
||||||
mc_chmod (dst_path, (src_mode & ctx->umask_kill));
|
mc_chmod (dst_vpath, (src_mode & ctx->umask_kill));
|
||||||
}
|
}
|
||||||
mc_utime (dst_path, &utb);
|
mc_utime (dst_vpath, &utb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (return_status == FILE_CONT)
|
if (return_status == FILE_CONT)
|
||||||
return_status = progress_update_one (tctx, ctx, file_size);
|
return_status = progress_update_one (tctx, ctx, file_size);
|
||||||
|
|
||||||
|
ret_fast:
|
||||||
|
vfs_path_free (src_vpath);
|
||||||
|
vfs_path_free (dst_vpath);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1898,7 +1912,7 @@ 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;
|
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
|
||||||
|
|
||||||
d = g_strdup (_d);
|
d = g_strdup (_d);
|
||||||
|
|
||||||
@ -2024,6 +2038,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
goto dont_mkdir;
|
goto dont_mkdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dest_dir_vpath = vfs_path_from_str (dest_dir);
|
||||||
while (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU))
|
while (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU))
|
||||||
{
|
{
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
@ -2038,14 +2053,9 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
lp = g_new (struct link, 1);
|
lp = g_new0 (struct link, 1);
|
||||||
{
|
mc_stat (dest_dir_vpath, &buf);
|
||||||
vfs_path_t *tmp_vpath = vfs_path_from_str (dest_dir);
|
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class;
|
||||||
mc_stat (tmp_vpath, &buf);
|
|
||||||
|
|
||||||
lp->vfs = vfs_path_get_by_index (tmp_vpath, -1)->class;
|
|
||||||
vfs_path_free (tmp_vpath);
|
|
||||||
}
|
|
||||||
lp->ino = buf.st_ino;
|
lp->ino = buf.st_ino;
|
||||||
lp->dev = buf.st_dev;
|
lp->dev = buf.st_dev;
|
||||||
lp->next = dest_dirs;
|
lp->next = dest_dirs;
|
||||||
@ -2053,7 +2063,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
if (ctx->preserve_uidgid)
|
if (ctx->preserve_uidgid)
|
||||||
{
|
{
|
||||||
while (mc_chown (dest_dir, cbuf.st_uid, cbuf.st_gid) != 0)
|
while (mc_chown (dest_dir_vpath, cbuf.st_uid, cbuf.st_gid) != 0)
|
||||||
{
|
{
|
||||||
if (ctx->skip_all)
|
if (ctx->skip_all)
|
||||||
return_status = FILE_SKIPALL;
|
return_status = FILE_SKIPALL;
|
||||||
@ -2150,21 +2160,22 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
|||||||
|
|
||||||
if (ctx->preserve)
|
if (ctx->preserve)
|
||||||
{
|
{
|
||||||
mc_chmod (dest_dir, cbuf.st_mode & ctx->umask_kill);
|
mc_chmod (dest_dir_vpath, cbuf.st_mode & ctx->umask_kill);
|
||||||
utb.actime = cbuf.st_atime;
|
utb.actime = cbuf.st_atime;
|
||||||
utb.modtime = cbuf.st_mtime;
|
utb.modtime = cbuf.st_mtime;
|
||||||
mc_utime (dest_dir, &utb);
|
mc_utime (dest_dir_vpath, &utb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cbuf.st_mode = umask (-1);
|
cbuf.st_mode = umask (-1);
|
||||||
umask (cbuf.st_mode);
|
umask (cbuf.st_mode);
|
||||||
cbuf.st_mode = 0100777 & ~cbuf.st_mode;
|
cbuf.st_mode = 0100777 & ~cbuf.st_mode;
|
||||||
mc_chmod (dest_dir, cbuf.st_mode & ctx->umask_kill);
|
mc_chmod (dest_dir_vpath, cbuf.st_mode & ctx->umask_kill);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
g_free (dest_dir);
|
g_free (dest_dir);
|
||||||
|
vfs_path_free (dest_dir_vpath);
|
||||||
g_free (parent_dirs);
|
g_free (parent_dirs);
|
||||||
ret_fast:
|
ret_fast:
|
||||||
g_free (d);
|
g_free (d);
|
||||||
|
@ -72,32 +72,41 @@ my_mkdir_rec (char *s, mode_t mode)
|
|||||||
{
|
{
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int result;
|
int result;
|
||||||
|
vfs_path_t *s_vpath;
|
||||||
|
|
||||||
if (!mc_mkdir (s, mode))
|
s_vpath = vfs_path_from_str (s);
|
||||||
|
if (mc_mkdir (s_vpath, mode) == 0)
|
||||||
|
{
|
||||||
|
vfs_path_free (s_vpath);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
else if (errno != ENOENT)
|
else if (errno != ENOENT)
|
||||||
|
{
|
||||||
|
vfs_path_free (s_vpath);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: should check instead if s is at the root of that filesystem */
|
/* FIXME: should check instead if s is at the root of that filesystem */
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath = vfs_path_from_str (s);
|
if (!vfs_file_is_local (s_vpath))
|
||||||
if (!vfs_file_is_local (vpath))
|
|
||||||
{
|
{
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (s_vpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
vfs_path_free (vpath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp (s, PATH_SEP_STR))
|
if (!strcmp (s, PATH_SEP_STR))
|
||||||
{
|
{
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
|
vfs_path_free (s_vpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = concat_dir_and_file (s, "..");
|
p = concat_dir_and_file (s, "..");
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath = vfs_path_from_str (p);
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (p);
|
||||||
q = vfs_path_to_str (vpath);
|
q = vfs_path_to_str (vpath);
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
@ -105,8 +114,9 @@ my_mkdir_rec (char *s, mode_t mode)
|
|||||||
|
|
||||||
result = my_mkdir_rec (q, mode);
|
result = my_mkdir_rec (q, mode);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
result = mc_mkdir (s, mode);
|
result = mc_mkdir (s_vpath, mode);
|
||||||
|
|
||||||
|
vfs_path_free (s_vpath);
|
||||||
g_free (q);
|
g_free (q);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -120,17 +130,17 @@ my_mkdir (const char *s, mode_t mode)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char *my_s;
|
char *my_s;
|
||||||
|
vfs_path_t *s_vpath;
|
||||||
|
|
||||||
result = mc_mkdir (s, mode);
|
s_vpath = vfs_path_from_str (s);
|
||||||
if (result)
|
result = mc_mkdir (s_vpath, mode);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
|
||||||
char *p;
|
char *p;
|
||||||
vpath = vfs_path_from_str (s);
|
|
||||||
p = vfs_path_to_str (vpath);
|
|
||||||
|
|
||||||
|
p = vfs_path_to_str (s_vpath);
|
||||||
result = my_mkdir_rec (p, mode);
|
result = my_mkdir_rec (p, mode);
|
||||||
vfs_path_free (vpath);
|
|
||||||
g_free (p);
|
g_free (p);
|
||||||
}
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
@ -143,6 +153,7 @@ my_mkdir (const char *s, mode_t mode)
|
|||||||
|
|
||||||
g_free (my_s);
|
g_free (my_s);
|
||||||
}
|
}
|
||||||
|
vfs_path_free (s_vpath);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,12 +164,14 @@ my_rmdir (const char *s)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char *my_s;
|
char *my_s;
|
||||||
|
vfs_path_t *vpath;
|
||||||
#ifdef FIXME
|
#ifdef FIXME
|
||||||
WTree *tree = 0;
|
WTree *tree = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str (s);
|
||||||
/* FIXME: Should receive a Wtree! */
|
/* FIXME: Should receive a Wtree! */
|
||||||
result = mc_rmdir (s);
|
result = mc_rmdir (vpath);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
my_s = get_absolute_name (s);
|
my_s = get_absolute_name (s);
|
||||||
@ -169,6 +182,7 @@ my_rmdir (const char *s)
|
|||||||
|
|
||||||
g_free (my_s);
|
g_free (my_s);
|
||||||
}
|
}
|
||||||
|
vfs_path_free (vpath);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,12 +713,13 @@ put_link (WPanel * panel)
|
|||||||
if (S_ISLNK (selection (panel)->st.st_mode))
|
if (S_ISLNK (selection (panel)->st.st_mode))
|
||||||
{
|
{
|
||||||
char buffer[MC_MAXPATHLEN];
|
char buffer[MC_MAXPATHLEN];
|
||||||
char *p;
|
vfs_path_t *vpath;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
p = concat_dir_and_file (panel->cwd, selection (panel)->fname);
|
vpath = vfs_path_build_filename (panel->cwd, selection (panel)->fname, NULL);
|
||||||
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
|
i = mc_readlink (vpath, buffer, MC_MAXPATHLEN - 1);
|
||||||
g_free (p);
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
|
@ -901,12 +901,14 @@ display_mini_info (WPanel * panel)
|
|||||||
|
|
||||||
if (S_ISLNK (panel->dir.list[panel->selected].st.st_mode))
|
if (S_ISLNK (panel->dir.list[panel->selected].st.st_mode))
|
||||||
{
|
{
|
||||||
char *lc_link, link_target[MC_MAXPATHLEN];
|
char link_target[MC_MAXPATHLEN];
|
||||||
|
vfs_path_t *lc_link_vpath;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
lc_link = concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
|
lc_link_vpath =
|
||||||
len = mc_readlink (lc_link, link_target, MC_MAXPATHLEN - 1);
|
vfs_path_build_filename (panel->cwd, panel->dir.list[panel->selected].fname, NULL);
|
||||||
g_free (lc_link);
|
len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1);
|
||||||
|
vfs_path_free (lc_link_vpath);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
link_target[len] = 0;
|
link_target[len] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user