mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
(operate_single_file): refactoring, add extra variables.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
07bbfb73e3
commit
816b503e3a
@ -1665,6 +1665,7 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
|
|||||||
{
|
{
|
||||||
FileProgressStatus value;
|
FileProgressStatus value;
|
||||||
vfs_path_t *src_vpath;
|
vfs_path_t *src_vpath;
|
||||||
|
gboolean is_file;
|
||||||
|
|
||||||
if (g_path_is_absolute (src))
|
if (g_path_is_absolute (src))
|
||||||
src_vpath = vfs_path_from_str (src);
|
src_vpath = vfs_path_from_str (src);
|
||||||
@ -1675,12 +1676,14 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
|
|||||||
if (value != FILE_CONT)
|
if (value != FILE_CONT)
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
|
is_file = !S_ISDIR (src_stat->st_mode);
|
||||||
|
|
||||||
if (operation == OP_DELETE)
|
if (operation == OP_DELETE)
|
||||||
{
|
{
|
||||||
if (S_ISDIR (src_stat->st_mode))
|
if (is_file)
|
||||||
value = erase_dir (tctx, ctx, src_vpath);
|
|
||||||
else
|
|
||||||
value = erase_file (tctx, ctx, src_vpath);
|
value = erase_file (tctx, ctx, src_vpath);
|
||||||
|
else
|
||||||
|
value = erase_dir (tctx, ctx, src_vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1708,6 +1711,7 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
|
|||||||
g_free (temp);
|
g_free (temp);
|
||||||
g_free (repl_dest);
|
g_free (repl_dest);
|
||||||
|
|
||||||
|
src = vfs_path_as_str (src_vpath);
|
||||||
dest = temp2;
|
dest = temp2;
|
||||||
|
|
||||||
switch (operation)
|
switch (operation)
|
||||||
@ -1715,20 +1719,19 @@ operate_single_file (const WPanel * panel, FileOperation operation, file_op_tota
|
|||||||
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 (src_vpath, src_stat);
|
ctx->stat_func (src_vpath, src_stat);
|
||||||
|
is_file = !S_ISDIR (src_stat->st_mode);
|
||||||
|
|
||||||
if (S_ISDIR (src_stat->st_mode))
|
if (is_file)
|
||||||
value =
|
value = copy_file_file (tctx, ctx, src, dest);
|
||||||
copy_dir_dir (tctx, ctx, vfs_path_as_str (src_vpath), dest, TRUE, FALSE,
|
|
||||||
FALSE, NULL);
|
|
||||||
else
|
else
|
||||||
value = copy_file_file (tctx, ctx, vfs_path_as_str (src_vpath), dest);
|
value = copy_dir_dir (tctx, ctx, src, dest, TRUE, FALSE, FALSE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_MOVE:
|
case OP_MOVE:
|
||||||
if (S_ISDIR (src_stat->st_mode))
|
if (is_file)
|
||||||
value = move_dir_dir (tctx, ctx, vfs_path_as_str (src_vpath), dest);
|
value = move_file_file (tctx, ctx, src, dest);
|
||||||
else
|
else
|
||||||
value = move_file_file (tctx, ctx, vfs_path_as_str (src_vpath), dest);
|
value = move_dir_dir (tctx, ctx, src, dest);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user