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
;
64 /* First argument passed to real functions */
71 /*** structures declarations (and typedefs of structures)*****************************************/
73 struct mc_search_struct
;
75 /* This structure describes a context for file operations. It is used to update
76 * the progress windows and pass around options.
78 typedef struct FileOpContext
80 /* Operation type (copy, move, delete) */
81 FileOperation operation
;
83 /* The estimated time of arrival in seconds */
86 /* Transferred bytes per second */
89 /* Transferred seconds */
92 /* Whether the panel total has been computed */
93 gboolean progress_totals_computed
;
94 filegui_dialog_type_t dialog_type
;
96 /* Counters for progress indicators */
97 size_t progress_count
;
98 uintmax_t progress_bytes
;
100 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
101 * We can't use the value of "ctx->preserve" because it can change in order
102 * to preserve file attributs when moving files across filesystem boundaries
103 * (we want to keep the value of the checkbox between copy operations).
105 gboolean op_preserve
;
107 /* Result from the recursive query */
108 FileCopyMode recursive_result
;
110 /* Whether to do a reget */
113 /* Controls appending to files */
116 /* Whether to stat or lstat */
117 gboolean follow_links
;
119 /* Pointer to the stat function we will use */
120 mc_stat_fn stat_func
;
122 /* Whether to recompute symlinks */
123 gboolean stable_symlinks
;
125 /* Preserve the original files' owner, group, permissions, and
126 * timestamps (owner, group only as root).
130 /* If running as root, preserve the original uid/gid (we don't want to
131 * try chown for non root) preserve_uidgid = preserve && uid == 0
133 gboolean preserve_uidgid
;
135 /* The bits to preserve in created files' modes on file copy */
138 /* The mask of files to actually operate on */
142 struct mc_search_struct
*search_handle
;
144 /* Whether to dive into subdirectories for recursive operations */
145 int dive_into_subdirs
;
147 /* When moving directories cross filesystem boundaries delete the
148 * successfully copied files when all files below the directory and its
149 * subdirectories were processed.
151 * If erase_at_end is FALSE files will be deleted immediately after their
152 * successful copy (Note: this behavior is not tested and at the moment
153 * it can't be changed at runtime).
155 gboolean erase_at_end
;
157 /* PID of the child for background operations */
160 /* toggle if all errors should be ignored */
163 /* User interface data goes here */
169 size_t progress_count
;
170 uintmax_t progress_bytes
;
171 uintmax_t copied_bytes
;
174 struct timeval transfer_start
;
177 gboolean ask_overwrite
;
178 } FileOpTotalContext
;
180 /*** global variables defined in .c file *********************************************************/
182 extern const char *op_names
[3];
184 /*** declarations of public functions ************************************************************/
186 FileOpContext
*file_op_context_new (FileOperation op
);
187 void file_op_context_destroy (FileOpContext
* ctx
);
189 FileOpTotalContext
*file_op_total_context_new (void);
190 void file_op_total_context_destroy (FileOpTotalContext
* tctx
);
192 /* The following functions are implemented separately by each port */
193 FileProgressStatus
file_progress_real_query_replace (FileOpContext
* 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 */