Update file operation statistics for every processing file.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-12-18 11:09:25 +03:00
parent dad538e7dc
commit 09d77878c7
4 changed files with 14 additions and 21 deletions

View File

@ -461,17 +461,14 @@ make_symlink (FileOpContext * ctx, const char *src_path, const char *dst_path)
/* --------------------------------------------------------------------------------------------- */
static FileProgressStatus
progress_update_one (FileOpTotalContext * tctx, FileOpContext * ctx, off_t add,
gboolean is_toplevel_file)
progress_update_one (FileOpTotalContext * tctx, FileOpContext * ctx, off_t add)
{
struct timeval tv_current;
static struct timeval tv_start = { };
if (is_toplevel_file || ctx->progress_totals_computed)
{
tctx->progress_count++;
tctx->progress_bytes += (uintmax_t) add;
}
tctx->progress_count++;
tctx->progress_bytes += (uintmax_t) add;
if (tv_start.tv_sec == 0)
{
gettimeofday (&tv_start, (struct timezone *) NULL);
@ -833,7 +830,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
}
if (mc_rename (s, d) == 0)
return progress_update_one (tctx, ctx, src_stats.st_size, TRUE);
return progress_update_one (tctx, ctx, src_stats.st_size);
}
#if 0
/* Comparison to EXDEV seems not to work in nfs if you're moving from
@ -890,7 +887,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
}
if (!copy_done)
return_status = progress_update_one (tctx, ctx, src_stats.st_size, TRUE);
return_status = progress_update_one (tctx, ctx, src_stats.st_size);
return return_status;
}
@ -902,8 +899,7 @@ move_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, c
/** Don't update progress status if progress_count==NULL */
static FileProgressStatus
erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s,
gboolean is_toplevel_file)
erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
{
int return_status;
struct stat buf;
@ -933,7 +929,7 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s,
if (tctx->progress_count == 0)
return FILE_CONT;
return progress_update_one (tctx, ctx, buf.st_size, is_toplevel_file);
return progress_update_one (tctx, ctx, buf.st_size);
}
/* --------------------------------------------------------------------------------------------- */
@ -977,7 +973,7 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
if (S_ISDIR (buf.st_mode))
return_status = recursive_erase (tctx, ctx, path);
else
return_status = erase_file (tctx, ctx, path, 0);
return_status = erase_file (tctx, ctx, path);
g_free (path);
}
mc_closedir (reading);
@ -1793,7 +1789,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
}
if (return_status == FILE_CONT)
return_status = progress_update_one (tctx, ctx, file_size, tctx->is_toplevel_file);
return_status = progress_update_one (tctx, ctx, file_size);
return return_status;
}
@ -2056,7 +2052,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
return_status = erase_dir_iff_empty (ctx, path);
}
else
return_status = erase_file (tctx, ctx, path, FALSE);
return_status = erase_file (tctx, ctx, path);
}
}
g_free (path);
@ -2195,7 +2191,7 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
return_status = erase_dir_iff_empty (ctx, erase_list->name);
}
else
return_status = erase_file (tctx, ctx, erase_list->name, FALSE);
return_status = erase_file (tctx, ctx, erase_list->name);
lp = erase_list;
erase_list = erase_list->next;
g_free (lp);
@ -2692,7 +2688,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
if (S_ISDIR (src_stat.st_mode))
value = erase_dir (tctx, ctx, source_with_path);
else
value = erase_file (tctx, ctx, source_with_path, 1);
value = erase_file (tctx, ctx, source_with_path);
}
else
{
@ -2785,7 +2781,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
if (S_ISDIR (src_stat.st_mode))
value = erase_dir (tctx, ctx, source_with_path);
else
value = erase_file (tctx, ctx, source_with_path, 1);
value = erase_file (tctx, ctx, source_with_path);
}
else
{

View File

@ -114,7 +114,6 @@ file_op_total_context_new (void)
FileOpTotalContext *tctx;
tctx = g_new0 (FileOpTotalContext, 1);
tctx->ask_overwrite = TRUE;
tctx->is_toplevel_file = TRUE;
return tctx;
}

View File

@ -174,7 +174,6 @@ typedef struct
double eta_secs;
gboolean ask_overwrite;
gboolean is_toplevel_file;
} FileOpTotalContext;
/*** global variables defined in .c file *********************************************************/

View File

@ -759,7 +759,6 @@ tree_copy (WTree * tree, const char *default_dest)
tctx = file_op_total_context_new ();
file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_MULTI_ITEM);
tctx->ask_overwrite = FALSE;
tctx->is_toplevel_file = FALSE;
copy_dir_dir (tctx, ctx, tree->selected_ptr->name, dest, TRUE, FALSE, FALSE, NULL);
file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx);