root/src/filemanager/fileopctx.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /** \file fileopctx.h
   2  *  \brief Header: file operation contexts
   3  *  \date 1998
   4  *  \author Federico Mena <federico@nuclecu.unam.mx>
   5  *  \author Miguel de Icaza <miguel@nuclecu.unam.mx>
   6  */
   7 
   8 #ifndef MC__FILEOPCTX_H
   9 #define MC__FILEOPCTX_H
  10 
  11 #include <sys/stat.h>
  12 #include <sys/types.h>
  13 #include <sys/time.h>
  14 #include <inttypes.h>           /* uintmax_t */
  15 
  16 #include "lib/global.h"
  17 #include "lib/vfs/vfs.h"
  18 
  19 
  20 /*** typedefs(not structures) and defined constants **********************************************/
  21 
  22 typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
  23 
  24 /*** enums ***************************************************************************************/
  25 
  26 typedef enum
  27 {
  28     FILEGUI_DIALOG_ONE_ITEM,
  29     FILEGUI_DIALOG_MULTI_ITEM,
  30     FILEGUI_DIALOG_DELETE_ITEM
  31 } filegui_dialog_type_t;
  32 
  33 typedef enum
  34 {
  35     OP_COPY = 0,
  36     OP_MOVE = 1,
  37     OP_DELETE = 2
  38 } FileOperation;
  39 
  40 typedef enum
  41 {
  42     RECURSIVE_YES = 0,
  43     RECURSIVE_NO = 1,
  44     RECURSIVE_ALWAYS = 2,
  45     RECURSIVE_NEVER = 3,
  46     RECURSIVE_ABORT = 4
  47 } FileCopyMode;
  48 
  49 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
  50 typedef enum
  51 {
  52     FILE_CONT = 10,
  53     FILE_RETRY,
  54     FILE_SKIP,
  55     FILE_ABORT,
  56     FILE_SKIPALL,
  57     FILE_SUSPEND
  58 } FileProgressStatus;
  59 
  60 /* First argument passed to real functions */
  61 enum OperationMode
  62 {
  63     Foreground,
  64     Background
  65 };
  66 
  67 /*** structures declarations (and typedefs of structures)*****************************************/
  68 
  69 struct mc_search_struct;
  70 
  71 /* This structure describes a context for file operations.  It is used to update
  72  * the progress windows and pass around options.
  73  */
  74 typedef struct
  75 {
  76     /* Operation type (copy, move, delete) */
  77     FileOperation operation;
  78 
  79     /* The estimated time of arrival in seconds */
  80     double eta_secs;
  81 
  82     /* Transferred bytes per second */
  83     long bps;
  84 
  85     /* Transferred seconds */
  86     long bps_time;
  87 
  88     /* Whether the panel total has been computed */
  89     gboolean progress_totals_computed;
  90     filegui_dialog_type_t dialog_type;
  91 
  92     /* Counters for progress indicators */
  93     size_t progress_count;
  94     uintmax_t progress_bytes;
  95 
  96     /* The value of the "preserve Attributes" checkbox in the copy file dialog.
  97      * We can't use the value of "ctx->preserve" because it can change in order
  98      * to preserve file attributs when moving files across filesystem boundaries
  99      * (we want to keep the value of the checkbox between copy operations).
 100      */
 101     gboolean op_preserve;
 102 
 103     /* Result from the recursive query */
 104     FileCopyMode recursive_result;
 105 
 106     /* Whether to do a reget */
 107     off_t do_reget;
 108 
 109     /* Controls appending to files */
 110     gboolean do_append;
 111 
 112     /* Whether to stat or lstat */
 113     gboolean follow_links;
 114 
 115     /* Pointer to the stat function we will use */
 116     mc_stat_fn stat_func;
 117 
 118     /* Whether to recompute symlinks */
 119     gboolean stable_symlinks;
 120 
 121     /* Preserve the original files' owner, group, permissions, and
 122      * timestamps (owner, group only as root).
 123      */
 124     gboolean preserve;
 125 
 126     /* If running as root, preserve the original uid/gid (we don't want to
 127      * try chown for non root) preserve_uidgid = preserve && uid == 0
 128      */
 129     gboolean preserve_uidgid;
 130 
 131     /* The bits to preserve in created files' modes on file copy */
 132     mode_t umask_kill;
 133 
 134     /* The mask of files to actually operate on */
 135     char *dest_mask;
 136 
 137     /* search handler */
 138     struct mc_search_struct *search_handle;
 139 
 140     /* Whether to dive into subdirectories for recursive operations */
 141     gboolean dive_into_subdirs;
 142 
 143     /* When moving directories cross filesystem boundaries delete the
 144      * successfully copied files when all files below the directory and its
 145      * subdirectories were processed.
 146      *
 147      * If erase_at_end is FALSE files will be deleted immediately after their
 148      * successful copy (Note: this behavior is not tested and at the moment
 149      * it can't be changed at runtime).
 150      */
 151     gboolean erase_at_end;
 152 
 153     /* PID of the child for background operations */
 154     pid_t pid;
 155 
 156     /* toggle if all errors should be ignored */
 157     gboolean skip_all;
 158 
 159     /* Whether the file operation is in pause */
 160     gboolean suspended;
 161 
 162     /* User interface data goes here */
 163     void *ui;
 164 } file_op_context_t;
 165 
 166 typedef struct
 167 {
 168     size_t progress_count;
 169     size_t prev_progress_count; /* Used in OP_MOVE between copy and remove directories */
 170     uintmax_t progress_bytes;
 171     uintmax_t copied_bytes;
 172     size_t bps;
 173     size_t bps_count;
 174     struct timeval transfer_start;
 175     double eta_secs;
 176 
 177     gboolean ask_overwrite;
 178 } file_op_total_context_t;
 179 
 180 /*** global variables defined in .c file *********************************************************/
 181 
 182 extern const char *op_names[3];
 183 
 184 /*** declarations of public functions ************************************************************/
 185 
 186 file_op_context_t *file_op_context_new (FileOperation op);
 187 void file_op_context_destroy (file_op_context_t * ctx);
 188 
 189 file_op_total_context_t *file_op_total_context_new (void);
 190 void file_op_total_context_destroy (file_op_total_context_t * tctx);
 191 
 192 /* The following functions are implemented separately by each port */
 193 FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,
 194                                                      enum OperationMode mode, const char *src,
 195                                                      struct stat *src_stat, const char *dst,
 196                                                      struct stat *dst_stat);
 197 
 198 /*** inline functions ****************************************************************************/
 199 #endif /* MC__FILEOPCTX_H */

/* [previous][next][first][last][top][bottom][index][help]  */