2 * \brief Header: file operation contexts
4 * \author Federico Mena <federico@nuclecu.unam.mx>
5 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
8 /* File operation contexts for the Midnight Commander
10 * Copyright (C) 1998 Free Software Foundation, Inc.
14 #ifndef MC__FILEOPCTX_H
15 #define MC__FILEOPCTX_H
18 #include <sys/types.h>
20 #include <inttypes.h> /* uintmax_t */
22 #include "lib/global.h"
23 #include "lib/vfs/vfs.h"
26 /*** typedefs(not structures) and defined constants **********************************************/
28 typedef int (*mc_stat_fn
) (const vfs_path_t
* vpath
, struct stat
* buf
);
30 /*** enums ***************************************************************************************/
34 FILEGUI_DIALOG_ONE_ITEM
,
35 FILEGUI_DIALOG_MULTI_ITEM
,
36 FILEGUI_DIALOG_DELETE_ITEM
37 } filegui_dialog_type_t
;
65 /* First argument passed to real functions */
72 /*** structures declarations (and typedefs of structures)*****************************************/
74 struct mc_search_struct
;
76 /* This structure describes a context for file operations. It is used to update
77 * the progress windows and pass around options.
79 typedef struct FileOpContext
81 /* Operation type (copy, move, delete) */
82 FileOperation operation
;
84 /* The estimated time of arrival in seconds */
87 /* Transferred bytes per second */
90 /* Transferred seconds */
93 /* Whether the panel total has been computed */
94 gboolean progress_totals_computed
;
95 filegui_dialog_type_t dialog_type
;
97 /* Counters for progress indicators */
98 size_t progress_count
;
99 uintmax_t progress_bytes
;
101 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
102 * We can't use the value of "ctx->preserve" because it can change in order
103 * to preserve file attributs when moving files across filesystem boundaries
104 * (we want to keep the value of the checkbox between copy operations).
106 gboolean op_preserve
;
108 /* Result from the recursive query */
109 FileCopyMode recursive_result
;
111 /* Whether to do a reget */
114 /* Controls appending to files */
117 /* Whether to stat or lstat */
118 gboolean follow_links
;
120 /* Pointer to the stat function we will use */
121 mc_stat_fn stat_func
;
123 /* Whether to recompute symlinks */
124 gboolean stable_symlinks
;
126 /* Preserve the original files' owner, group, permissions, and
127 * timestamps (owner, group only as root).
131 /* If running as root, preserve the original uid/gid (we don't want to
132 * try chown for non root) preserve_uidgid = preserve && uid == 0
134 gboolean preserve_uidgid
;
136 /* The bits to preserve in created files' modes on file copy */
139 /* The mask of files to actually operate on */
143 struct mc_search_struct
*search_handle
;
145 /* Whether to dive into subdirectories for recursive operations */
146 gboolean dive_into_subdirs
;
148 /* When moving directories cross filesystem boundaries delete the
149 * successfully copied files when all files below the directory and its
150 * subdirectories were processed.
152 * If erase_at_end is FALSE files will be deleted immediately after their
153 * successful copy (Note: this behavior is not tested and at the moment
154 * it can't be changed at runtime).
156 gboolean erase_at_end
;
158 /* PID of the child for background operations */
161 /* toggle if all errors should be ignored */
164 /* Whether the file operation is in pause */
167 /* User interface data goes here */
173 size_t progress_count
;
174 uintmax_t progress_bytes
;
175 uintmax_t copied_bytes
;
178 struct timeval transfer_start
;
181 gboolean ask_overwrite
;
182 } FileOpTotalContext
;
184 /*** global variables defined in .c file *********************************************************/
186 extern const char *op_names
[3];
188 /*** declarations of public functions ************************************************************/
190 FileOpContext
*file_op_context_new (FileOperation op
);
191 void file_op_context_destroy (FileOpContext
* ctx
);
193 FileOpTotalContext
*file_op_total_context_new (void);
194 void file_op_total_context_destroy (FileOpTotalContext
* tctx
);
196 /* The following functions are implemented separately by each port */
197 FileProgressStatus
file_progress_real_query_replace (FileOpContext
* ctx
,
198 enum OperationMode mode
,
199 const char *destname
,
200 struct stat
*_s_stat
, struct stat
*_d_stat
);
202 /*** inline functions ****************************************************************************/
203 #endif /* MC__FILEOPCTX_H */