Added -g, --oldmouse option to support of NORMAL/BUTTON_EVENT mouse type.
[midnight-commander.git] / src / filemanager / fileopctx.h
blob251758e60787559186d7f563d9505fe293a37580
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 } FileProgressStatus;
62 /* First argument passed to real functions */
63 enum OperationMode
65 Foreground,
66 Background
69 /*** structures declarations (and typedefs of structures)*****************************************/
71 struct mc_search_struct;
73 /* This structure describes a context for file operations. It is used to update
74 * the progress windows and pass around options.
76 typedef struct FileOpContext
78 /* Operation type (copy, move, delete) */
79 FileOperation operation;
81 /* The estimated time of arrival in seconds */
82 double eta_secs;
84 /* Transferred bytes per second */
85 long bps;
87 /* Transferred seconds */
88 long bps_time;
90 /* Whether the panel total has been computed */
91 gboolean progress_totals_computed;
92 filegui_dialog_type_t dialog_type;
94 /* Counters for progress indicators */
95 size_t progress_count;
96 uintmax_t progress_bytes;
98 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
99 * We can't use the value of "ctx->preserve" because it can change in order
100 * to preserve file attributs when moving files across filesystem boundaries
101 * (we want to keep the value of the checkbox between copy operations).
103 gboolean op_preserve;
105 /* Result from the recursive query */
106 FileCopyMode recursive_result;
108 /* Whether to do a reget */
109 off_t do_reget;
111 /* Controls appending to files */
112 gboolean do_append;
114 /* Whether to stat or lstat */
115 gboolean follow_links;
117 /* Pointer to the stat function we will use */
118 mc_stat_fn stat_func;
120 /* Whether to recompute symlinks */
121 gboolean stable_symlinks;
123 /* Preserve the original files' owner, group, permissions, and
124 * timestamps (owner, group only as root).
126 int preserve;
128 /* If running as root, preserve the original uid/gid (we don't want to
129 * try chown for non root) preserve_uidgid = preserve && uid == 0
131 gboolean preserve_uidgid;
133 /* The bits to preserve in created files' modes on file copy */
134 int umask_kill;
136 /* The mask of files to actually operate on */
137 char *dest_mask;
139 /* search handler */
140 struct mc_search_struct *search_handle;
142 /* Whether to dive into subdirectories for recursive operations */
143 int dive_into_subdirs;
145 /* When moving directories cross filesystem boundaries delete the
146 * successfully copied files when all files below the directory and its
147 * subdirectories were processed.
149 * If erase_at_end is FALSE files will be deleted immediately after their
150 * successful copy (Note: this behavior is not tested and at the moment
151 * it can't be changed at runtime).
153 gboolean erase_at_end;
155 /* PID of the child for background operations */
156 pid_t pid;
158 /* User interface data goes here */
159 void *ui;
160 } FileOpContext;
162 typedef struct
164 size_t progress_count;
165 uintmax_t progress_bytes;
166 uintmax_t copyed_bytes;
167 size_t bps;
168 size_t bps_count;
169 struct timeval transfer_start;
170 double eta_secs;
172 gboolean ask_overwrite;
173 gboolean is_toplevel_file;
174 } FileOpTotalContext;
176 /*** global variables defined in .c file *********************************************************/
178 extern const char *op_names[3];
180 /*** declarations of public functions ************************************************************/
182 FileOpContext *file_op_context_new (FileOperation op);
183 void file_op_context_destroy (FileOpContext * ctx);
185 FileOpTotalContext *file_op_total_context_new (void);
186 void file_op_total_context_destroy (FileOpTotalContext * tctx);
188 /* The following functions are implemented separately by each port */
189 FileProgressStatus file_progress_real_query_replace (FileOpContext * ctx,
190 enum OperationMode mode,
191 const char *destname,
192 struct stat *_s_stat, struct stat *_d_stat);
194 /*** inline functions ****************************************************************************/
195 #endif /* MC__FILEOPCTX_H */