mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
* file.c (copy_dir_dir): Code cleanup (removal of unnecessary goto,
redundant comment, indentation). * filegui.c (init_replace): Use off_t instead of int for file sizes. Use proper format string parameter for size.
This commit is contained in:
parent
65f99d5493
commit
b5a5f9f5f1
@ -1,3 +1,13 @@
|
|||||||
|
2004-12-02 Leonard den Ottolander <leonard * den ottolander nl>
|
||||||
|
|
||||||
|
* file.c (copy_dir_dir): Code cleanup (removal of unnecessary goto,
|
||||||
|
redundant comment, indentation).
|
||||||
|
|
||||||
|
2004-12-02 Jindrich Novy <jnovy@redhat.com>
|
||||||
|
|
||||||
|
* filegui.c (init_replace): Use off_t instead of int for file
|
||||||
|
sizes. Use proper format string parameter for size.
|
||||||
|
|
||||||
2004-11-30 Pavel Tsekov <ptsekov@gmx.net>
|
2004-11-30 Pavel Tsekov <ptsekov@gmx.net>
|
||||||
|
|
||||||
* widget.c (listbox_drawscroll): Fix declaration of `slow_terminal'.
|
* widget.c (listbox_drawscroll): Fix declaration of `slow_terminal'.
|
||||||
|
58
src/file.c
58
src/file.c
@ -824,8 +824,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
|||||||
function calls */
|
function calls */
|
||||||
int
|
int
|
||||||
copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||||
int move_over, int delete,
|
int move_over, int delete, struct link *parent_dirs,
|
||||||
struct link *parent_dirs,
|
|
||||||
off_t *progress_count, double *progress_bytes)
|
off_t *progress_count, double *progress_bytes)
|
||||||
{
|
{
|
||||||
struct dirent *next;
|
struct dirent *next;
|
||||||
@ -840,8 +839,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
retry_src_stat:
|
retry_src_stat:
|
||||||
if ((*ctx->stat_func) (s, &cbuf)) {
|
if ((*ctx->stat_func) (s, &cbuf)) {
|
||||||
return_status =
|
return_status =
|
||||||
file_error (_(" Cannot stat source directory \"%s\" \n %s "),
|
file_error (_(" Cannot stat source directory \"%s\" \n %s "), s);
|
||||||
s);
|
|
||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
goto retry_src_stat;
|
goto retry_src_stat;
|
||||||
return return_status;
|
return return_status;
|
||||||
@ -866,9 +864,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
|
|
||||||
if (!S_ISDIR (cbuf.st_mode)) {
|
if (!S_ISDIR (cbuf.st_mode)) {
|
||||||
return_status =
|
return_status =
|
||||||
file_error (_
|
file_error (_(" Source \"%s\" is not a directory \n %s "), s);
|
||||||
(" Source \"%s\" is not a directory \n %s "),
|
|
||||||
s);
|
|
||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
goto retry_src_stat;
|
goto retry_src_stat;
|
||||||
return return_status;
|
return return_status;
|
||||||
@ -910,42 +906,25 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
* or ( /bla doesn't exist ) /tmp/\* to /bla -> /bla/\*
|
* or ( /bla doesn't exist ) /tmp/\* to /bla -> /bla/\*
|
||||||
*/
|
*/
|
||||||
if (!S_ISDIR (buf.st_mode)) {
|
if (!S_ISDIR (buf.st_mode)) {
|
||||||
return_status =
|
return_status = file_error(
|
||||||
file_error (_
|
_(" Destination \"%s\" must be a directory \n %s "), d);
|
||||||
(" Destination \"%s\" must be a directory \n %s "),
|
|
||||||
d);
|
|
||||||
if (return_status == FILE_RETRY)
|
if (return_status == FILE_RETRY)
|
||||||
goto retry_dst_stat;
|
goto retry_dst_stat;
|
||||||
g_free (parent_dirs);
|
g_free (parent_dirs);
|
||||||
return return_status;
|
return return_status;
|
||||||
}
|
}
|
||||||
#if 1
|
/* Dive into subdir if exists */
|
||||||
/* Again, I'm getting curious. Is not d already what we wanted, incl.
|
|
||||||
* masked source basename? Is not this just a relict of the past versions?
|
|
||||||
* I'm afraid this will lead into a two level deep dive :(
|
|
||||||
*
|
|
||||||
* I think this is indeed the problem. I cannot remember any case where
|
|
||||||
* we actually would like that behavior -miguel
|
|
||||||
*
|
|
||||||
* It's a documented feature (option `Dive into subdir if exists' in the
|
|
||||||
* copy/move dialog). -Norbert
|
|
||||||
*/
|
|
||||||
if (toplevel && ctx->dive_into_subdirs) {
|
if (toplevel && ctx->dive_into_subdirs) {
|
||||||
dest_dir = concat_dir_and_file (d, x_basename (s));
|
dest_dir = concat_dir_and_file (d, x_basename (s));
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
dest_dir = g_strdup (d);
|
dest_dir = g_strdup (d);
|
||||||
goto dont_mkdir;
|
goto dont_mkdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retry_dst_mkdir:
|
while (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU)) {
|
||||||
if (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU)) {
|
return_status = file_error (
|
||||||
return_status =
|
_(" Cannot create target directory \"%s\" \n %s "), dest_dir);
|
||||||
file_error (_(" Cannot create target directory \"%s\" \n %s "),
|
if (return_status != FILE_RETRY)
|
||||||
dest_dir);
|
|
||||||
if (return_status == FILE_RETRY)
|
|
||||||
goto retry_dst_mkdir;
|
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,10 +938,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
|
|
||||||
if (ctx->preserve_uidgid) {
|
if (ctx->preserve_uidgid) {
|
||||||
while (mc_chown (dest_dir, cbuf.st_uid, cbuf.st_gid)) {
|
while (mc_chown (dest_dir, cbuf.st_uid, cbuf.st_gid)) {
|
||||||
return_status =
|
return_status = file_error (
|
||||||
file_error (_
|
_(" Cannot chown target directory \"%s\" \n %s "), dest_dir);
|
||||||
(" Cannot chown target directory \"%s\" \n %s "),
|
|
||||||
dest_dir);
|
|
||||||
if (return_status != FILE_RETRY)
|
if (return_status != FILE_RETRY)
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -995,15 +972,13 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
* dir already exists. So, we give the recursive call the flag 0
|
* dir already exists. So, we give the recursive call the flag 0
|
||||||
* meaning no toplevel.
|
* meaning no toplevel.
|
||||||
*/
|
*/
|
||||||
return_status = copy_dir_dir (ctx, path, mdpath, 0, 0,
|
return_status = copy_dir_dir (ctx, path, mdpath, 0, 0, delete,
|
||||||
delete, parent_dirs,
|
parent_dirs, progress_count, progress_bytes);
|
||||||
progress_count, progress_bytes);
|
|
||||||
g_free (mdpath);
|
g_free (mdpath);
|
||||||
} else {
|
} else {
|
||||||
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
|
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
|
||||||
return_status = copy_file_file (ctx, path, dest_file, 1,
|
return_status = copy_file_file (ctx, path, dest_file, 1,
|
||||||
progress_count, progress_bytes,
|
progress_count, progress_bytes, 0);
|
||||||
0);
|
|
||||||
g_free (dest_file);
|
g_free (dest_file);
|
||||||
}
|
}
|
||||||
if (delete && return_status == FILE_CONT) {
|
if (delete && return_status == FILE_CONT) {
|
||||||
@ -1025,7 +1000,6 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
|||||||
return_status = erase_file (ctx, path, 0, 0, 0);
|
return_status = erase_file (ctx, path, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
mc_closedir (reading);
|
mc_closedir (reading);
|
||||||
|
@ -525,8 +525,13 @@ static struct {
|
|||||||
N_("&No"), BY - 2, 37, REPLACE_NO}, {
|
N_("&No"), BY - 2, 37, REPLACE_NO}, {
|
||||||
N_("&Yes"), BY - 2, 28, REPLACE_YES}, {
|
N_("&Yes"), BY - 2, 28, REPLACE_YES}, {
|
||||||
N_("Overwrite this target?"), BY - 2, 4, 0}, {
|
N_("Overwrite this target?"), BY - 2, 4, 0}, {
|
||||||
N_("Target date: %s, size %d"), 6, 4, 0}, {
|
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
|
||||||
N_("Source date: %s, size %d"), 5, 4, 0}
|
N_("Target date: %s, size %llu"), 6, 4, 0}, {
|
||||||
|
N_("Source date: %s, size %llu"), 5, 4, 0}
|
||||||
|
#else
|
||||||
|
N_("Target date: %s, size %u"), 6, 4, 0}, {
|
||||||
|
N_("Source date: %s, size %u"), 5, 4, 0}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ADD_RD_BUTTON(i)\
|
#define ADD_RD_BUTTON(i)\
|
||||||
@ -635,9 +640,9 @@ init_replace (FileOpContext *ctx, enum OperationMode mode)
|
|||||||
ADD_RD_LABEL (ui, 11, 0, 0);
|
ADD_RD_LABEL (ui, 11, 0, 0);
|
||||||
|
|
||||||
ADD_RD_LABEL (ui, 12, file_date (ui->d_stat->st_mtime),
|
ADD_RD_LABEL (ui, 12, file_date (ui->d_stat->st_mtime),
|
||||||
(int) ui->d_stat->st_size);
|
(off_t) ui->d_stat->st_size);
|
||||||
ADD_RD_LABEL (ui, 13, file_date (ui->s_stat->st_mtime),
|
ADD_RD_LABEL (ui, 13, file_date (ui->s_stat->st_mtime),
|
||||||
(int) ui->s_stat->st_size);
|
(off_t) ui->s_stat->st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user