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>
21 struct mc_search_struct
;
28 typedef int (*mc_stat_fn
) (const char *filename
, struct stat
*buf
);
30 /* This structure describes a context for file operations. It is used to update
31 * the progress windows and pass around options.
33 typedef struct FileOpContext
{
34 /* Operation type (copy, move, delete) */
35 FileOperation operation
;
37 /* The estimated time of arrival in seconds */
40 /* Transferred bytes per second */
43 /* Transferred seconds */
46 /* Whether the panel total has been computed */
47 int progress_totals_computed
;
49 /* Counters for progress indicators */
51 double progress_bytes
;
53 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
54 * We can't use the value of "ctx->preserve" because it can change in order
55 * to preserve file attributs when moving files across filesystem boundaries
56 * (we want to keep the value of the checkbox between copy operations).
60 /* Result from the recursive query */
63 /* Whether to do a reget */
66 /* Controls appending to files */
69 /* Whether to stat or lstat */
72 /* Pointer to the stat function we will use */
75 /* Whether to recompute symlinks */
78 /* Preserve the original files' owner, group, permissions, and
79 * timestamps (owner, group only as root).
83 /* If running as root, preserve the original uid/gid (we don't want to
84 * try chown for non root) preserve_uidgid = preserve && uid == 0
88 /* The bits to preserve in created files' modes on file copy */
91 /* The mask of files to actually operate on */
94 struct mc_search_struct
*search_handle
;
95 /* Whether to dive into subdirectories for recursive operations */
96 int dive_into_subdirs
;
98 /* When moving directories cross filesystem boundaries delete the
99 * successfully copied files when all files below the directory and its
100 * subdirectories were processed.
102 * If erase_at_end is zero files will be deleted immediately after their
103 * successful copy (Note: this behavior is not tested and at the moment
104 * it can't be changed at runtime).
108 /* PID of the child for background operations */
111 /* User interface data goes here */
117 FileOpContext
*file_op_context_new (FileOperation op
);
118 void file_op_context_destroy (FileOpContext
*ctx
);
121 extern const char *op_names
[3];
128 } FileProgressStatus
;
138 /* First argument passed to real functions */
144 /* The following functions are implemented separately by each port */
146 void file_op_context_create_ui (FileOpContext
*ctx
, int with_eta
);
147 void file_op_context_create_ui_without_init (FileOpContext
*ctx
, int with_eta
);
148 void file_op_context_destroy_ui (FileOpContext
*ctx
);
150 FileProgressStatus
file_progress_show (FileOpContext
*ctx
, off_t done
, off_t total
);
151 FileProgressStatus
file_progress_show_count (FileOpContext
*ctx
, off_t done
, off_t total
);
152 FileProgressStatus
file_progress_show_bytes (FileOpContext
*ctx
, double done
, double total
);
153 FileProgressStatus
file_progress_show_source (FileOpContext
*ctx
, const char *path
);
154 FileProgressStatus
file_progress_show_target (FileOpContext
*ctx
, const char *path
);
155 FileProgressStatus
file_progress_show_deleting (FileOpContext
*ctx
, const char *path
);
157 void file_progress_set_stalled_label (FileOpContext
*ctx
, const char *stalled_msg
);
159 FileProgressStatus
file_progress_real_query_replace (FileOpContext
*ctx
,
160 enum OperationMode mode
,
161 const char *destname
,
162 struct stat
*_s_stat
,
163 struct stat
*_d_stat
);