mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Refactoring of file and directory delete routines.
* (file_progress_show_deleting): take 'vfs_path_t *' instead of 'char *'. * (try_erase_dir): likewise. * (erase_file): sync with new file_progress_show_deleting(). * (recursive_erase): sync with new file_progress_show_deleting() and try_erase_dir(). * (erase_dir_iff_empty): likewise. * (erase_dir): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6cb97d18f1
commit
0780ef2970
@ -1386,7 +1386,7 @@ erase_file (file_op_total_context_t *tctx, file_op_context_t *ctx, const vfs_pat
|
|||||||
FileProgressStatus return_status;
|
FileProgressStatus return_status;
|
||||||
|
|
||||||
/* check buttons if deleting info was changed */
|
/* check buttons if deleting info was changed */
|
||||||
if (file_progress_show_deleting (ctx, vfs_path_as_str (vpath), &tctx->progress_count))
|
if (file_progress_show_deleting (ctx, vpath, &tctx->progress_count))
|
||||||
{
|
{
|
||||||
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
@ -1413,10 +1413,13 @@ erase_file (file_op_total_context_t *tctx, file_op_context_t *ctx, const vfs_pat
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static FileProgressStatus
|
static FileProgressStatus
|
||||||
try_erase_dir (file_op_context_t *ctx, const char *dir)
|
try_erase_dir (file_op_context_t *ctx, const vfs_path_t *vpath)
|
||||||
{
|
{
|
||||||
|
const char *dir;
|
||||||
FileProgressStatus return_status = FILE_CONT;
|
FileProgressStatus return_status = FILE_CONT;
|
||||||
|
|
||||||
|
dir = vfs_path_as_str (vpath);
|
||||||
|
|
||||||
while (my_rmdir (dir) != 0 && !ctx->skip_all)
|
while (my_rmdir (dir) != 0 && !ctx->skip_all)
|
||||||
{
|
{
|
||||||
return_status = file_error (TRUE, _("Cannot remove directory \"%s\"\n%s"), dir);
|
return_status = file_error (TRUE, _("Cannot remove directory \"%s\"\n%s"), dir);
|
||||||
@ -1442,7 +1445,6 @@ recursive_erase (file_op_total_context_t *tctx, file_op_context_t *ctx, const vf
|
|||||||
{
|
{
|
||||||
struct vfs_dirent *next;
|
struct vfs_dirent *next;
|
||||||
DIR *reading;
|
DIR *reading;
|
||||||
const char *s;
|
|
||||||
FileProgressStatus return_status = FILE_CONT;
|
FileProgressStatus return_status = FILE_CONT;
|
||||||
|
|
||||||
reading = mc_opendir (vpath);
|
reading = mc_opendir (vpath);
|
||||||
@ -1475,16 +1477,14 @@ recursive_erase (file_op_total_context_t *tctx, file_op_context_t *ctx, const vf
|
|||||||
if (return_status == FILE_ABORT)
|
if (return_status == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
s = vfs_path_as_str (vpath);
|
file_progress_show_deleting (ctx, vpath, NULL);
|
||||||
|
|
||||||
file_progress_show_deleting (ctx, s, NULL);
|
|
||||||
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
return try_erase_dir (ctx, s);
|
return try_erase_dir (ctx, vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -1528,11 +1528,7 @@ check_dir_is_empty (const vfs_path_t *vpath)
|
|||||||
static FileProgressStatus
|
static FileProgressStatus
|
||||||
erase_dir_iff_empty (file_op_context_t *ctx, const vfs_path_t *vpath, size_t count)
|
erase_dir_iff_empty (file_op_context_t *ctx, const vfs_path_t *vpath, size_t count)
|
||||||
{
|
{
|
||||||
const char *s;
|
file_progress_show_deleting (ctx, vpath, NULL);
|
||||||
|
|
||||||
s = vfs_path_as_str (vpath);
|
|
||||||
|
|
||||||
file_progress_show_deleting (ctx, s, NULL);
|
|
||||||
file_progress_show_count (ctx, count, ctx->progress_count);
|
file_progress_show_count (ctx, count, ctx->progress_count);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
@ -1543,10 +1539,9 @@ erase_dir_iff_empty (file_op_context_t *ctx, const vfs_path_t *vpath, size_t cou
|
|||||||
return FILE_CONT;
|
return FILE_CONT;
|
||||||
|
|
||||||
/* not empty or error */
|
/* not empty or error */
|
||||||
return try_erase_dir (ctx, s);
|
return try_erase_dir (ctx, vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3258,7 +3253,7 @@ move_dir_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const char
|
|||||||
FileProgressStatus
|
FileProgressStatus
|
||||||
erase_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const vfs_path_t *vpath)
|
erase_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const vfs_path_t *vpath)
|
||||||
{
|
{
|
||||||
file_progress_show_deleting (ctx, vfs_path_as_str (vpath), NULL);
|
file_progress_show_deleting (ctx, vpath, NULL);
|
||||||
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
|
||||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
@ -3282,7 +3277,7 @@ erase_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const vfs_path
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return try_erase_dir (ctx, vfs_path_as_str (vpath));
|
return try_erase_dir (ctx, vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -1176,7 +1176,7 @@ file_progress_show_target (file_op_context_t *ctx, const vfs_path_t *vpath)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
file_progress_show_deleting (file_op_context_t *ctx, const char *s, size_t *count)
|
file_progress_show_deleting (file_op_context_t *ctx, const vfs_path_t *vpath, size_t *count)
|
||||||
{
|
{
|
||||||
static gint64 timestamp = 0;
|
static gint64 timestamp = 0;
|
||||||
/* update with 25 FPS rate */
|
/* update with 25 FPS rate */
|
||||||
@ -1192,12 +1192,14 @@ file_progress_show_deleting (file_op_context_t *ctx, const char *s, size_t *coun
|
|||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
file_op_context_ui_t *ui;
|
file_op_context_ui_t *ui;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
ui = ctx->ui;
|
ui = ctx->ui;
|
||||||
|
|
||||||
if (ui->src_file_label != NULL)
|
if (ui->src_file_label != NULL)
|
||||||
label_set_text (ui->src_file_label, _("Deleting"));
|
label_set_text (ui->src_file_label, _("Deleting"));
|
||||||
|
|
||||||
|
s = vfs_path_as_str (vpath);
|
||||||
label_set_text (ui->src_file, truncFileStringSecure (ui->op_dlg, s));
|
label_set_text (ui->src_file, truncFileStringSecure (ui->op_dlg, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ void file_progress_show_total (file_op_total_context_t * tctx, file_op_context_t
|
|||||||
uintmax_t copied_bytes, gboolean show_summary);
|
uintmax_t copied_bytes, gboolean show_summary);
|
||||||
void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * vpath);
|
void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * vpath);
|
||||||
void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * vpath);
|
void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * vpath);
|
||||||
gboolean file_progress_show_deleting (file_op_context_t * ctx, const char *path, size_t *count);
|
gboolean file_progress_show_deleting (file_op_context_t * ctx, const vfs_path_t * vpath,
|
||||||
|
size_t *count);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
#endif /* MC__FILEGUI_H */
|
#endif /* MC__FILEGUI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user