1 /* copyop.h
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2001-2021 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef COPYOP_H
23 #define COPYOP_H
24 
25 #include "wdefines.h"
26 #include "functionproto.h"
27 #include "copy_parameters.hh"
28 
29 class CopyOp:public FunctionProto
30 {
31 public:
32   CopyOp();
33   virtual ~CopyOp();
34   CopyOp( const CopyOp &other );
35   CopyOp &operator=( const CopyOp &other );
36 
37   CopyOp *duplicate() const override;
38   bool isName(const char *) override;
39   const char *getName() override;
40   int run( std::shared_ptr< WPUContext > wpu, ActionMessage* ) override;
41   bool save(Datei*) override;
42   const char *getDescription() override;
43   int configure() override;
44 
45   int doconfigure(int mode);
46 
47   typedef enum {COPYOP_OVERWRITE_NORMAL=0,COPYOP_OVERWRITE_ALWAYS,COPYOP_OVERWRITE_NEVER} overwrite_t;
48   void setFollowSymlinks(bool);
49   void setMove(bool);
50   void setRename(bool);
51   void setSameDir(bool);
52   void setRequestDest(bool);
53   void setOverwrite(overwrite_t);
54   void setPreserveAttr(bool);
55   void setVdirPreserveDirStructure(bool);
56 
57   typedef enum { COPYOP_ADJUST_SYMLINK_NEVER,
58                  COPYOP_ADJUST_SYMLINK_OUTSIDE,
59                  COPYOP_ADJUST_SYMLINK_ALWAYS
60   } adjust_relative_symlinks_t;
61 
62   void setAdjustRelativeSymlinks( adjust_relative_symlinks_t nv );
63   void setEnsureFilePermissions( const CopyParams::EnsureFilePermissions &nv );
64   bool isInteractiveRun() const;
65   void setInteractiveRun();
66 protected:
67   static const char *name;
68   // Infos to save
69   bool follow_symlinks;
70   bool move;
71   bool do_rename;
72   bool same_dir;
73   bool request_dest;
74   bool preserve_attr;
75   bool vdir_preserve_dir_structure;
76   adjust_relative_symlinks_t adjust_relative_symlinks;
77   CopyParams::EnsureFilePermissions ensure_file_permissions;
78 
79   overwrite_t overwrite;
80 
81   // temp variables
82   Lister *startlister,*endlister;
83 
84   // temp values filled when request_flags==true
85   bool tfollow_symlinks;
86   bool tmove;
87   bool trename;
88   bool tsame_dir;
89   bool trequest_dest;
90   bool tpreserve_attr;
91   bool tvdir_preserve_dir_structure;
92   adjust_relative_symlinks_t tadjust_relative_symlinks;
93   CopyParams::EnsureFilePermissions tensure_file_permissions;
94   overwrite_t toverwrite;
95 
96   int normalmodecopy( ActionMessage *am );
97   int requestdest( const char *defaultstr, char **dest,
98                    bool show_do_not_ask, bool &do_not_ask_return );
99 };
100 
101 #endif
102