libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
dir.h
Go to the documentation of this file.
1
8#pragma once
9
12#include <promeki/core/string.h>
13#include <promeki/core/list.h>
14#include <promeki/core/error.h>
15
17
34class Dir {
35 public:
37 Dir() = default;
38
43 Dir(const FilePath &path) : _path(path) { }
44
49 Dir(const String &path) : _path(path) { }
50
55 Dir(const char *path) : _path(path) { }
56
61 FilePath path() const { return _path; }
62
67 bool exists() const;
68
75 bool isEmpty() const;
76
82
90 List<FilePath> entryList(const String &filter) const;
91
98 Error mkdir() const;
99
104 Error mkpath() const;
105
110 Error remove() const;
111
117
122 static Dir current();
123
128 static Dir home();
129
134 static Dir temp();
135
142
143 private:
144 FilePath _path;
145};
146
Provides directory operations using std::filesystem.
Definition dir.h:34
Error remove() const
Removes this directory (must be empty).
Error mkdir() const
Creates this directory.
FilePath path() const
Returns the directory path.
Definition dir.h:61
static Error setCurrent(const FilePath &path)
Sets the current working directory.
Dir(const String &path)
Constructs a Dir from a String path.
Definition dir.h:49
bool isEmpty() const
Returns true if the directory is empty.
Error mkpath() const
Creates this directory and all parent directories.
Dir()=default
Constructs a Dir with an empty path.
static Dir temp()
Returns a Dir for the system temp directory.
List< FilePath > entryList() const
Returns a list of all entries in the directory.
bool exists() const
Returns true if the directory exists.
Dir(const char *path)
Constructs a Dir from a C string path.
Definition dir.h:55
Dir(const FilePath &path)
Constructs a Dir for the given path.
Definition dir.h:43
List< FilePath > entryList(const String &filter) const
Returns a filtered list of entries in the directory.
static Dir current()
Returns a Dir for the current working directory.
Error removeRecursively() const
Removes this directory and all its contents.
static Dir home()
Returns a Dir for the user's home directory.
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Simple value type wrapping std::filesystem::path.
Definition filepath.h:27
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19