(edit_set_filename): expand tilde while setting file name.
[pantumic.git] / src / fileopctx.h
blob30119c1841247ffcc612b343281ba99f997af90a
2 /** \file fileopctx.h
3 * \brief Header: file operation contexts
4 * \date 1998
5 * \author Federico Mena <federico@nuclecu.unam.mx>
6 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
7 */
9 /* File operation contexts for the Midnight Commander
11 * Copyright (C) 1998 Free Software Foundation, Inc.
15 #ifndef FILEOPCTX_H
16 #define FILEOPCTX_H
18 #include <sys/stat.h>
19 #include <sys/types.h>
20 #include <sys/time.h>
22 #include "lib/global.h"
24 struct mc_search_struct;
26 typedef enum {
27 OP_COPY = 0,
28 OP_MOVE = 1,
29 OP_DELETE = 2
30 } FileOperation;
32 typedef enum {
33 RECURSIVE_YES = 0,
34 RECURSIVE_NO = 1,
35 RECURSIVE_ALWAYS = 2,
36 RECURSIVE_NEVER = 3,
37 RECURSIVE_ABORT = 4
38 } FileCopyMode;
40 typedef int (*mc_stat_fn) (const char *filename, struct stat *buf);
42 /* This structure describes a context for file operations. It is used to update
43 * the progress windows and pass around options.
45 typedef struct FileOpContext {
46 /* Operation type (copy, move, delete) */
47 FileOperation operation;
49 /* The estimated time of arrival in seconds */
50 double eta_secs;
52 /* Transferred bytes per second */
53 long bps;
55 /* Transferred seconds */
56 long bps_time;
58 /* Whether the panel total has been computed */
59 gboolean progress_totals_computed;
60 int dialog_type;
62 /* Counters for progress indicators */
63 off_t progress_count;
64 double progress_bytes;
66 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
67 * We can't use the value of "ctx->preserve" because it can change in order
68 * to preserve file attributs when moving files across filesystem boundaries
69 * (we want to keep the value of the checkbox between copy operations).
71 gboolean op_preserve;
73 /* Result from the recursive query */
74 FileCopyMode recursive_result;
76 /* Whether to do a reget */
77 off_t do_reget;
79 /* Controls appending to files */
80 gboolean do_append;
82 /* Whether to stat or lstat */
83 gboolean follow_links;
85 /* Pointer to the stat function we will use */
86 mc_stat_fn stat_func;
88 /* Whether to recompute symlinks */
89 gboolean stable_symlinks;
91 /* Preserve the original files' owner, group, permissions, and
92 * timestamps (owner, group only as root).
94 int preserve;
96 /* If running as root, preserve the original uid/gid (we don't want to
97 * try chown for non root) preserve_uidgid = preserve && uid == 0
99 gboolean preserve_uidgid;
101 /* The bits to preserve in created files' modes on file copy */
102 int umask_kill;
104 /* The mask of files to actually operate on */
105 char *dest_mask;
107 /* search handler */
108 struct mc_search_struct *search_handle;
110 /* Whether to dive into subdirectories for recursive operations */
111 int dive_into_subdirs;
113 /* When moving directories cross filesystem boundaries delete the
114 * successfully copied files when all files below the directory and its
115 * subdirectories were processed.
117 * If erase_at_end is FALSE files will be deleted immediately after their
118 * successful copy (Note: this behavior is not tested and at the moment
119 * it can't be changed at runtime).
121 gboolean erase_at_end;
123 /* PID of the child for background operations */
124 pid_t pid;
126 /* User interface data goes here */
127 void *ui;
128 } FileOpContext;
130 typedef struct {
131 off_t progress_count;
132 double progress_bytes;
133 double copyed_bytes;
134 size_t bps;
135 size_t bps_count;
136 struct timeval transfer_start;
137 double eta_secs;
139 gboolean ask_overwrite;
140 gboolean is_toplevel_file;
142 } FileOpTotalContext;
145 FileOpContext *file_op_context_new (FileOperation op);
146 void file_op_context_destroy (FileOpContext *ctx);
148 FileOpTotalContext *file_op_total_context_new (void);
149 void file_op_total_context_destroy (FileOpTotalContext *tctx);
152 extern const char *op_names [3];
154 typedef enum {
155 FILE_CONT = 0,
156 FILE_RETRY = 1,
157 FILE_SKIP = 2,
158 FILE_ABORT = 3
159 } FileProgressStatus;
161 /* First argument passed to real functions */
162 enum OperationMode {
163 Foreground,
164 Background
167 /* The following functions are implemented separately by each port */
169 FileProgressStatus file_progress_real_query_replace (FileOpContext *ctx,
170 enum OperationMode mode,
171 const char *destname,
172 struct stat *_s_stat,
173 struct stat *_d_stat);
176 #endif