Qore FsUtil Module Reference 1.3
Loading...
Searching...
No Matches
FsUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* FsUtil.qm Copyright 2018 - 2023 Qore Technologies, s.r.o.
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 in
14 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
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27
28// assume local var scope, do not use "$" for vars, members, and method calls
29
30
31/* see release notes below for version history
32*/
33
89// private namespace
90namespace Init {
91 init();
92
93};
94
96namespace FsUtil {
98 const DefaultBufferSize = 16 * 1024;
99
102
103public:
105 list<string> delimiters;
106
107 string joinPaths(list<string> paths);
108
109 // to be implemented by platform-specific classes
110protected:
111 abstract string joinPathsIntern(list<string> paths);
112public:
113 };
114
117
118public:
121
122
124
129 list<string> splitDrive(string path);
130
132
140protected:
141 string joinPathsIntern(list<string> paths);
142public:
143
144 };
145
148
149public:
152
153
155
163protected:
164 string joinPathsIntern(list<string> paths);
165public:
166
167 };
168
170
179 string basename_ext(string path, *string extension);
180
181
183
192 string join_paths(string path1, list<auto> paths);
193
194
196
205 string join_paths();
206
207
209
218 string join_paths(list<string> paths);
219
220
222
228 bool path_exists(string path, bool follow_symlinks = False);
229
230
231 const TMP_MAX_ATTEMPTS = 10000;
232
234
247 string make_tmp_dir(*string prefix, *string suffix, *string path);
248
249
250 public hashdecl TmpFileHash {
251 string path = "";
252 File file = new File();
253 };
254
256
270 hash<TmpFileHash> make_tmp_file(*string prefix, *string suffix, *string path);
271
272
274
278class TmpDir : public Qore::Dir {
279
280public:
282 string path;
283
285
290 constructor(*string prefix, *string suffix, *string path);
291
292
293 destructor();
294 };
295
297 class TmpFile {
298
299public:
300 string path;
301 File file;
302
304
309 constructor(*string prefix, *string suffix, *string path);
310
311
312 destructor();
313 };
314
316
323 remove_file(string path);
324
325
327
341 remove_tree(string path, bool fail_immediately = True);
342
343
345
350 remove_path(string path);
351
352
354
368 bool same_file_stat(*hash<StatInfo> stat1, *hash<StatInfo> stat2, bool ignore_errors = True);
369
370
372
388 bool same_file(string path1, string path2, bool follow_symlinks = True, bool ignore_errors = True);
389
390
392
424 string copy_tree_internal(string source, string destination, bool follow_symlinks = False, bool overwrite = False, bool merge = False, bool fail_immediately = True, *int depth);
425
426
428
436 copy_file_obj(File source, File destination, bool close = False, int buf_size = DefaultBufferSize);
437
438
440
455 string copy_file(string source, string destination, bool follow_symlinks = False, bool overwrite = False);
456
457
459
480 string copy_tree(string source, string destination, bool follow_symlinks = False, bool overwrite = False, bool fail_immediately = True);
481
482
484
507 string copy_path(string source, string destination, bool follow_symlinks = False, bool overwrite = False, bool fail_immediately = True, *int depth);
508
509
511
531 string merge_tree(string source, string destination, bool follow_symlinks = False, bool overwrite = False, bool fail_immediately = True, *int depth);
532
533
535
549 string move_path(string source, string destination, bool overwrite = False);
550
551
553
570 string merge_path(string source, string destination, bool follow_symlinks = False, bool overwrite = False, bool fail_immediately = True, *int depth);
571
572
574
587 string copy_dir_structure(string source, string destination, *int depth);
588
589
590}; // FsUtil namespace
generic path handler implementing functionality common for both platforms
Definition: FsUtil.qm.dox.h:101
list< string > delimiters
path delimiters - to be set by platform specific path handlers
Definition: FsUtil.qm.dox.h:105
path handler implementing POSIX specific functionality
Definition: FsUtil.qm.dox.h:147
string joinPathsIntern(list< string > paths)
Returns the path resulting from joining the given paths.
constructor()
creates the object and sets the delimiter
Class implementing a user friendly temporary directory creation.
Definition: FsUtil.qm.dox.h:278
string path
The path to the temporary directory created in the constructor.
Definition: FsUtil.qm.dox.h:282
constructor(*string prefix, *string suffix, *string path)
Creates a unique temporary directory and returns its absolute path.
Class implementing a user friendly temporary file creation; the file is removed in the destructor.
Definition: FsUtil.qm.dox.h:297
constructor(*string prefix, *string suffix, *string path)
Creates and opens a unique temporary file and returns its absolute path as well as its File object.
path handler implementing Windows specific functionality
Definition: FsUtil.qm.dox.h:116
constructor()
creates the object and sets the delimiter
string joinPathsIntern(list< string > paths)
Returns the path resulting from joining the given paths.
list< string > splitDrive(string path)
separates and returns the drive and the rest of the path
the FsUtil namespace contains all the objects in the FsUtil module
Definition: FsUtil.qm.dox.h:96
string copy_path(string source, string destination, bool follow_symlinks=False, bool overwrite=False, bool fail_immediately=True, *int depth)
Universal copy function.
bool same_file_stat(*hash< StatInfo > stat1, *hash< StatInfo > stat2, bool ignore_errors=True)
Checks whether two stat hashes point to the same file or not.
bool same_file(string path1, string path2, bool follow_symlinks=True, bool ignore_errors=True)
Checks whether two paths point to the same file/directory or not.
remove_path(string path)
Universal remove function.
string copy_file(string source, string destination, bool follow_symlinks=False, bool overwrite=False)
Copies a file (regular or symlink) from source to destination.
copy_file_obj(File source, File destination, bool close=False, int buf_size=DefaultBufferSize)
Copies a file object data from source to destination.
string copy_dir_structure(string source, string destination, *int depth)
Copies a structure of directories, files are ignored.
string move_path(string source, string destination, bool overwrite=False)
Moves a path from source to destination.
hash< TmpFileHash > make_tmp_file(*string prefix, *string suffix, *string path)
Creates and opens a unique temporary file and returns its absolute path as well as its File object.
string merge_tree(string source, string destination, bool follow_symlinks=False, bool overwrite=False, bool fail_immediately=True, *int depth)
Merges a copy of the source directory tree to the destination directory tree.
string join_paths()
Returns the path resulting from joining the given paths.
bool path_exists(string path, bool follow_symlinks=False)
Check whether the given path exists or not.
string make_tmp_dir(*string prefix, *string suffix, *string path)
Creates a unique temporary directory and returns its absolute path.
remove_tree(string path, bool fail_immediately=True)
Removes the filesystem tree specified by path.
string merge_path(string source, string destination, bool follow_symlinks=False, bool overwrite=False, bool fail_immediately=True, *int depth)
Universal merge function.
remove_file(string path)
Removes a regular file or symlink specified by path.
string copy_tree(string source, string destination, bool follow_symlinks=False, bool overwrite=False, bool fail_immediately=True)
Copies a directory tree from source to destination.
string copy_tree_internal(string source, string destination, bool follow_symlinks=False, bool overwrite=False, bool merge=False, bool fail_immediately=True, *int depth)
Private internal copy tree function implementation.
string basename_ext(string path, *string extension)
this function returns the segment of given path after the last delimiter
const DefaultBufferSize
Default file block buffer size.
Definition: FsUtil.qm.dox.h:98