1 /* File operation contexts for the Midnight Commander
3 * Copyright (C) 1998 The Free Software Foundation
5 * Authors: Federico Mena <federico@nuclecu.unam.mx>
6 * Miguel de Icaza <miguel@nuclecu.unam.mx>
13 #include <sys/types.h>
17 typedef int (*mc_stat_fn
) (char *filename
, struct stat
*buf
);
19 /* This structure describes a context for file operations. It is used to update
20 * the progress windows and pass around options.
23 /* The estimated time of arrival in seconds */
26 /* Transferred bytes per second */
29 /* Transferred seconds */
32 /* Whether the panel total has been computed */
33 int progress_totals_computed
;
35 /* Counters for progress indicators */
37 double progress_bytes
;
39 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
40 * We can't use the value of "ctx->preserve" because it can change in order
41 * to preserve file attributs when moving files across filesystem boundaries
42 * (we want to keep the value of the checkbox between copy operations).
46 /* Result from the recursive query */
49 /* Whether to do a reget */
52 /* Controls appending to files */
55 /* Whether to stat or lstat */
58 /* Pointer to the stat function we will use */
61 /* Whether to recompute symlinks */
64 /* Preserve the original files' owner, group, permissions, and
65 * timestamps (owner, group only as root).
69 /* If running as root, preserve the original uid/gid (we don't want to
70 * try chown for non root) preserve_uidgid = preserve && uid == 0
74 /* The bits to preserve in created files' modes on file copy */
77 /* The mask of files to actually operate on */
80 /* Regex for the file mask */
81 struct re_pattern_buffer rx
;
82 struct re_registers regs
;
84 /* Whether to dive into subdirectories for recursive operations */
85 int dive_into_subdirs
;
87 /* When moving directories cross filesystem boundaries delete the
88 * successfull copied files when all files below the directory and its
89 * subdirectories were processed.
91 * If erase_at_end is zero files will be deleted immediately after their
92 * successful copy (Note: this behaviour is not tested and at the moment
93 * it can't be changed at runtime).
97 /* PID of the child for background operations */
100 /* User interface data goes here */
106 FileOpContext
*file_op_context_new (void);
107 void file_op_context_destroy (FileOpContext
*ctx
);
116 extern char *op_names
[3];
123 } FileProgressStatus
;
133 /* First argument passed to real functions */
139 /* The following functions are implemented separately by each port */
141 void file_op_context_create_ui (FileOpContext
*ctx
, FileOperation op
, int with_eta
);
142 void file_op_context_destroy_ui (FileOpContext
*ctx
);
144 FileProgressStatus
file_progress_show (FileOpContext
*ctx
, off_t done
, off_t total
);
145 FileProgressStatus
file_progress_show_count (FileOpContext
*ctx
, off_t done
, off_t total
);
146 FileProgressStatus
file_progress_show_bytes (FileOpContext
*ctx
, double done
, double total
);
147 FileProgressStatus
file_progress_show_source (FileOpContext
*ctx
, char *path
);
148 FileProgressStatus
file_progress_show_target (FileOpContext
*ctx
, char *path
);
149 FileProgressStatus
file_progress_show_deleting (FileOpContext
*ctx
, char *path
);
151 void file_progress_set_stalled_label (FileOpContext
*ctx
, char *stalled_msg
);
153 FileProgressStatus
file_progress_real_query_replace (FileOpContext
*ctx
,
154 enum OperationMode mode
,
156 struct stat
*_s_stat
,
157 struct stat
*_d_stat
);