mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
src/file.c: move_dir_dir():
* changed type of move_over variable from int to gboolean; * fixed memory leak: destdir is not free'd when the same directory is copied; * don't use the non-valid dbuf variable if mc_stat(d, &dbuf) returns non-zero.
This commit is contained in:
parent
5d50f64a2b
commit
bf8ac0594e
15
src/file.c
15
src/file.c
@ -1148,7 +1148,8 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
struct link *lp;
|
struct link *lp;
|
||||||
char *destdir;
|
char *destdir;
|
||||||
FileProgressStatus return_status;
|
FileProgressStatus return_status;
|
||||||
int move_over = 0;
|
gboolean move_over = FALSE;
|
||||||
|
gboolean dstat_ok;
|
||||||
|
|
||||||
if (file_progress_show_source (ctx, s) == FILE_ABORT ||
|
if (file_progress_show_source (ctx, s) == FILE_ABORT ||
|
||||||
file_progress_show_target (ctx, d) == FILE_ABORT)
|
file_progress_show_target (ctx, d) == FILE_ABORT)
|
||||||
@ -1157,17 +1158,19 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
mc_stat (s, &sbuf);
|
mc_stat (s, &sbuf);
|
||||||
if (mc_stat (d, &dbuf))
|
dstat_ok = (mc_stat (d, &dbuf) == 0);
|
||||||
|
|
||||||
|
if (dstat_ok && sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino)
|
||||||
|
return warn_same_file (_(" `%s' \n and \n `%s' \n are the same directory "), s, d);
|
||||||
|
|
||||||
|
if (!dstat_ok)
|
||||||
destdir = g_strdup (d); /* destination doesn't exist */
|
destdir = g_strdup (d); /* destination doesn't exist */
|
||||||
else if (!ctx->dive_into_subdirs) {
|
else if (!ctx->dive_into_subdirs) {
|
||||||
destdir = g_strdup (d);
|
destdir = g_strdup (d);
|
||||||
move_over = 1;
|
move_over = TRUE;
|
||||||
} else
|
} else
|
||||||
destdir = concat_dir_and_file (d, x_basename (s));
|
destdir = concat_dir_and_file (d, x_basename (s));
|
||||||
|
|
||||||
if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino)
|
|
||||||
return warn_same_file (_(" `%s' \n and \n `%s' \n are the same directory "), s, d);
|
|
||||||
|
|
||||||
/* Check if the user inputted an existing dir */
|
/* Check if the user inputted an existing dir */
|
||||||
retry_dst_stat:
|
retry_dst_stat:
|
||||||
if (!mc_stat (destdir, &destbuf)) {
|
if (!mc_stat (destdir, &destbuf)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user