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) */
59 /* First argument passed to real functions */
66 /*** structures declarations (and typedefs of structures)*****************************************/
68 struct mc_search_struct
;
70 /* This structure describes a context for file operations. It is used to update
71 * the progress windows and pass around options.
75 /* Operation type (copy, move, delete) */
76 FileOperation operation
;
78 /* The estimated time of arrival in seconds */
81 /* Transferred bytes per second */
84 /* Transferred seconds */
87 /* Whether the panel total has been computed */
88 gboolean progress_totals_computed
;
89 filegui_dialog_type_t dialog_type
;
91 /* Counters for progress indicators */
92 size_t progress_count
;
93 uintmax_t progress_bytes
;
95 /* Result from the recursive query */
96 FileCopyMode recursive_result
;
98 /* Whether to do a reget */
101 /* Controls appending to files */
104 /* Whether to stat or lstat */
105 gboolean follow_links
;
107 /* Pointer to the stat function we will use */
108 mc_stat_fn stat_func
;
110 /* Whether to recompute symlinks */
111 gboolean stable_symlinks
;
113 /* Preserve the original files' owner, group, permissions, and
114 * timestamps (owner, group only as root).
118 /* If running as root, preserve the original uid/gid (we don't want to
119 * try chown for non root) preserve_uidgid = preserve && uid == 0
121 gboolean preserve_uidgid
;
123 /* The bits to preserve in created files' modes on file copy */
126 /* The mask of files to actually operate on */
130 struct mc_search_struct
*search_handle
;
132 /* Whether to dive into subdirectories for recursive operations */
133 gboolean dive_into_subdirs
;
135 /* When moving directories cross filesystem boundaries delete the
136 * successfully copied files when all files below the directory and its
137 * subdirectories were processed.
139 * If erase_at_end is FALSE files will be deleted immediately after their
140 * successful copy (Note: this behavior is not tested and at the moment
141 * it can't be changed at runtime).
143 gboolean erase_at_end
;
145 /* PID of the child for background operations */
148 /* toggle if all errors should be ignored */
151 /* Whether the file operation is in pause */
154 /* User interface data goes here */
160 size_t progress_count
;
161 size_t prev_progress_count
; /* Used in OP_MOVE between copy and remove directories */
162 uintmax_t progress_bytes
;
163 uintmax_t copied_bytes
;
166 gint64 transfer_start
;
169 gboolean ask_overwrite
;
170 } file_op_total_context_t
;
172 /*** global variables defined in .c file *********************************************************/
174 extern const char *op_names
[3];
176 /*** declarations of public functions ************************************************************/
178 file_op_context_t
*file_op_context_new (FileOperation op
);
179 void file_op_context_destroy (file_op_context_t
* ctx
);
181 file_op_total_context_t
*file_op_total_context_new (void);
182 void file_op_total_context_destroy (file_op_total_context_t
* tctx
);
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 ****************************************************************************/
191 #endif /* MC__FILEOPCTX_H */