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>
14 #include <inttypes.h> /* uintmax_t */
16 #include "lib/global.h"
17 #include "lib/vfs/vfs.h"
20 /*** typedefs(not structures) and defined constants **********************************************/
22 typedef int (*mc_stat_fn
) (const vfs_path_t
* vpath
, struct stat
* buf
);
24 /*** enums ***************************************************************************************/
28 FILEGUI_DIALOG_ONE_ITEM
,
29 FILEGUI_DIALOG_MULTI_ITEM
,
30 FILEGUI_DIALOG_DELETE_ITEM
31 } filegui_dialog_type_t
;
49 /* 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 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
97 * We can't use the value of "ctx->preserve" because it can change in order
98 * to preserve file attributs when moving files across filesystem boundaries
99 * (we want to keep the value of the checkbox between copy operations).
101 gboolean op_preserve
;
103 /* Result from the recursive query */
104 FileCopyMode recursive_result
;
106 /* Whether to do a reget */
109 /* Controls appending to files */
112 /* Whether to stat or lstat */
113 gboolean follow_links
;
115 /* Pointer to the stat function we will use */
116 mc_stat_fn stat_func
;
118 /* Whether to recompute symlinks */
119 gboolean stable_symlinks
;
121 /* Preserve the original files' owner, group, permissions, and
122 * timestamps (owner, group only as root).
126 /* If running as root, preserve the original uid/gid (we don't want to
127 * try chown for non root) preserve_uidgid = preserve && uid == 0
129 gboolean preserve_uidgid
;
131 /* The bits to preserve in created files' modes on file copy */
134 /* The mask of files to actually operate on */
138 struct mc_search_struct
*search_handle
;
140 /* Whether to dive into subdirectories for recursive operations */
141 gboolean dive_into_subdirs
;
143 /* When moving directories cross filesystem boundaries delete the
144 * successfully copied files when all files below the directory and its
145 * subdirectories were processed.
147 * If erase_at_end is FALSE files will be deleted immediately after their
148 * successful copy (Note: this behavior is not tested and at the moment
149 * it can't be changed at runtime).
151 gboolean erase_at_end
;
153 /* PID of the child for background operations */
156 /* toggle if all errors should be ignored */
159 /* Whether the file operation is in pause */
162 /* User interface data goes here */
168 size_t progress_count
;
169 size_t prev_progress_count
; /* Used in OP_MOVE between copy and remove directories */
170 uintmax_t progress_bytes
;
171 uintmax_t copied_bytes
;
174 struct timeval transfer_start
;
177 gboolean ask_overwrite
;
178 } file_op_total_context_t
;
180 /*** global variables defined in .c file *********************************************************/
182 extern const char *op_names
[3];
184 /*** declarations of public functions ************************************************************/
186 file_op_context_t
*file_op_context_new (FileOperation op
);
187 void file_op_context_destroy (file_op_context_t
* ctx
);
189 file_op_total_context_t
*file_op_total_context_new (void);
190 void file_op_total_context_destroy (file_op_total_context_t
* tctx
);
192 /* The following functions are implemented separately by each port */
193 FileProgressStatus
file_progress_real_query_replace (file_op_context_t
* ctx
,
194 enum OperationMode mode
,
195 const char *destname
,
196 struct stat
*_s_stat
, struct stat
*_d_stat
);
198 /*** inline functions ****************************************************************************/
199 #endif /* MC__FILEOPCTX_H */