-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFolder.h
170 lines (145 loc) · 5.79 KB
/
Folder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef Folder_H
#define Folder_H
#include "Arduino_UnifiedStorage.h"
#include "Utils.h"
#include "UFile.h"
#include <vector>
class UFile;
/**
* @class Folder
* @brief Class representing a directory.
*/
class Folder {
public:
/**
* @brief Creates an empty Folder object.
* Please note that any operation on this object will fail until a valid directory is assigned to it.
*/
Folder();
/**
* @brief Creates a directory with the specified name.
* If the directory already exists, it returns a Folder object representing the existing directory.
* Otherwise, it tries to create a new directory with the specified name. If it fails the `path` property of the Folder object will be null.
* @param const char * dirname - The name of the directory.
*/
Folder(const char * dirname);
/**
* @brief Creates a directory with the specified name.
* If the directory already exists, it returns a Folder object representing the existing directory.
* Otherwise, it tries to create a new directory with the specified name. If it fails the `path` property of the Folder object will be empty.
* @param String dirname - The name of the directory.
*/
Folder(String dirname);
/**
* @brief Creates a file inside the directory.
* @param const char * fileName - The name of the file to create.
* @return A File object if successful, NULL if not.
*/
UFile createFile(const char * fileName, FileMode fmode);
/**
* @brief Creates a file inside the directory.
* @param String fileName - The name of the file to create.
* @return A File object if successful, NULL if not.
*/
UFile createFile(String fileName, FileMode fmode);
/**
* @brief Removes a directory.
* @return True if the directory was removed successfully, false otherwise.
*/
bool remove();
/**
* @brief Renames a directory.
* @param const char * newDirname The new name of the directory.
* @return True if the directory was renamed successfully, false otherwise.
*/
bool rename(const char * newDirname);
/**
* @brief Renames a directory.
* @param String newDirname The new name of the directory.
* @return True if the directory was renamed successfully, false otherwise.
*/
bool rename(String newDirname);
/**
* @brief Checks if the directory exists.
* @return True if the directory exists, false otherwise.
*/
bool exists();
/**
* @brief Returns the path of the file.
* @return The path of the file as a const char *
*/
const char * getPath();
/**
* @brief Returns the path of the file.
* @return The path of the file as an Arduino String
*/
String getPathAsString();
/**
* @brief Creates a subfolder in the directory.
* @param const char * subfolderName - he name of the subfolder to create.
* @param overwrite - behaviour in case the folder already exists, default is false
* @return The created subfolder.
*/
Folder createSubfolder(const char * subfolderName, bool overwrite = false);
/**
* @brief Creates a subfolder in the directory.
* @param String subfolderName - he name of the subfolder to create.
* @param overwrite - behaviour in case the folder already exists, default is false
* @return The created subfolder.
*/
Folder createSubfolder(String subfolderName, bool overwrite = false);
/**
* @brief Returns File objects for all files in the current directory.
* @return A std::vector of File objects representing the files in the directory.
*/
std::vector<UFile> getFiles();
/**
* @brief Returns Folder objects for all files in the current directory.
* @return A std::vector of Folder objects representing the files in the directory.
*/
std::vector<Folder> getFolders();
/**
* @brief Copies the current directory
* @param Folder destination - a Folder object representing the destination
* @return True upon success, false otherwise.
*/
bool copyTo(Folder destination, bool overwrite = false);
/**
* @brief Copies the current directory
* @param const char * destination - the path of the destination location
* @param overwrite - behaviour in case the folder already exists, default is false
* @return True upon success, false otherwise.
*/
bool copyTo(const char * destination, bool overwrite = false);
/**
* @brief Copies the current directory
* @param String destination - the path of the destination location
* @param overwrite - behaviour in case the folder already exists, default is false
* @return True upon success, false otherwise.
*/
bool copyTo(String destination, bool overwrite = false);
/**
* @brief Moves the current directory
* @param Folder destination - a Folder object representing the destination
* @param overwrite - behaviour in case the folder already exists, default is false
* @return True upon success, false otherwise.
*/
bool moveTo(Folder destination, bool overwrite = false);
/**
* @brief Moves the current directory
* @param const char * destination - the path of the destination location
* @param overwrite - behaviour in case the folder already exists, default is false
* @return True upon success, false otherwise.
*/
bool moveTo(const char * destination, bool overwrite = false);
/**
* @brief Move the current directory
* @param String destination - the path of the destination location
* @param overwrite - behaviour in case the folder already exists, default is false
* @return True upon success, false otherwise.
*/
bool moveTo(String destination, bool overwrite = false);
private:
std::string path;
};
#endif