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>
31 USE_SYSTEM_PATHS = 1 << 0,
55 DONT_IGNORE_DOTS = 1 << 0,
65 REGULAR_FILES = 1 << 2,
84 DEFAULT_FLAGS = AFileListFlags::DIRS | AFileListFlags::REGULAR_FILES
128class API_AUI_CORE APath final:
public AString {
130 APath ensureSlashEnding()
const;
131 APath ensureNonSlashEnding()
const;
133 void removeBackSlashes();
137 struct _stat64 stat() const;
139 struct stat stat() const;
144 APath(AString&& other)
noexcept: AString(std::move(other)) {
147 APath(
const AString& other)
noexcept: AString(other) {
150 APath(
const char* utf8)
noexcept: AString(utf8) {
155 APath(
const char* utf8, std::size_t length)
noexcept: AString(utf8, utf8 + length) {
158 APath(
const char16_t * str)
noexcept: AString(str) {
162 APath(
const char16_t * str, std::size_t length)
noexcept: AString(str, str + length) {
244 [[nodiscard]] APath
file(
const AString& fileName)
const;
380 time_t fileModifyTime()
const;
381 size_t fileSize()
const;
393 const APath&
chmod(
int newMode)
const;
457 static void copy(
const APath& source,
const APath& destination);
464 static void move(
const APath& source,
const APath& destination);
526 explicit APathOwner(
APath mPath)
noexcept: mPath(std::move(mPath)) {}
530 mPath.removeFileRecursive();
535 operator const APath&()
const noexcept {
540 const APath& value()
const noexcept {
548inline APath operator""_path(
const char* str, std::size_t length) {
549 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:128
AString systemSlashDirection() const
Transforms this path to string with platform's native slashes.
bool isAbsolute() const
Checks whether path absolute or not.
bool isEffectivelyAccessible(AFileAccess flags) const noexcept
Return true if the current process has specified access flags to path.
const APath & removeFileRecursive() const
Delete files recursively, including itself.
const APath & removeDirContentsRecursive() const
Delete directory contents (recursively).
static void copy(const APath &source, const APath &destination)
Copy regular file.
const APath & makeDirs() const
Create all nonexistent folders on the path.
const APath & makeDir() const
Create folder.
DefaultPath
Definition APath.h:395
@ HOME
User home directory.
Definition APath.h:442
@ TEMP
Folder for temporary data.
Definition APath.h:431
@ APPDATA
Folder for application data.
Definition APath.h:411
APath filenameWithoutExtension() const
File name without extension.
const APath & removeFile() const
Delete file. Relevant for empty folders and regular files.
static APath getDefaultPath(DefaultPath path)
Get system's default folder.
AString relativelyTo(const APath &dir) const
Returns same path but without dir
const APath & chmod(int newMode) const
Changes mode (permissions) on file.
bool isRegularFileExists() const
static AVector< APath > find(const AString &filename, const AVector< APath > &locations, APathFinder flags=APathFinder::NONE)
APath absolute() const
Get the absolute (full) path to the file.
bool isDirectoryExists() const
APath operator/(const AString &filename) const
Path of the child element. Relevant only for folders.
Definition APath.h:492
const APath & touch() const
static void move(const APath &source, const APath &destination)
Move regular file.
bool isRelative() const
Checks whether path absolute or not.
Definition APath.h:376
static APath workingDir()
AString extension() const
File extension.
APath withoutUppermostFolder() const
Remove the uppermost folder from this path.
static const APath & processTemporaryDir()
Generates a unique, process-agnostic temporary directory in the system's temp directory.
static APath nextRandomTemporary()
Creates a path to non-existent random file in system temp directory.
APath file(const AString &fileName) const
Path of the child element. Relevant only for folders.
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...
APath extensionChanged(const AString &newExtension) const
Returns same path but with extension changed.
APath filename() const
File name.
A std::vector with AUI extensions.
Definition AVector.h:39
@ NONE
Definition AFloat.h:23
#define AUI_ENUM_FLAG(name)
Make a bitfield-style enum class.
Definition AEnumerate.h:227
Definition serializable.h:26
Forbids copy of your class.
Definition values.h:45