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:
Slava Zanko 2011-07-21 00:22:50 +03:00
parent cb2ad816f6
commit a78f87d30d
12 changed files with 169 additions and 111 deletions

View File

@ -150,7 +150,7 @@ resolve_symlinks (const char *path)
strcpy (r, p + 1);
else
{
len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1);
len = mc_readlink (vpath, buf2, MC_MAXPATHLEN - 1);
if (len < 0)
{
g_free (buf);
@ -1521,7 +1521,13 @@ mc_util_unlink_backup_if_possible (const char *file_name, const char *backup_suf
return FALSE;
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);
return TRUE;

View File

@ -225,35 +225,31 @@ mc_open (const char *filename, int flags, ...)
int mc_##name inarg \
{ \
int result; \
vfs_path_t *vpath; \
vfs_path_element_t *path_element; \
\
vpath = vfs_path_from_str (path); \
if (vpath == NULL) \
return -1; \
\
path_element = vfs_path_get_by_index (vpath, -1); \
if (!vfs_path_element_valid (path_element)) \
{ \
vfs_path_free(vpath); \
return -1; \
} \
\
result = path_element->class->name != NULL ? path_element->class->name callarg : -1; \
if (result == -1) \
errno = path_element->class->name != NULL ? vfs_ferrno (path_element->class) : E_NOTSUPP; \
vfs_path_free(vpath); \
return result; \
}
MC_NAMEOP (chmod, (const char *path, mode_t mode), (vpath, mode))
MC_NAMEOP (chown, (const char *path, uid_t owner, gid_t group), (vpath, owner, group))
MC_NAMEOP (utime, (const char *path, struct utimbuf * times), (vpath, times))
MC_NAMEOP (readlink, (const char *path, char *buf, size_t bufsiz), (vpath, buf, bufsiz))
MC_NAMEOP (unlink, (const char *path), (vpath))
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (vpath, mode))
MC_NAMEOP (rmdir, (const char *path), (vpath))
MC_NAMEOP (mknod, (const char *path, mode_t mode, dev_t dev), (vpath, mode, dev))
MC_NAMEOP (chmod, (const vfs_path_t *vpath, mode_t mode), (vpath, mode))
MC_NAMEOP (chown, (const vfs_path_t *vpath, uid_t owner, gid_t group), (vpath, owner, group))
MC_NAMEOP (utime, (const vfs_path_t *vpath, struct utimbuf * times), (vpath, times))
MC_NAMEOP (readlink, (const vfs_path_t *vpath, char *buf, size_t bufsiz), (vpath, buf, bufsiz))
MC_NAMEOP (unlink, (const vfs_path_t *vpath), (vpath))
MC_NAMEOP (mkdir, (const vfs_path_t *vpath, mode_t mode), (vpath, mode))
MC_NAMEOP (rmdir, (const vfs_path_t *vpath), (vpath))
MC_NAMEOP (mknod, (const vfs_path_t *vpath, mode_t mode, dev_t dev), (vpath, mode, dev))
/* *INDENT-ON* */

View File

@ -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_write (int handle, const void *buffer, size_t count);
int mc_utime (const char *path, struct utimbuf *times);
int mc_readlink (const char *path, char *buf, size_t bufsiz);
int mc_utime (const vfs_path_t * vpath, struct utimbuf *times);
int mc_readlink (const vfs_path_t * vpath, char *buf, size_t bufsiz);
int mc_close (int handle);
off_t mc_lseek (int fd, off_t offset, int whence);
DIR *mc_opendir (const vfs_path_t * vpath);
struct dirent *mc_readdir (DIR * dirp);
int mc_closedir (DIR * dir);
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_mkdir (const char *path, mode_t mode);
int mc_rmdir (const char *path);
int mc_mkdir (const vfs_path_t * vpath, mode_t mode);
int mc_rmdir (const vfs_path_t * vpath);
int mc_fstat (int fd, struct stat *buf);
int mc_lstat (const vfs_path_t * vpath, struct stat *buf);
int mc_symlink (const char *name1, const char *name2);
int mc_rename (const char *original, const char *target);
int mc_chmod (const char *path, mode_t mode);
int mc_chown (const char *path, uid_t owner, gid_t group);
int mc_chmod (const vfs_path_t * vpath, mode_t mode);
int mc_chown (const vfs_path_t * vpath, uid_t owner, gid_t group);
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_setctl (const vfs_path_t * vpath, int ctlop, void *arg);
int mc_open (const char *filename, int flags, ...);

