Updated italian translation
[midnight-commander.git] / src / fileopctx.h
blob3ba20152fb58d16880eeefe225aab28cce704313
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>
7 */
9 #ifndef FILEOPCTX_H
10 #define FILEOPCTX_H
12 #include <sys/stat.h>
13 #include <sys/types.h>
14 #include "eregex.h"
16 typedef enum {
17 OP_COPY,
18 OP_MOVE,
19 OP_DELETE
20 } FileOperation;
22 typedef int (*mc_stat_fn) (const char *filename, struct stat *buf);
24 /* This structure describes a context for file operations. It is used to update
25 * the progress windows and pass around options.
27 typedef struct FileOpContext {
28 /* Operation type (copy, move, delete) */
29 FileOperation operation;
31 /* The estimated time of arrival in seconds */
32 double eta_secs;
34 /* Transferred bytes per second */
35 long bps;
37 /* Transferred seconds */
38 long bps_time;
40 /* Whether the panel total has been computed */
41 int progress_totals_computed;
43 /* Counters for progress indicators */
44 off_t progress_count;
45 double progress_bytes;
47 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
48 * We can't use the value of "ctx->preserve" because it can change in order
49 * to preserve file attributs when moving files across filesystem boundaries
50 * (we want to keep the value of the checkbox between copy operations).
52 int op_preserve;
54 /* Result from the recursive query */
55 int recursive_result;
57 /* Whether to do a reget */
58 off_t do_reget;
60 /* Controls appending to files */
61 int do_append;
63 /* Whether to stat or lstat */
64 int follow_links;
66 /* Pointer to the stat function we will use */
67 mc_stat_fn stat_func;
69 /* Whether to recompute symlinks */
70 int stable_symlinks;
72 /* Preserve the original files' owner, group, permissions, and
73 * timestamps (owner, group only as root).
75 int preserve;
77 /* If running as root, preserve the original uid/gid (we don't want to
78 * try chown for non root) preserve_uidgid = preserve && uid == 0
80 int preserve_uidgid;
82 /* The bits to preserve in created files' modes on file copy */
83 int umask_kill;
85 /* The mask of files to actually operate on */
86 char *dest_mask;
88 /* Regex for the file mask */
89 struct re_pattern_buffer rx;
90 struct re_registers regs;
92 /* Whether to dive into subdirectories for recursive operations */
93 int dive_into_subdirs;
95 /* When moving directories cross filesystem boundaries delete the
96 * successfully copied files when all files below the directory and its
97 * subdirectories were processed.
99 * If erase_at_end is zero files will be deleted immediately after their
100 * successful copy (Note: this behavior is not tested and at the moment
101 * it can't be changed at runtime).
103 int erase_at_end;
105 /* PID of the child for background operations */
106 pid_t pid;
108 /* User interface data goes here */
110 void *ui;
111 } FileOpContext;
114 FileOpContext *file_op_context_new (FileOperation op);
115 void file_op_context_destroy (FileOpContext *ctx);
118 extern const char *op_names [3];
120 typedef enum {
121 FILE_CONT,
122 FILE_RETRY,
123 FILE_SKIP,
124 FILE_ABORT
125 } FileProgressStatus;
127 typedef enum {
128 RECURSIVE_YES,
129 RECURSIVE_NO,
130 RECURSIVE_ALWAYS,
131 RECURSIVE_NEVER,
132 RECURSIVE_ABORT
133 } FileCopyMode;
135 /* First argument passed to real functions */
136 enum OperationMode {
137 Foreground,
138 Background
141 /* The following functions are implemented separately by each port */
143 void file_op_context_create_ui (FileOpContext *ctx, int with_eta);
144 void file_op_context_destroy_ui (FileOpContext *ctx);
146 FileProgressStatus file_progress_show (FileOpContext *ctx, off_t done, off_t total);
147 FileProgressStatus file_progress_show_count (FileOpContext *ctx, off_t done, off_t total);
148 FileProgressStatus file_progress_show_bytes (FileOpContext *ctx, double done, double total);
149 FileProgressStatus file_progress_show_source (FileOpContext *ctx, const char *path);
150 FileProgressStatus file_progress_show_target (FileOpContext *ctx, const char *path);
151 FileProgressStatus file_progress_show_deleting (FileOpContext *ctx, const char *path);
153 void file_progress_set_stalled_label (FileOpContext *ctx, const char *stalled_msg);
155 FileProgressStatus file_progress_real_query_replace (FileOpContext *ctx,
156 enum OperationMode mode,
157 const char *destname,
158 struct stat *_s_stat,
159 struct stat *_d_stat);
162 #endif