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 <inttypes.h>           /* uintmax_t */
  14 
  15 #include "lib/global.h"
  16 #include "lib/vfs/vfs.h"
  17 
  18 
  19 /*** typedefs(not structures) and defined constants **********************************************/
  20 
  21 typedef int (*mc_stat_fn) (const vfs_path_t * vpath, struct stat * buf);
  22 
  23 /*** enums ***************************************************************************************/
  24 
  25 typedef enum
  26 {
  27     FILEGUI_DIALOG_ONE_ITEM,
  28     FILEGUI_DIALOG_MULTI_ITEM,
  29     FILEGUI_DIALOG_DELETE_ITEM
  30 } filegui_dialog_type_t;
  31 
  32 typedef enum
  33 {
  34     OP_COPY = 0,
  35     OP_MOVE = 1,
  36     OP_DELETE = 2
  37 } FileOperation;
  38 
  39 typedef enum
  40 {
  41     RECURSIVE_YES = 0,
  42     RECURSIVE_NO = 1,
  43     RECURSIVE_ALWAYS = 2,
  44     RECURSIVE_NEVER = 3,
  45     RECURSIVE_ABORT = 4
  46 } FileCopyMode;
  47 
  48 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
  49 typedef enum
  50 {
  51     FILE_CONT = 10,
  52     FILE_RETRY,
  53     FILE_SKIP,
  54     FILE_ABORT,
  55     FILE_IGNORE,
  56     FILE_IGNORE_ALL,
  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     /* Result from the recursive query */
  97     FileCopyMode recursive_result;
  98 
  99     /* Whether to do a reget */
 100     off_t do_reget;
 101 
 102     /* Controls appending to files */
 103     gboolean do_append;
 104 
 105     /* Whether to stat or lstat */
 106     gboolean follow_links;
 107 
 108     /* Pointer to the stat function we will use */
 109     mc_stat_fn stat_func;
 110 
 111     /* Whether to recompute symlinks */
 112     gboolean stable_symlinks;
 113 
 114     /* Preserve the original files' owner, group, permissions, and
 115      * timestamps (owner, group only as root).
 116      */
 117     gboolean preserve;
 118 
 119     /* If running as root, preserve the original uid/gid (we don't want to
 120      * try chown for non root) preserve_uidgid = preserve && uid == 0
 121      */
 122     gboolean preserve_uidgid;
 123 
 124     /* The bits to preserve in created files' modes on file copy */
 125     mode_t umask_kill;
 126 
 127     /* The mask of files to actually operate on */
 128     char *dest_mask;
 129 
 130     /* search handler */
 131     struct mc_search_struct *search_handle;
 132 
 133     /* Whether to dive into subdirectories for recursive operations */
 134     gboolean dive_into_subdirs;
 135 
 136     /* When moving directories cross filesystem boundaries delete the
 137      * successfully copied files when all files below the directory and its
 138      * subdirectories were processed.
 139      *
 140      * If erase_at_end is FALSE files will be deleted immediately after their
 141      * successful copy (Note: this behavior is not tested and at the moment
 142      * it can't be changed at runtime).
 143      */
 144     gboolean erase_at_end;
 145 
 146     /* PID of the child for background operations */
 147     pid_t pid;
 148 
 149     /* toggle if all errors should be ignored */
 150     gboolean ignore_all;
 151 
 152     /* Whether the file operation is in pause */
 153     gboolean suspended;
 154 
 155     /* User interface data goes here */
 156     void *ui;
 157 } file_op_context_t;
 158 
 159 typedef struct
 160 {
 161     size_t progress_count;
 162     size_t prev_progress_count; /* Used in OP_MOVE between copy and remove directories */
 163     uintmax_t progress_bytes;
 164     uintmax_t copied_bytes;
 165     size_t bps;
 166     size_t bps_count;
 167     gint64 transfer_start;
 168     double eta_secs;
 169 
 170     gboolean ask_overwrite;
 171 } file_op_total_context_t;
 172 
 173 /*** global variables defined in .c file *********************************************************/
 174 
 175 extern const char *op_names[3];
 176 
 177 /*** declarations of public functions ************************************************************/
 178 
 179 file_op_context_t *file_op_context_new (FileOperation op);
 180 void file_op_context_destroy (file_op_context_t * ctx);
 181 
 182 file_op_total_context_t *file_op_total_context_new (void);
 183 void file_op_total_context_destroy (file_op_total_context_t * tctx);
 184 
 185 /* The following functions are implemented separately by each port */
 186 FileProgressStatus file_progress_real_query_replace (file_op_context_t * ctx,
 187                                                      enum OperationMode mode, const char *src,
 188                                                      struct stat *src_stat, const char *dst,
 189                                                      struct stat *dst_stat);
 190 
 191 /*** inline functions ****************************************************************************/
 192 #endif /* MC__FILEOPCTX_H */

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