Codepage messages related translated & other stuff...
[midnight-commander.git] / src / fileopctx.h
blob27589688c85974830cf42646cd9c9158e6aacf66
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"
17 /* This structure describes a context for file operations. It is used to update
18 * the progress windows and pass around options.
20 typedef struct {
21 /* The estimated time of arrival in seconds */
22 double eta_secs;
24 /* Transferred bytes per second */
25 long bps;
27 /* Transferred seconds */
28 long bps_time;
30 /* Whether the panel total has been computed */
31 int progress_totals_computed;
33 /* Counters for progress indicators */
34 long progress_count;
35 double progress_bytes;
37 /* The value of the "preserve Attributes" checkbox in the copy file dialog.
38 * We can't use the value of "ctx->preserve" because it can change in order
39 * to preserve file attributs when moving files across filesystem boundaries
40 * (we want to keep the value of the checkbox between copy operations).
42 int op_preserve;
44 /* Result from the recursive query */
45 int recursive_result;
47 /* Whether to do a reget */
48 int do_reget;
50 /* Controls appending to files */
51 int do_append;
53 /* Whether to stat or lstat */
54 int follow_links;
56 /* Pointer to the stat function we will use */
57 int (*stat_func) (char *filename, struct stat *buf);
59 /* Whether to recompute symlinks */
60 int stable_symlinks;
62 /* Preserve the original files' owner, group, permissions, and
63 * timestamps (owner, group only as root).
65 int preserve;
67 /* If running as root, preserve the original uid/gid (we don't want to
68 * try chwon for non root) preserve_uidgid = preserve && uid == 0
70 int preserve_uidgid;
72 /* The bits to preserve in created files' modes on file copy */
73 int umask_kill;
75 /* The mask of files to actually operate on */
76 char *dest_mask;
78 /* Regex for the file mask */
79 struct re_pattern_buffer rx;
80 struct re_registers regs;
82 /* Whether to dive into subdirectories for recursive operations */
83 int dive_into_subdirs;
85 /* When moving directories cross filesystem boundaries delete the
86 * successfull copied files when all files below the directory and its
87 * subdirectories were processed.
89 * If erase_at_end is zero files will be deleted immediately after their
90 * successful copy (Note: this behaviour is not tested and at the moment
91 * it can't be changed at runtime).
93 int erase_at_end;
95 /* PID of the child for background operations */
96 pid_t pid;
98 /* User interface data goes here */
100 void *ui;
101 } FileOpContext;
104 FileOpContext *file_op_context_new (void);
105 void file_op_context_destroy (FileOpContext *ctx);
108 typedef enum {
109 OP_COPY,
110 OP_MOVE,
111 OP_DELETE
112 } FileOperation;
114 extern char *op_names [3];
116 typedef enum {
117 FILE_CONT,
118 FILE_RETRY,
119 FILE_SKIP,
120 FILE_ABORT
121 } FileProgressStatus;
123 typedef enum {
124 RECURSIVE_YES,
125 RECURSIVE_NO,
126 RECURSIVE_ALWAYS,
127 RECURSIVE_NEVER,
128 RECURSIVE_ABORT
129 } FileCopyMode;
131 /* First argument passed to real functions */
132 enum OperationMode {
133 Foreground,
134 Background
137 /* The following functions are implemented separately by each port */
139 void file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta);
140 void file_op_context_destroy_ui (FileOpContext *ctx);
142 FileProgressStatus file_progress_show (FileOpContext *ctx, long done, long total);
143 FileProgressStatus file_progress_show_count (FileOpContext *ctx, long done, long total);
144 FileProgressStatus file_progress_show_bytes (FileOpContext *ctx, double done, double total);
145 FileProgressStatus file_progress_show_source (FileOpContext *ctx, char *path);
146 FileProgressStatus file_progress_show_target (FileOpContext *ctx, char *path);
147 FileProgressStatus file_progress_show_deleting (FileOpContext *ctx, char *path);
149 void file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg);
151 FileProgressStatus file_progress_real_query_replace (FileOpContext *ctx,
152 enum OperationMode mode,
153 char *destname,
154 struct stat *_s_stat,
155 struct stat *_d_stat);
158 #endif