tbx  0.7.3
fileraction.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2012 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 /*
25  * fileraction.h
26  *
27  * Created on: 21 Feb 2012
28  * Author: alanb
29  */
30 
31 #ifndef TBX_FILERACTION_H_
32 #define TBX_FILERACTION_H_
33 
34 #include <string>
35 #include "listener.h"
36 
37 namespace tbx {
38 
43 {
44  public:
45  virtual ~FilerActionFinishedListener() {}
46 
50  virtual void fileraction_finished() = 0;
51 };
52 
64 {
65  int _handle;
66 public:
67  FilerAction();
68  FilerAction(const std::string &object_name);
69  FilerAction(const std::string &dir_name, const std::string &objects);
70  virtual ~FilerAction();
71 
79  int task_handle() const {return _handle;}
80 
81  void directory(const std::string &dir_name);
82  void add_objects(const std::string &objects);
83  void set_object(const std::string &object_name);
84 
89  enum Options
90  {
91  NONE = 0, //<! No options
92  VERBOSE = 1, //<! Show verbose information
93  CONFIRM = 2, //<! Confirm operation
94  FORCE = 4, //<! Force overwrite
95  NEWER = 8, //<! Copy if newer only
96  RECURSE = 16 //<! Recurse (applies to access only)
97  };
98 
99  void copy(const std::string &target_dir, int options = NONE);
100  void rename(const std::string &target_dir, int options = NONE);
101  void remove(int options = NONE);
102  void set_access(int set, int leave, int options = NONE);
103  void set_file_type(int type, int options = NONE);
104  void count(int options = NONE);
105  void move(const std::string &target_dir, int options = NONE);
106  void copy_local(const std::string &leaf_name, int options = NONE);
107  void stamp(int options = NONE);
108  void find(const std::string &find_object, int options = NONE);
109 
110  void verbose(bool on);
111 
113 
114 private:
115  void start();
116 };
117 
118 } /* namespace tbx */
119 
120 #endif /* TBX_FILERACTION_H_ */
virtual void fileraction_finished()=0
Called when the filer action has finished.
void set_access(int set, int leave, int options=NONE)
Set access for object(s)
Definition: fileraction.cc:224
int task_handle() const
Return the handle of the filer action task.
Definition: fileraction.h:79
Options
Options for file operations.
Definition: fileraction.h:89
void set_object(const std::string &object_name)
Set the filer action to operate on a single file system object e.g.
Definition: fileraction.cc:149
void copy(const std::string &target_dir, int options=NONE)
Copy object(s) to the target directory.
Definition: fileraction.cc:164
void directory(const std::string &dir_name)
Set the directory containing the object to operate on.
Definition: fileraction.cc:117
void count(int options=NONE)
Show a count of the selected object(s)
Definition: fileraction.cc:263
Listener for filer action finished.
Definition: fileraction.h:42
void set_file_type(int type, int options=NONE)
Set file type for object(s)
Definition: fileraction.cc:244
void find(const std::string &find_object, int options=NONE)
Find an object and display its location.
Definition: fileraction.cc:342
void add_objects(const std::string &objects)
Set the objects to operate upon.
Definition: fileraction.cc:134
void move(const std::string &target_dir, int options=NONE)
Move object(s) to the target directory by copying first then deleting.
Definition: fileraction.cc:283
void stamp(int options=NONE)
Stamp the object(s) with the current time and date.
Definition: fileraction.cc:322
void verbose(bool on)
Turn on or off verbose window while filer action is running.
Definition: fileraction.cc:376
Class to use the RISC OS desktop filer to perform multi-tasking file operations.
Definition: fileraction.h:63
Base class for all toolbox event listeners.
Definition: listener.h:33
void copy_local(const std::string &leaf_name, int options=NONE)
Copy file within the source directory.
Definition: fileraction.cc:302
void rename(const std::string &target_dir, int options=NONE)
Move object(s) to the target directory by renaming.
Definition: fileraction.cc:184
void add_finished_listener(FilerActionFinishedListener *listener)
Add a listener for when the filer action has finished.
Definition: fileraction.cc:394
FilerAction()
Constructor with no parameters.
Definition: fileraction.cc:75