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"
25 /*** typedefs(not structures) and defined constants **********************************************/
27 typedef int (*mc_stat_fn
) (const char *filename
, struct stat
* buf
);
29 /*** enums ***************************************************************************************/
33 FILEGUI_DIALOG_ONE_ITEM
,
34 FILEGUI_DIALOG_MULTI_ITEM
,
35 FILEGUI_DIALOG_DELETE_ITEM
36 } filegui_dialog_type_t
;
63 /* First argument passed to real functions */
70 /*** structures declarations (and typedefs of structures)*****************************************/
72 struct mc_search_struct
;
74 /* This structure describes a context for file operations. It is used to update
75 * the progress windows and pass around options.
77 typedef struct FileOpContext
79 /* Operation type (copy, move, delete) */
80 FileOperation operation
;
82 /* The estimated time of arrival in seconds */
85 /* Transferred bytes per second */
88 /* Transferred seconds */
91 /* Whether the panel total has been computed */
92 gboolean progress_totals_computed
;
93 filegui_dialog_type_t dialog_type
;
95 /* Counters for progress indicators */
96 size_t progress_count
;
97 uintmax_t progress_bytes
;
99 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
100 * We can't use the value of "ctx->preserve" because it can change in order
101 * to preserve file attributs when moving files across filesystem boundaries
102 * (we want to keep the value of the checkbox between copy operations).
104 gboolean op_preserve
;
106 /* Result from the recursive query */
107 FileCopyMode recursive_result
;
109 /* Whether to do a reget */
112 /* Controls appending to files */
115 /* Whether to stat or lstat */
116 gboolean follow_links
;
118 /* Pointer to the stat function we will use */
119 mc_stat_fn stat_func
;
121 /* Whether to recompute symlinks */
122 gboolean stable_symlinks
;
124 /* Preserve the original files' owner, group, permissions, and
125 * timestamps (owner, group only as root).
129 /* If running as root, preserve the original uid/gid (we don't want to
130 * try chown for non root) preserve_uidgid = preserve && uid == 0
132 gboolean preserve_uidgid
;
134 /* The bits to preserve in created files' modes on file copy */
137 /* The mask of files to actually operate on */
141 struct mc_search_struct
*search_handle
;
143 /* Whether to dive into subdirectories for recursive operations */
144 int dive_into_subdirs
;
146 /* When moving directories cross filesystem boundaries delete the
147 * successfully copied files when all files below the directory and its
148 * subdirectories were processed.
150 * If erase_at_end is FALSE files will be deleted immediately after their
151 * successful copy (Note: this behavior is not tested and at the moment
152 * it can't be changed at runtime).
154 gboolean erase_at_end
;
156 /* PID of the child for background operations */
159 /* toggle if all errors should be ignored */
162 /* User interface data goes here */
168 size_t progress_count
;
169 uintmax_t progress_bytes
;
170 uintmax_t copyed_bytes
;
173 struct timeval transfer_start
;
176 gboolean ask_overwrite
;
177 } FileOpTotalContext
;
179 /*** global variables defined in .c file *********************************************************/
181 extern const char *op_names
[3];
183 /*** declarations of public functions ************************************************************/
185 FileOpContext
*file_op_context_new (FileOperation op
);
186 void file_op_context_destroy (FileOpContext
* ctx
);
188 FileOpTotalContext
*file_op_total_context_new (void);
189 void file_op_total_context_destroy (FileOpTotalContext
* tctx
);
191 /* The following functions are implemented separately by each port */
192 FileProgressStatus
file_progress_real_query_replace (FileOpContext
* ctx
,
193 enum OperationMode mode
,
194 const char *destname
,
195 struct stat
*_s_stat
, struct stat
*_d_stat
);
197 /*** inline functions ****************************************************************************/
198 #endif /* MC__FILEOPCTX_H */