2 * \brief Header: file management GUI
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 ***************************************************************************************/
23 FILEGUI_DIALOG_ONE_ITEM
,
24 FILEGUI_DIALOG_MULTI_ITEM
,
25 FILEGUI_DIALOG_DELETE_ITEM
26 } filegui_dialog_type_t
;
44 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
56 /* First argument passed to real functions */
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.
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 */
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). */
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 */
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 */
105 /* Controls appending to files */
108 /* Pointer to the stat function we will use */
109 mc_stat_fn stat_func
;
111 struct mc_search_struct
*search_handle
;
112 /* toggle if all errors should be ignored */
114 /* Whether the file operation is in pause */
116 gboolean ask_overwrite
;
117 /* Result from the recursive query */
118 FileCopyMode recursive_result
;
120 /* PID of the child for background operations */
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 */
130 /* Transferred bytes per second */
132 /* Transferred seconds */
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
;
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 */
149 /* Used in OP_MOVE between copy and remove directories */
150 size_t prev_total_progress_count
;
152 /* User interface data goes here */
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
,
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 */