3 * \brief Header: file operation contexts
5 * \author Federico Mena <federico@nuclecu.unam.mx>
6 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
9 /* File operation contexts for the Midnight Commander
11 * Copyright (C) 1998 Free Software Foundation, Inc.
19 #include <sys/types.h>
22 #include "lib/global.h"
24 struct mc_search_struct
;
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 */
52 /* Transferred bytes per second */
55 /* Transferred seconds */
58 /* Whether the panel total has been computed */
59 gboolean progress_totals_computed
;
62 /* Counters for progress indicators */
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).
73 /* Result from the recursive query */
74 FileCopyMode recursive_result
;
76 /* Whether to do a reget */
79 /* Controls appending to files */
82 /* Whether to stat or lstat */
83 gboolean follow_links
;
85 /* Pointer to the stat function we will use */
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).
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 */
104 /* The mask of files to actually operate on */
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 */
126 /* User interface data goes here */
131 off_t progress_count
;
132 double progress_bytes
;
136 struct timeval transfer_start
;
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];
159 } FileProgressStatus
;
161 /* First argument passed to real functions */
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
);