15#include "AUI/Reflect/AEnumerate.h"
16#include <AUI/Common/AString.h>
17#include <AUI/Common/ADeque.h>
18#include <AUI/Common/AVector.h>
19#include <AUI/Traits/serializable.h>
25AUI_ENUM_FLAG(APathFinder) {
31 USE_SYSTEM_PATHS = 1 << 0,
48AUI_ENUM_FLAG(AFileListFlags) {
55 DONT_IGNORE_DOTS = 1 << 0,
65 REGULAR_FILES = 1 << 2,
84 DEFAULT_FLAGS = AFileListFlags::DIRS | AFileListFlags::REGULAR_FILES
107class API_AUI_CORE APath final:
public AString {
109 APath ensureSlashEnding()
const;
110 APath ensureNonSlashEnding()
const;
112 void removeBackSlashes();
116 struct _stat64 stat() const;
118 struct stat stat() const;
123 APath(AString&& other)
noexcept: AString(std::move(other)) {
126 APath(
const AString& other)
noexcept: AString(other) {
129 APath(
const char* utf8)
noexcept: AString(utf8) {
134 APath(
const char* utf8, std::size_t length)
noexcept: AString(utf8, utf8 + length) {
137 APath(
const char16_t * str)
noexcept: AString(str) {
141 APath(
const char16_t * str, std::size_t length)
noexcept: AString(str, str + length) {
149 const APath&
touch()
const;
175 [[nodiscard]] APath
parent()
const;
190 [[nodiscard]] APath
file(
const AString& fileName)
const;
198 [[nodiscard]] APath
filename()
const;
292 time_t fileModifyTime()
const;
293 size_t fileSize()
const;
295 const APath& chmod(
int newMode)
const;
330 static APath getDefaultPath(DefaultPath path);
337 static void copy(
const APath& source,
const APath& destination);
344 static void move(
const APath& source,
const APath& destination);
349 static APath workingDir();
378inline APath operator""_path(
const char* str, std::size_t length) {
379 return APath(str, length);
A std::deque with AUI extensions.
Definition ADeque.h:27
An add-on to AString with functions for working with the path.
Definition APath.h:107
AString systemSlashDirection() const
Definition APath.cpp:434
bool isAbsolute() const
Checks whether path absolute or not.
Definition APath.cpp:247
const APath & removeFileRecursive() const
Delete files recursively. Relevant for folders.
Definition APath.cpp:124
const APath & makeDirs() const
Create all nonexistent folders on the path.
Definition APath.cpp:234
const APath & makeDir() const
Create folder.
Definition APath.cpp:222
DefaultPath
Definition APath.h:297
@ HOME
User home directory.
Definition APath.h:322
@ TEMP
Folder for temporary data.
Definition APath.h:314
@ APPDATA
Folder for application data.
Definition APath.h:305
APath filenameWithoutExtension() const
File name without extension.
Definition APath.cpp:54
const APath & removeFile() const
Delete file. Relevant for empty folders and regular files.
Definition APath.cpp:103
AString relativelyTo(const APath &dir) const
Returns same path but without folder
Definition APath.cpp:81
bool exists() const
Definition APath.cpp:92
bool isRegularFileExists() const
Definition APath.cpp:95
APath absolute() const
Get the absolute (full) path to the file.
Definition APath.cpp:195
bool isDirectoryExists() const
Definition APath.cpp:99
APath operator/(const AString &filename) const
Path of the child element. Relevant only for folders.
Definition APath.h:371
const APath & touch() const
Definition APath.cpp:444
APath parent() const
Definition APath.cpp:38
bool isRelative() const
Checks whether path absolute or not.
Definition APath.h:288
APath withoutUppermostFolder() const
Remove the uppermost folder from this path.
Definition APath.cpp:312
APath file(const AString &fileName) const
Path of the child element. Relevant only for folders.
Definition APath.cpp:63
ADeque< APath > listDir(AFileListFlags f=AFileListFlags::DEFAULT_FLAGS) const
Get list of (by default) direct children of this folder. This function outputs paths including the pa...
Definition APath.cpp:135
APath extensionChanged(const AString &newExtension) const
Returns same path but with extension changed.
Definition APath.cpp:461
APath filename() const
File name.
Definition APath.cpp:46
Represents a Unicode character string.
Definition AString.h:37
A std::vector with AUI extensions.
Definition AVector.h:39
@ NONE
Definition AFloat.h:23
Definition serializable.h:26