lib/vfs/direntry.c: vfs_s_inode_from_path() and vfs_s_get_path() now handle vfs_path_t
[midnight-commander.git] / src / filemanager / fileopctx.h
blobf16c20bec91299fc0c469ef0efe70d5ea368b0a6
1 /** \file fileopctx.h
2 * \brief Header: file operation contexts
3 * \date 1998
4 * \author Federico Mena <federico@nuclecu.unam.mx>
5 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
6 */
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
17 #include <sys/stat.h>
18 #include <sys/types.h>
19 #include <sys/time.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 ***************************************************************************************/
31 typedef enum
33 FILEGUI_DIALOG_ONE_ITEM,
34 FILEGUI_DIALOG_MULTI_ITEM,
35 FILEGUI_DIALOG_DELETE_ITEM
36 } filegui_dialog_type_t;
38 typedef enum
40 OP_COPY = 0,
41 OP_MOVE = 1,
42 OP_DELETE = 2
43 } FileOperation;
45 typedef enum
47 RECURSIVE_YES = 0,
48 RECURSIVE_NO = 1,
49 RECURSIVE_ALWAYS = 2,
50 RECURSIVE_NEVER = 3,
51 RECURSIVE_ABORT = 4
52 } FileCopyMode;
54 typedef enum
56 FILE_CONT = 0,
57 FILE_RETRY = 1,
58 FILE_SKIP = 2,
59 FILE_ABORT = 3,
60 FILE_SKIPALL = 4
61 } FileProgressStatus;
63 /* First argument passed to real functions */
64 enum OperationMode
66 Foreground,
67 Background
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 */
83 double eta_secs;
85 /* Transferred bytes per second */
86 long bps;
88 /* Transferred seconds */
89 long bps_time;
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 */
110 off_t do_reget;
112 /* Controls appending to files */
113 gboolean do_append;
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).
127 int preserve;
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 */
135 int umask_kill;
137 /* The mask of files to actually operate on */
138 char *dest_mask;
140 /* search handler */
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 */
157 pid_t pid;
159 /* toggle if all errors should be ignored */
160 gboolean skip_all;
162 /* User interface data goes here */
163 void *ui;
164 } FileOpContext;
166 typedef struct
168 size_t progress_count;
169 uintmax_t progress_bytes;
170 uintmax_t copyed_bytes;
171 size_t bps;
172 size_t bps_count;
173 struct timeval transfer_start;
174 double eta_secs;
176 gboolean ask_overwrite;
177 gboolean is_toplevel_file;
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 */