View File

@ -235,10 +235,15 @@ edit_save_file (WEdit * edit, const char *filename)
}
else
savename = g_strdup (real_filename);
{
int ret;
ret = mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
ret = mc_chmod (savename, edit->stat1.st_mode);
vfs_path_t *savename_vpath;
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);

View File

@ -725,26 +725,27 @@ next_file (void)
static void
apply_advanced_chowns (struct stat *sf)
{
vfs_path_t *vpath;
char *lc_fname;
gid_t a_gid = sf->st_gid;
uid_t a_uid = sf->st_uid;
lc_fname = current_panel->dir.list[current_file].fname;
vpath = vfs_path_from_str (lc_fname);
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"),
lc_fname, unix_error_string (errno));
/* 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)
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
do_file_mark (current_panel, current_file, 0);
vfs_path_free (vpath);
do
{
vfs_path_t *vpath;
lc_fname = next_file ();
vpath = vfs_path_from_str (lc_fname);
@ -754,11 +755,11 @@ apply_advanced_chowns (struct stat *sf)
break;
}
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"),
lc_fname, unix_error_string (errno));
/* 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)
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
@ -776,7 +777,6 @@ apply_advanced_chowns (struct stat *sf)
void
chown_advanced_cmd (void)
{
files_on_begin = current_panel->marked;
do
@ -812,15 +812,22 @@ chown_advanced_cmd (void)
break;
case B_ENTER:
{
vfs_path_t *fname_vpath;
fname_vpath = vfs_path_from_str (fname);
need_update = 1;
if (mc_chmod (fname, get_mode ()) == -1)
if (mc_chmod (fname_vpath, get_mode ()) == -1)
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
fname, unix_error_string (errno));
/* call mc_chown only, if mc_chmod didn't fail */
else if (mc_chown (fname, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) - 1,
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));
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname,
unix_error_string (errno));
vfs_path_free (fname_vpath);
}
break;
case B_SETALL:
apply_advanced_chowns (sf_stat);

View File

@ -366,13 +366,16 @@ next_file (void)
static void
do_chmod (struct stat *sf)
{
vfs_path_t *vpath;
sf->st_mode &= and_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"),
current_panel->dir.list[c_file].fname, unix_error_string (errno));
vfs_path_free (vpath);
do_file_mark (current_panel, c_file, 0);
}
@ -443,7 +446,6 @@ chmod_cmd (void)
vfs_path_free (vpath);
break;
}
vfs_path_free (vpath);
c_stat = sf_stat.st_mode;
@ -455,7 +457,7 @@ chmod_cmd (void)
switch (result)
{
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"),
fname, unix_error_string (errno));
need_update = TRUE;
@ -511,6 +513,8 @@ chmod_cmd (void)
need_update = TRUE;
}
vfs_path_free (vpath);
destroy_dlg (ch_dlg);
}
while (current_panel->marked != 0 && !end_chmod);

View File

@ -242,10 +242,14 @@ chown_done (void)
static void
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"),
current_panel->dir.list[current_file].fname, unix_error_string (errno));
vfs_path_free (vpath);
do_file_mark (current_panel, current_file, 0);
}
@ -285,6 +289,7 @@ chown_cmd (void)
do
{ /* do while any files remaining */
vfs_path_t *vpath;
ch_dlg = init_chown ();
new_user = new_group = -1;
@ -366,10 +371,14 @@ chown_cmd (void)
new_user = user->pw_uid;
if (ch_dlg->ret_value == B_ENTER)
{
vfs_path_t *fname_vpath;
fname_vpath = vfs_path_from_str (fname);
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"),
fname, unix_error_string (errno));
vfs_path_free (vpath);
}
else
apply_chowns (new_user, new_group);

