updated the .TP cleanup for coherency in the key description pages.
[midnight-commander.git] / src / fileopctx.h
blob731adccad30197a3e59f1e24b524b388068ae86b
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 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.
22 typedef struct {
23 /* The estimated time of arrival in seconds */
24 double eta_secs;
26 /* Transferred bytes per second */
27 long bps;
29 /* Transferred seconds */
30 long bps_time;
32 /* Whether the panel total has been computed */
33 int progress_totals_computed;
35 /* Counters for progress indicators */
36 off_t progress_count;
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).
44 int op_preserve;
46 /* Result from the recursive query */
47 int recursive_result;
49 /* Whether to do a reget */
50 int do_reget;
52 /* Controls appending to files */
53 int do_append;
55 /* Whether to stat or lstat */
56 int follow_links;
58 /* Pointer to the stat function we will use */
59 mc_stat_fn stat_func;
61 /* Whether to recompute symlinks */
62 int stable_symlinks;
64 /* Preserve the original files' owner, group, permissions, and
65 * timestamps (owner, group only as root).
67 int preserve;
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
72 int preserve_uidgid;
74 /* The bits to preserve in created files' modes on file copy */
75 int umask_kill;
77 /* The mask of files to actually operate on */
78 char *dest_mask;
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).
95 int erase_at_end;
97 /* PID of the child for background operations */
98 pid_t pid;
100 /* User interface data goes here */
102 void *ui;
103 } FileOpContext;
106 FileOpContext *file_op_context_new (void);
107 void file_op_context_destroy (FileOpContext *ctx);
110 typedef enum {
111 OP_COPY,
112 OP_MOVE,
113 OP_DELETE
114 } FileOperation;
116 extern char *op_names [3];
118 typedef enum {
119 FILE_CONT,
120 FILE_RETRY,
121 FILE_SKIP,
122 FILE_ABORT
123 } FileProgressStatus;
125 typedef enum {
126 RECURSIVE_YES,
127 RECURSIVE_NO,
128 RECURSIVE_ALWAYS,
129 RECURSIVE_NEVER,
130 RECURSIVE_ABORT
131 } FileCopyMode;
133 /* First argument passed to real functions */
134 enum OperationMode {
135 Foreground,
136 Background
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,
155 char *destname,
156 struct stat *_s_stat,
157 struct stat *_d_stat);
160 #endif