(erase_dir_iff_empty): remove 'count' argument.
[midnight-commander.git] / src / filemanager / filegui.h
blob8c2c4b04e2bb7626e552c76120f45ab8f59dad96
1 /** \file filegui.h
2 * \brief Header: file management GUI
3 */
5 #ifndef MC__FILEGUI_H
6 #define MC__FILEGUI_H
8 #include <sys/stat.h>
9 #include <sys/types.h>
10 #include <inttypes.h> /* uintmax_t */
12 #include "lib/global.h"
13 #include "lib/vfs/vfs.h"
15 /*** typedefs(not structures) and defined constants **********************************************/
17 typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
19 /*** enums ***************************************************************************************/
21 typedef enum
23 FILEGUI_DIALOG_ONE_ITEM,
24 FILEGUI_DIALOG_MULTI_ITEM,
25 FILEGUI_DIALOG_DELETE_ITEM
26 } filegui_dialog_type_t;
28 typedef enum
30 OP_COPY = 0,
31 OP_MOVE = 1,
32 OP_DELETE = 2
33 } FileOperation;
35 typedef enum
37 RECURSIVE_YES = 0,
38 RECURSIVE_NO = 1,
39 RECURSIVE_ALWAYS = 2,
40 RECURSIVE_NEVER = 3,
41 RECURSIVE_ABORT = 4
42 } FileCopyMode;
44 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
45 typedef enum
47 FILE_CONT = 10,
48 FILE_RETRY,
49 FILE_SKIP,
50 FILE_ABORT,
51 FILE_IGNORE,
52 FILE_IGNORE_ALL,
53 FILE_SUSPEND
54 } FileProgressStatus;
56 /* First argument passed to real functions */
57 enum OperationMode
59 Foreground,
60 Background
63 /*** structures declarations (and typedefs of structures)*****************************************/
65 struct mc_search_struct;
67 /* This structure describes a context for file operations. It is used to update
68 * the progress windows and pass around options.
70 typedef struct
72 /* Operation type (copy, move, delete) */
73 FileOperation operation;
75 filegui_dialog_type_t dialog_type;
77 /* File operation options */
78 /* The mask of files to actually operate on */
79 char *dest_mask;
80 /* Whether to dive into subdirectories for recursive operations */
81 gboolean dive_into_subdirs;
82 /* Whether to stat or lstat */
83 gboolean follow_links;
84 /* Whether to recompute symlinks */
85 gboolean stable_symlinks;
86 /* Preserve the original files' owner, group, permissions, and
87 * timestamps (owner, group only as root). */
88 gboolean preserve;
89 /* If running as root, preserve the original uid/gid (we don't want to
90 * try chown for non root) preserve_uidgid = preserve && uid == 0 */
91 gboolean preserve_uidgid;
92 /* The bits to preserve in created files' modes on file copy */
93 mode_t umask_kill;
94 /* When moving directories cross filesystem boundaries delete the
95 * successfully copied files when all files below the directory and its
96 * subdirectories were processed.
98 * If erase_at_end is FALSE files will be deleted immediately after their
99 * successful copy (Note: this behavior is not tested and at the moment
100 * it can't be changed at runtime). */
101 gboolean erase_at_end;
103 /* Whether to do a reget */
104 off_t do_reget;
105 /* Controls appending to files */
106 gboolean do_append;
108 /* Pointer to the stat function we will use */
109 mc_stat_fn stat_func;
110 /* search handler */
111 struct mc_search_struct *search_handle;
112 /* toggle if all errors should be ignored */
113 gboolean ignore_all;
114 /* Whether the file operation is in pause */
115 gboolean suspended;
116 gboolean ask_overwrite;
117 /* Result from the recursive query */
118 FileCopyMode recursive_result;
120 /* PID of the child for background operations */
121 pid_t pid;
123 /* One file statuses */
124 /* File transfer start time */
125 gint64 transfer_start;
126 /* Counters for progress indicators */
127 uintmax_t progress_bytes;
128 /* The estimated time of arrival in seconds */
129 double eta_secs;
130 /* Transferred bytes per second */
131 long bps;
132 /* Transferred seconds */
133 long bps_time;
135 /* Total statuses */
136 /* Whether the panel total has been computed */
137 gboolean totals_computed;
138 /* Files transfer start time */
139 gint64 total_transfer_start;
140 /* Counters for progress indicators */
141 size_t total_progress_count;
142 size_t total_count;
143 uintmax_t total_progress_bytes;
144 uintmax_t total_bytes;
145 /* The estimated time of arrival in seconds */
146 double total_eta_secs;
147 /* Transferred bytes per second */
148 size_t total_bps;
149 /* Used in OP_MOVE between copy and remove directories */
150 size_t prev_total_progress_count;
152 /* User interface data goes here */
153 void *ui;
154 } file_op_context_t;
156 /*** global variables defined in .c file *********************************************************/
158 extern const char *op_names[3];
160 /*** declarations of public functions ************************************************************/
162 file_op_context_t *file_op_context_new (FileOperation op);
163 void file_op_context_destroy (file_op_context_t * ctx);
165 void file_progress_ui_create (file_op_context_t * ctx, gboolean with_eta,
166 filegui_dialog_type_t dialog_type);
167 void file_progress_ui_destroy (file_op_context_t * ctx);
169 char *file_mask_dialog (file_op_context_t * ctx, gboolean only_one, const char *format,
170 const void *text, const char *def_text, gboolean * do_bg);
172 FileProgressStatus file_progress_check_buttons (file_op_context_t * ctx);
174 void file_progress_show (file_op_context_t * ctx, off_t done, off_t total,
175 const char *stalled_msg, gboolean force_update);
176 void file_progress_show_count (file_op_context_t * ctx, size_t done, size_t total);
177 void file_progress_show_total (file_op_context_t * ctx, uintmax_t copied_bytes,
178 gboolean show_summary);
179 void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * vpath);
180 void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * vpath);
181 gboolean file_progress_show_deleting (file_op_context_t * ctx, const vfs_path_t * vpath,
182 size_t *count);
184 /* The following functions are implemented separately by each port */
185 FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,
186 enum OperationMode mode, const char *src,
187 struct stat *src_stat, const char *dst,
188 struct stat *dst_stat);
190 /*** inline functions ****************************************************************************/
192 #endif /* MC__FILEGUI_H */