View File

@ -1324,8 +1324,10 @@ edit_symlink_cmd (void)
char *p = NULL;
int i;
char *dest, *q;
vfs_path_t *p_vpath;
p = selection (current_panel)->fname;
p_vpath = vfs_path_from_str (p);
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))
{
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"),
p, unix_error_string (errno));
@ -1357,6 +1359,7 @@ edit_symlink_cmd (void)
}
}
g_free (q);
vfs_path_free (p_vpath);
}
else
{

View File

@ -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);
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 (ctx->skip_all)
@ -451,7 +451,7 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
*/
if (dst_is_symlink)
{
if (!mc_unlink (dst_path))
if (mc_unlink (dst_vpath) == 0)
if (mc_symlink (link_target, dst_path) == 0)
{
/* Success */
@ -926,7 +926,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
mc_refresh ();
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);
if (return_status == FILE_RETRY)
@ -972,7 +972,7 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
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);
if (return_status == FILE_ABORT)
@ -1417,7 +1417,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
dest_status_t dst_status = DEST_NONE;
int open_flags;
gboolean is_first_time = TRUE;
vfs_path_t *src_vpath, *dst_vpath;
vfs_path_t *src_vpath = NULL, *dst_vpath = NULL;
/* FIXME: We should not be using global variables! */
ctx->do_reget = 0;
@ -1445,12 +1445,11 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
if (return_status == FILE_RETRY)
continue;
}
return return_status;
goto ret_fast;
}
dst_exists = TRUE;
break;
}
vfs_path_free (dst_vpath);
src_vpath = vfs_path_from_str (src_path);
while ((*ctx->stat_func) (src_vpath, &sb) != 0)
@ -1464,25 +1463,25 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
ctx->skip_all = TRUE;
}
if (return_status != FILE_RETRY)
{
vfs_path_free (src_vpath);
return return_status;
goto ret_fast;
}
}
vfs_path_free (src_vpath);
if (dst_exists)
{
/* Destination already exists */
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? */
if (tctx->ask_overwrite)
{
ctx->do_reget = 0;
return_status = query_replace (ctx, dst_path, &sb, &sb2);
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))
{
/* 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))
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) ||
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)
{
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;
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
return return_status;
goto ret_fast;
}
/* 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)
{
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)
ctx->skip_all = TRUE;
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)
{
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)
ctx->skip_all = TRUE;
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)
break;
ctx->do_append = 0;
return return_status;
goto ret_fast;
}
if (ctx->do_reget != 0)
@ -1659,7 +1669,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
}
mc_close (dest_desc);
dest_desc = -1;
mc_unlink (dst_path);
mc_unlink (dst_vpath);
dst_status = DEST_NONE;
goto ret;
}
@ -1815,18 +1825,19 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
{
/* Remove short file */
int result;
result = query_dialog (Q_ ("DialogTitle|Copy"),
_("Incomplete file was retrieved. Keep it?"),
D_ERROR, 2, _("&Delete"), _("&Keep"));
if (result == 0)
mc_unlink (dst_path);
mc_unlink (dst_vpath);
}
else if (dst_status == DEST_FULL)
{
/* Copy has succeeded */
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);
if (temp_status == FILE_RETRY)
@ -1846,7 +1857,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
{
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);
if (temp_status == FILE_RETRY)
@ -1866,15 +1877,18 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
src_mode = umask (-1);
umask (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)
return_status = progress_update_one (tctx, ctx, file_size);
ret_fast:
vfs_path_free (src_vpath);
vfs_path_free (dst_vpath);
return return_status;
}
@ -1898,7 +1912,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
struct utimbuf utb;
struct link *lp;
char *d;
vfs_path_t *src_vpath, *dst_vpath;
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
d = g_strdup (_d);
@ -2024,6 +2038,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
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))
{
if (ctx->skip_all)
@ -2038,14 +2053,9 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
goto ret;
}
lp = g_new (struct link, 1);
{
vfs_path_t *tmp_vpath = vfs_path_from_str (dest_dir);
mc_stat (tmp_vpath, &buf);
lp->vfs = vfs_path_get_by_index (tmp_vpath, -1)->class;
vfs_path_free (tmp_vpath);
}
lp = g_new0 (struct link, 1);
mc_stat (dest_dir_vpath, &buf);
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class;
lp->ino = buf.st_ino;
lp->dev = buf.st_dev;
lp->next = dest_dirs;
@ -2053,7 +2063,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
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)
return_status = FILE_SKIPALL;
@ -2150,21 +2160,22 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
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.modtime = cbuf.st_mtime;
mc_utime (dest_dir, &utb);
mc_utime (dest_dir_vpath, &utb);
}
else
{
cbuf.st_mode = umask (-1);
umask (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:
g_free (dest_dir);
vfs_path_free (dest_dir_vpath);
g_free (parent_dirs);
ret_fast:
g_free (d);

View File

@ -72,32 +72,41 @@ my_mkdir_rec (char *s, mode_t mode)
{
char *p, *q;
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;
}
else if (errno != ENOENT)
{
vfs_path_free (s_vpath);
return -1;
}
/* 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 (vpath))
if (!vfs_file_is_local (s_vpath))
{
vfs_path_free (vpath);
vfs_path_free (s_vpath);
return -1;
}
vfs_path_free (vpath);
}
if (!strcmp (s, PATH_SEP_STR))
{
errno = ENOTDIR;
vfs_path_free (s_vpath);
return -1;
}
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);
vfs_path_free (vpath);
}
@ -105,8 +114,9 @@ my_mkdir_rec (char *s, mode_t mode)
result = my_mkdir_rec (q, mode);
if (result == 0)
result = mc_mkdir (s, mode);
result = mc_mkdir (s_vpath, mode);
vfs_path_free (s_vpath);
g_free (q);
return result;
}
@ -120,17 +130,17 @@ my_mkdir (const char *s, mode_t mode)
{
int result;
char *my_s;
vfs_path_t *s_vpath;
result = mc_mkdir (s, mode);
if (result)
s_vpath = vfs_path_from_str (s);
result = mc_mkdir (s_vpath, mode);
if (result != 0)
{
vfs_path_t *vpath;
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);
vfs_path_free (vpath);
g_free (p);
}
if (result == 0)
@ -143,6 +153,7 @@ my_mkdir (const char *s, mode_t mode)
g_free (my_s);
}
vfs_path_free (s_vpath);
return result;
}
@ -153,12 +164,14 @@ my_rmdir (const char *s)
{
int result;
char *my_s;
vfs_path_t *vpath;
#ifdef FIXME
WTree *tree = 0;
#endif
vpath = vfs_path_from_str (s);
/* FIXME: Should receive a Wtree! */
result = mc_rmdir (s);
result = mc_rmdir (vpath);
if (result == 0)
{
my_s = get_absolute_name (s);
@ -169,6 +182,7 @@ my_rmdir (const char *s)
g_free (my_s);
}
vfs_path_free (vpath);
return result;
}

View File

@ -713,12 +713,13 @@ put_link (WPanel * panel)
if (S_ISLNK (selection (panel)->st.st_mode))
{
char buffer[MC_MAXPATHLEN];
char *p;
vfs_path_t *vpath;
int i;
p = concat_dir_and_file (panel->cwd, selection (panel)->fname);
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
g_free (p);
vpath = vfs_path_build_filename (panel->cwd, selection (panel)->fname, NULL);
i = mc_readlink (vpath, buffer, MC_MAXPATHLEN - 1);
vfs_path_free (vpath);
if (i > 0)
{
buffer[i] = '\0';

View File

@ -901,12 +901,14 @@ display_mini_info (WPanel * panel)
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;
lc_link = concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
len = mc_readlink (lc_link, link_target, MC_MAXPATHLEN - 1);
g_free (lc_link);
lc_link_vpath =
vfs_path_build_filename (panel->cwd, panel->dir.list[panel->selected].fname, NULL);
len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1);
vfs_path_free (lc_link_vpath);
if (len > 0)
{
link_target[len] = 0;