1 /* File operation contexts for the Midnight Commander
3 * Copyright (C) 1998 Free Software Foundation, Inc.
5 * Authors: Federico Mena <federico@nuclecu.unam.mx>
6 * Miguel de Icaza <miguel@nuclecu.unam.mx>
13 #include <sys/types.h>
22 typedef int (*mc_stat_fn
) (const char *filename
, struct stat
*buf
);
24 /* This structure describes a context for file operations. It is used to update
25 * the progress windows and pass around options.
27 typedef struct FileOpContext
{
28 /* Operation type (copy, move, delete) */
29 FileOperation operation
;
31 /* The estimated time of arrival in seconds */
34 /* Transferred bytes per second */
37 /* Transferred seconds */
40 /* Whether the panel total has been computed */
41 int progress_totals_computed
;
43 /* Counters for progress indicators */
45 double progress_bytes
;
47 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
48 * We can't use the value of "ctx->preserve" because it can change in order
49 * to preserve file attributs when moving files across filesystem boundaries
50 * (we want to keep the value of the checkbox between copy operations).
54 /* Result from the recursive query */
57 /* Whether to do a reget */
60 /* Controls appending to files */
63 /* Whether to stat or lstat */
66 /* Pointer to the stat function we will use */
69 /* Whether to recompute symlinks */
72 /* Preserve the original files' owner, group, permissions, and
73 * timestamps (owner, group only as root).
77 /* If running as root, preserve the original uid/gid (we don't want to
78 * try chown for non root) preserve_uidgid = preserve && uid == 0
82 /* The bits to preserve in created files' modes on file copy */
85 /* The mask of files to actually operate on */
88 /* Regex for the file mask */
89 struct re_pattern_buffer rx
;
90 struct re_registers regs
;
92 /* Whether to dive into subdirectories for recursive operations */
93 int dive_into_subdirs
;
95 /* When moving directories cross filesystem boundaries delete the
96 * successfully copied files when all files below the directory and its
97 * subdirectories were processed.
99 * If erase_at_end is zero files will be deleted immediately after their
100 * successful copy (Note: this behavior is not tested and at the moment
101 * it can't be changed at runtime).
105 /* PID of the child for background operations */
108 /* User interface data goes here */
114 FileOpContext
*file_op_context_new (FileOperation op
);
115 void file_op_context_destroy (FileOpContext
*ctx
);
118 extern const char *op_names
[3];
125 } FileProgressStatus
;
135 /* First argument passed to real functions */
141 /* The following functions are implemented separately by each port */
143 void file_op_context_create_ui (FileOpContext
*ctx
, int with_eta
);
144 void file_op_context_destroy_ui (FileOpContext
*ctx
);
146 FileProgressStatus
file_progress_show (FileOpContext
*ctx
, off_t done
, off_t total
);
147 FileProgressStatus
file_progress_show_count (FileOpContext
*ctx
, off_t done
, off_t total
);
148 FileProgressStatus
file_progress_show_bytes (FileOpContext
*ctx
, double done
, double total
);
149 FileProgressStatus
file_progress_show_source (FileOpContext
*ctx
, const char *path
);
150 FileProgressStatus
file_progress_show_target (FileOpContext
*ctx
, const char *path
);
151 FileProgressStatus
file_progress_show_deleting (FileOpContext
*ctx
, const char *path
);
153 void file_progress_set_stalled_label (FileOpContext
*ctx
, const char *stalled_msg
);
155 FileProgressStatus
file_progress_real_query_replace (FileOpContext
*ctx
,
156 enum OperationMode mode
,
157 const char *destname
,
158 struct stat
*_s_stat
,
159 struct stat
*_d_stat
);