2 * \brief Header: file operation contexts
4 * \author Federico Mena <federico@nuclecu.unam.mx>
5 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
8 #ifndef MC__FILEOPCTX_H
9 #define MC__FILEOPCTX_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 ***************************************************************************************/
27 FILEGUI_DIALOG_ONE_ITEM
,
28 FILEGUI_DIALOG_MULTI_ITEM
,
29 FILEGUI_DIALOG_DELETE_ITEM
30 } filegui_dialog_type_t
;
48 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
60 /* First argument passed to real functions */
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.
76 /* Operation type (copy, move, delete) */
77 FileOperation operation
;
79 /* The estimated time of arrival in seconds */
82 /* Transferred bytes per second */
85 /* Transferred seconds */
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 */
102 /* Controls appending to files */
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).
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 */
127 /* The mask of files to actually operate on */
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 */
149 /* toggle if all errors should be ignored */
152 /* Whether the file operation is in pause */
155 /* User interface data goes here */
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
;
167 gint64 transfer_start
;
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 */