1
2
3
4
5 #ifndef MC__FILEGUI_H
6 #define MC__FILEGUI_H
7
8 #include <sys/stat.h>
9 #include <sys/types.h>
10 #include <inttypes.h>
11
12 #include "lib/global.h"
13 #include "lib/vfs/vfs.h"
14
15
16
17 typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
18
19
20
21 typedef enum
22 {
23 FILEGUI_DIALOG_ONE_ITEM,
24 FILEGUI_DIALOG_MULTI_ITEM,
25 FILEGUI_DIALOG_DELETE_ITEM
26 } filegui_dialog_type_t;
27
28 typedef enum
29 {
30 OP_COPY = 0,
31 OP_MOVE = 1,
32 OP_DELETE = 2
33 } FileOperation;
34
35 typedef enum
36 {
37 RECURSIVE_YES = 0,
38 RECURSIVE_NO = 1,
39 RECURSIVE_ALWAYS = 2,
40 RECURSIVE_NEVER = 3,
41 RECURSIVE_ABORT = 4
42 } FileCopyMode;
43
44
45 typedef enum
46 {
47 FILE_CONT = 10,
48 FILE_RETRY,
49 FILE_SKIP,
50 FILE_ABORT,
51 FILE_IGNORE,
52 FILE_IGNORE_ALL,
53 FILE_SUSPEND
54 } FileProgressStatus;
55
56
57 enum OperationMode
58 {
59 Foreground,
60 Background
61 };
62
63
64
65 struct mc_search_struct;
66
67
68
69
70 typedef struct
71 {
72
73 FileOperation operation;
74
75 filegui_dialog_type_t dialog_type;
76
77
78
79 char *dest_mask;
80
81 gboolean dive_into_subdirs;
82
83 gboolean follow_links;
84
85 gboolean stable_symlinks;
86
87
88 gboolean preserve;
89
90
91 gboolean preserve_uidgid;
92
93 mode_t umask_kill;
94
95
96
97
98
99
100
101 gboolean erase_at_end;
102
103
104 off_t do_reget;
105
106 gboolean do_append;
107
108
109 mc_stat_fn stat_func;
110
111 struct mc_search_struct *search_handle;
112
113 gboolean ignore_all;
114
115 gboolean suspended;
116 gboolean ask_overwrite;
117
118 FileCopyMode recursive_result;
119
120
121 pid_t pid;
122
123
124
125 gint64 transfer_start;
126
127 uintmax_t progress_bytes;
128
129 double eta_secs;
130
131 long bps;
132
133
134
135 gboolean totals_computed;
136
137 gint64 total_transfer_start;
138
139 size_t total_progress_count;
140 size_t total_count;
141 uintmax_t total_progress_bytes;
142 uintmax_t total_bytes;
143
144 double total_eta_secs;
145
146 long total_bps;
147
148 size_t prev_total_progress_count;
149
150
151 gint64 pauses;
152
153
154 void *ui;
155 } file_op_context_t;
156
157
158
159 extern const char *op_names[3];
160
161
162
163 file_op_context_t *file_op_context_new (FileOperation op);
164 void file_op_context_destroy (file_op_context_t * ctx);
165
166 void file_progress_ui_create (file_op_context_t * ctx, gboolean with_eta,
167 filegui_dialog_type_t dialog_type);
168 void file_progress_ui_destroy (file_op_context_t * ctx);
169
170 char *file_mask_dialog (file_op_context_t * ctx, gboolean only_one, const char *format,
171 const void *text, const char *def_text, gboolean * do_bg);
172
173 FileProgressStatus file_progress_check_buttons (file_op_context_t * ctx);
174
175 void file_progress_show (file_op_context_t * ctx, off_t done, off_t total,
176 const char *stalled_msg, gboolean force_update);
177 void file_progress_show_count (file_op_context_t * ctx);
178 void file_progress_show_total (file_op_context_t * ctx, uintmax_t copied_bytes, gint64 tv_current,
179 gboolean show_summary);
180 void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * vpath);
181 void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * vpath);
182 gboolean file_progress_show_deleting (file_op_context_t * ctx, const vfs_path_t * vpath,
183 size_t *count);
184
185
186 FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,
187 enum OperationMode mode, const char *src,
188 struct stat *src_stat, const char *dst,
189 struct stat *dst_stat);
190
191
192
193 #endif