(panel_callback) [MSG_FOCUS]: remove self-draw here.
[midnight-commander.git] / src / filemanager / fileopctx.h
blobddb333b2442450e1d27d4128fec774b81cfc71d7
1 /** \file fileopctx.h
2 * \brief Header: file operation contexts
3 * \date 1998
4 * \author Federico Mena <federico@nuclecu.unam.mx>
5 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
6 */
8 #ifndef MC__FILEOPCTX_H
9 #define MC__FILEOPCTX_H
11 #include <sys/stat.h>
12 #include <sys/types.h>
13 #include <inttypes.h> /* uintmax_t */
15 #include "lib/global.h"
16 #include "lib/vfs/vfs.h"
19 /*** typedefs(not structures) and defined constants **********************************************/
21 typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
23 /*** enums ***************************************************************************************/
25 typedef enum
27 FILEGUI_DIALOG_ONE_ITEM,
28 FILEGUI_DIALOG_MULTI_ITEM,
29 FILEGUI_DIALOG_DELETE_ITEM
30 } filegui_dialog_type_t;
32 typedef enum
34 OP_COPY = 0,
35 OP_MOVE = 1,
36 OP_DELETE = 2
37 } FileOperation;
39 typedef enum
41 RECURSIVE_YES = 0,
42 RECURSIVE_NO = 1,
43 RECURSIVE_ALWAYS = 2,
44 RECURSIVE_NEVER = 3,
45 RECURSIVE_ABORT = 4
46 } FileCopyMode;
48 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
49 typedef enum
51 FILE_CONT = 10,
52 FILE_RETRY,
53 FILE_SKIP,
54 FILE_ABORT,
55 FILE_IGNORE,
56 FILE_IGNORE_ALL,
57 FILE_SUSPEND
58 } FileProgressStatus;
60 /* First argument passed to real functions */
61 enum OperationMode
63 Foreground,
64 Background
67 /*** structures declarations (and typedefs of structures)*****************************************/
69 struct mc_search_struct;
71 /* This structure describes a context for file operations. It is used to update
72 * the progress windows and pass around options.
74 typedef struct
76 /* Operation type (copy, move, delete) */
77 FileOperation operation;
79 /* The estimated time of arrival in seconds */
80 double eta_secs;
82 /* Transferred bytes per second */
83 long bps;
85 /* Transferred seconds */
86 long bps_time;
88 /* Whether the panel total has been computed */
89 gboolean progress_totals_computed;
90 filegui_dialog_type_t dialog_type;
92 /* Counters for progress indicators */
93 size_t progress_count;
94 uintmax_t progress_bytes;
96 /* Result from the recursive query */
97 FileCopyMode recursive_result;
99 /* Whether to do a reget */
100 off_t do_reget;
102 /* Controls appending to files */
103 gboolean do_append;
105 /* Whether to stat or lstat */
106 gboolean follow_links;
108 /* Pointer to the stat function we will use */
109 mc_stat_fn stat_func;
111 /* Whether to recompute symlinks */
112 gboolean stable_symlinks;
114 /* Preserve the original files' owner, group, permissions, and
115 * timestamps (owner, group only as root).
117 gboolean preserve;
119 /* If running as root, preserve the original uid/gid (we don't want to
120 * try chown for non root) preserve_uidgid = preserve && uid == 0
122 gboolean preserve_uidgid;
124 /* The bits to preserve in created files' modes on file copy */
125 mode_t umask_kill;
127 /* The mask of files to actually operate on */
128 char *dest_mask;
130 /* search handler */
131 struct mc_search_struct *search_handle;
133 /* Whether to dive into subdirectories for recursive operations */
134 gboolean dive_into_subdirs;
136 /* When moving directories cross filesystem boundaries delete the
137 * successfully copied files when all files below the directory and its
138 * subdirectories were processed.
140 * If erase_at_end is FALSE files will be deleted immediately after their
141 * successful copy (Note: this behavior is not tested and at the moment
142 * it can't be changed at runtime).
144 gboolean erase_at_end;
146 /* PID of the child for background operations */
147 pid_t pid;
149 /* toggle if all errors should be ignored */
150 gboolean ignore_all;
152 /* Whether the file operation is in pause */
153 gboolean suspended;
155 /* User interface data goes here */
156 void *ui;
157 } file_op_context_t;
159 typedef struct
161 size_t progress_count;
162 size_t prev_progress_count; /* Used in OP_MOVE between copy and remove directories */
163 uintmax_t progress_bytes;
164 uintmax_t copied_bytes;
165 size_t bps;
166 size_t bps_count;
167 gint64 transfer_start;
168 double eta_secs;
170 gboolean ask_overwrite;
171 } file_op_total_context_t;
173 /*** global variables defined in .c file *********************************************************/
175 extern const char *op_names[3];
177 /*** declarations of public functions ************************************************************/
179 file_op_context_t *file_op_context_new (FileOperation op);
180 void file_op_context_destroy (file_op_context_t * ctx);
182 file_op_total_context_t *file_op_total_context_new (void);
183 void file_op_total_context_destroy (file_op_total_context_t * tctx);
185 /* The following functions are implemented separately by each port */
186 FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,
187 enum OperationMode mode, const char *src,
188 struct stat *src_stat, const char *dst,
189 struct stat *dst_stat);
191 /*** inline functions ****************************************************************************/
192 #endif /* MC__FILEOPCTX_H */