* 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:
Andrew V. Samoilov 2004-12-02 06:25:57 +00:00
parent 65f99d5493
commit b5a5f9f5f1
3 changed files with 36 additions and 47 deletions

View File

@ -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>
* widget.c (listbox_drawscroll): Fix declaration of `slow_terminal'.

View File

@ -824,8 +824,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
function calls */
int
copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
int move_over, int delete,
struct link *parent_dirs,
int move_over, int delete, struct link *parent_dirs,
off_t *progress_count, double *progress_bytes)
{
struct dirent *next;
@ -840,8 +839,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
retry_src_stat:
if ((*ctx->stat_func) (s, &cbuf)) {
return_status =
file_error (_(" Cannot stat source directory \"%s\" \n %s "),
s);
file_error (_(" Cannot stat source directory \"%s\" \n %s "), s);
if (return_status == FILE_RETRY)
goto retry_src_stat;
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)) {
return_status =
file_error (_
(" Source \"%s\" is not a directory \n %s "),
s);
file_error (_(" Source \"%s\" is not a directory \n %s "), s);
if (return_status == FILE_RETRY)
goto retry_src_stat;
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/\*
*/
if (!S_ISDIR (buf.st_mode)) {
return_status =
file_error (_
(" Destination \"%s\" must be a directory \n %s "),
d);
return_status = file_error(
_(" Destination \"%s\" must be a directory \n %s "), d);
if (return_status == FILE_RETRY)
goto retry_dst_stat;
g_free (parent_dirs);
return return_status;
}
#if 1
/* 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
*/
/* Dive into subdir if exists */
if (toplevel && ctx->dive_into_subdirs) {
dest_dir = concat_dir_and_file (d, x_basename (s));
} else
#endif
{
} else {
dest_dir = g_strdup (d);
goto dont_mkdir;
}
}
retry_dst_mkdir:
if (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU)) {
return_status =
file_error (_(" Cannot create target directory \"%s\" \n %s "),
dest_dir);
if (return_status == FILE_RETRY)
goto retry_dst_mkdir;
while (my_mkdir (dest_dir, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU)) {
return_status = file_error (
_(" Cannot create target directory \"%s\" \n %s "), dest_dir);
if (return_status != FILE_RETRY)
goto ret;
}
@ -959,10 +938,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
if (ctx->preserve_uidgid) {
while (mc_chown (dest_dir, cbuf.st_uid, cbuf.st_gid)) {
return_status =
file_error (_
(" Cannot chown target directory \"%s\" \n %s "),
dest_dir);
return_status = file_error (
_(" Cannot chown target directory \"%s\" \n %s "), dest_dir);
if (return_status != FILE_RETRY)
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
* meaning no toplevel.
*/
return_status = copy_dir_dir (ctx, path, mdpath, 0, 0,
delete, parent_dirs,
progress_count, progress_bytes);
return_status = copy_dir_dir (ctx, path, mdpath, 0, 0, delete,
parent_dirs, progress_count, progress_bytes);
g_free (mdpath);
} else {
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
return_status = copy_file_file (ctx, path, dest_file, 1,
progress_count, progress_bytes,
0);
progress_count, progress_bytes, 0);
g_free (dest_file);
}
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);
}
}
g_free (path);
}
mc_closedir (reading);

View File

@ -525,8 +525,13 @@ static struct {
N_("&No"), BY - 2, 37, REPLACE_NO}, {
N_("&Yes"), BY - 2, 28, REPLACE_YES}, {
N_("Overwrite this target?"), BY - 2, 4, 0}, {
N_("Target date: %s, size %d"), 6, 4, 0}, {
N_("Source date: %s, size %d"), 5, 4, 0}
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
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)\
@ -635,9 +640,9 @@ init_replace (FileOpContext *ctx, enum OperationMode mode)
ADD_RD_LABEL (ui, 11, 0, 0);
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),
(int) ui->s_stat->st_size);
(off_t) ui->s_stat->st_size);
}
void