(copy_dir_dir): refactoring: get rid of goto dont_mkdir.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-11-25 13:49:20 +04:00
parent 82cfece6ae
commit ba6b7ce976

View File

@ -1945,6 +1945,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
struct link *lp; struct link *lp;
char *d; char *d;
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL; vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
gboolean do_mkdir = TRUE;
d = g_strdup (_d); d = g_strdup (_d);
@ -2059,40 +2060,42 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
} }
/* Dive into subdir if exists */ /* Dive into subdir if exists */
if (toplevel && ctx->dive_into_subdirs) if (toplevel && ctx->dive_into_subdirs)
{
dest_dir = mc_build_filename (d, x_basename (s), NULL); dest_dir = mc_build_filename (d, x_basename (s), NULL);
}
else else
{ {
dest_dir = d; dest_dir = d;
d = NULL; d = NULL;
dest_dir_vpath = vfs_path_from_str (dest_dir); do_mkdir = FALSE;
goto dont_mkdir;
} }
} }
dest_dir_vpath = vfs_path_from_str (dest_dir); dest_dir_vpath = vfs_path_from_str (dest_dir);
while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
if (do_mkdir)
{ {
if (ctx->skip_all) while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
return_status = FILE_SKIPALL;
else
{ {
return_status = file_error (_("Cannot create target directory \"%s\"\n%s"), dest_dir); if (ctx->skip_all)
if (return_status == FILE_SKIPALL) return_status = FILE_SKIPALL;
ctx->skip_all = TRUE; else
{
return_status =
file_error (_("Cannot create target directory \"%s\"\n%s"), dest_dir);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
if (return_status != FILE_RETRY)
goto ret;
} }
if (return_status != FILE_RETRY)
goto ret; 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;
dest_dirs = g_slist_prepend (dest_dirs, lp);
} }
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;
dest_dirs = g_slist_prepend (dest_dirs, lp);
dont_mkdir:
if (ctx->preserve_uidgid) if (ctx->preserve_uidgid)
{ {
while (mc_chown (dest_dir_vpath, cbuf.st_uid, cbuf.st_gid) != 0) while (mc_chown (dest_dir_vpath, cbuf.st_uid, cbuf.st_gid) != 0)