(get_fs_usage): avoid compile warning about mixed declarations and code.
[midnight-commander.git] / src / filemanager / fileopctx.h
blobea9c0cabbb8219e9700f5de74f083b465ee9c654
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"
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 ***************************************************************************************/
32 typedef enum
34 FILEGUI_DIALOG_ONE_ITEM,
35 FILEGUI_DIALOG_MULTI_ITEM,
36 FILEGUI_DIALOG_DELETE_ITEM
37 } filegui_dialog_type_t;
39 typedef enum
41 OP_COPY = 0,
42 OP_MOVE = 1,
43 OP_DELETE = 2
44 } FileOperation;
46 typedef enum
48 RECURSIVE_YES = 0,
49 RECURSIVE_NO = 1,
50 RECURSIVE_ALWAYS = 2,
51 RECURSIVE_NEVER = 3,
52 RECURSIVE_ABORT = 4
53 } FileCopyMode;
55 typedef enum
57 FILE_CONT = 0,
58 FILE_RETRY = 1,
59 FILE_SKIP = 2,
60 FILE_ABORT = 3,
61 FILE_SKIPALL = 4
62 } FileProgressStatus;
64 /* First argument passed to real functions */
65 enum OperationMode
67 Foreground,
68 Background
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 */
84 double eta_secs;
86 /* Transferred bytes per second */
87 long bps;
89 /* Transferred seconds */
90 long bps_time;
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 */
111 off_t do_reget;
113 /* Controls appending to files */
114 gboolean do_append;
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).
128 int preserve;
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 */
136 int umask_kill;
138 /* The mask of files to actually operate on */
139 char *dest_mask;
141 /* search handler */
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 */
158 pid_t pid;
160 /* toggle if all errors should be ignored */
161 gboolean skip_all;
163 /* User interface data goes here */
164 void *ui;
165 } FileOpContext;
167 typedef struct
169 size_t progress_count;
170 uintmax_t progress_bytes;
171 uintmax_t copied_bytes;
172 size_t bps;
173 size_t bps_count;
174 struct timeval transfer_start;
175 double eta_secs;
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 */