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>
21 #include "lib/global.h"
24 /*** typedefs(not structures) and defined constants **********************************************/
26 typedef int (*mc_stat_fn
) (const char *filename
, struct stat
* buf
);
28 /*** enums ***************************************************************************************/
54 /* First argument passed to real functions */
61 /*** structures declarations (and typedefs of structures)*****************************************/
63 struct mc_search_struct
;
65 /* This structure describes a context for file operations. It is used to update
66 * the progress windows and pass around options.
68 typedef struct FileOpContext
70 /* Operation type (copy, move, delete) */
71 FileOperation operation
;
73 /* The estimated time of arrival in seconds */
76 /* Transferred bytes per second */
79 /* Transferred seconds */
82 /* Whether the panel total has been computed */
83 gboolean progress_totals_computed
;
86 /* Counters for progress indicators */
88 double progress_bytes
;
90 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
91 * We can't use the value of "ctx->preserve" because it can change in order
92 * to preserve file attributs when moving files across filesystem boundaries
93 * (we want to keep the value of the checkbox between copy operations).
97 /* Result from the recursive query */
98 FileCopyMode recursive_result
;
100 /* Whether to do a reget */
103 /* Controls appending to files */
106 /* Whether to stat or lstat */
107 gboolean follow_links
;
109 /* Pointer to the stat function we will use */
110 mc_stat_fn stat_func
;
112 /* Whether to recompute symlinks */
113 gboolean stable_symlinks
;
115 /* Preserve the original files' owner, group, permissions, and
116 * timestamps (owner, group only as root).
120 /* If running as root, preserve the original uid/gid (we don't want to
121 * try chown for non root) preserve_uidgid = preserve && uid == 0
123 gboolean preserve_uidgid
;
125 /* The bits to preserve in created files' modes on file copy */
128 /* The mask of files to actually operate on */
132 struct mc_search_struct
*search_handle
;
134 /* Whether to dive into subdirectories for recursive operations */
135 int dive_into_subdirs
;
137 /* When moving directories cross filesystem boundaries delete the
138 * successfully copied files when all files below the directory and its
139 * subdirectories were processed.
141 * If erase_at_end is FALSE files will be deleted immediately after their
142 * successful copy (Note: this behavior is not tested and at the moment
143 * it can't be changed at runtime).
145 gboolean erase_at_end
;
147 /* PID of the child for background operations */
150 /* User interface data goes here */
156 off_t progress_count
;
157 double progress_bytes
;
161 struct timeval transfer_start
;
164 gboolean ask_overwrite
;
165 gboolean is_toplevel_file
;
167 } FileOpTotalContext
;
169 /*** global variables defined in .c file *********************************************************/
171 extern const char *op_names
[3];
173 /*** declarations of public functions ************************************************************/
175 FileOpContext
*file_op_context_new (FileOperation op
);
176 void file_op_context_destroy (FileOpContext
* ctx
);
178 FileOpTotalContext
*file_op_total_context_new (void);
179 void file_op_total_context_destroy (FileOpTotalContext
* tctx
);
181 /* The following functions are implemented separately by each port */
182 FileProgressStatus
file_progress_real_query_replace (FileOpContext
* ctx
,
183 enum OperationMode mode
,
184 const char *destname
,
185 struct stat
*_s_stat
, struct stat
*_d_stat
);
187 /*** inline functions ****************************************************************************/
188 #endif /* MC__FILEOPCTX_H */