Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/lib/path.h
Show All 31 Lines | |||||
// must hold at least that much. | // must hold at least that much. | ||||
// - unless otherwise mentioned, all functions are intended to work with | // - unless otherwise mentioned, all functions are intended to work with | ||||
// native and VFS paths. | // native and VFS paths. | ||||
// when reading, both '/' and SYS_DIR_SEP are accepted; '/' is written. | // when reading, both '/' and SYS_DIR_SEP are accepted; '/' is written. | ||||
#ifndef INCLUDED_PATH | #ifndef INCLUDED_PATH | ||||
#define INCLUDED_PATH | #define INCLUDED_PATH | ||||
#include "lib/sysdep/os.h" | |||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
#if OS_WIN | |||||
#include <filesystem> | |||||
#endif | |||||
#include <functional> | #include <functional> | ||||
namespace ERR | namespace ERR | ||||
{ | { | ||||
const Status PATH_CHARACTER_ILLEGAL = -100300; | const Status PATH_CHARACTER_ILLEGAL = -100300; | ||||
const Status PATH_CHARACTER_UNSAFE = -100301; | const Status PATH_CHARACTER_UNSAFE = -100301; | ||||
const Status PATH_NOT_FOUND = -100302; | const Status PATH_NOT_FOUND = -100302; | ||||
const Status PATH_MIXED_SEPARATORS = -100303; | const Status PATH_MIXED_SEPARATORS = -100303; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | Path& operator=(const Path& rhs) | ||||
return *this; | return *this; | ||||
} | } | ||||
bool empty() const | bool empty() const | ||||
{ | { | ||||
return path.empty(); | return path.empty(); | ||||
} | } | ||||
// TODO: This macro should be removed later when macOS supports std::filesystem. | |||||
// Currently it does in more recent SDKs, but it also causes a slowdown on | |||||
// OpenGL. See #6193. | |||||
#if OS_WIN | |||||
/** | |||||
* @returns a STL version of the path. | |||||
*/ | |||||
std::filesystem::path fileSystemPath() const | |||||
{ | |||||
return std::filesystem::path(path); | |||||
} | |||||
#endif | |||||
const String& string() const | const String& string() const | ||||
{ | { | ||||
return path; | return path; | ||||
} | } | ||||
/** | /** | ||||
* Return a UTF-8 version of the path, in a human-readable but potentially | * Return a UTF-8 version of the path, in a human-readable but potentially | ||||
* lossy form. It is *not* safe to take this string and construct a new | * lossy form. It is *not* safe to take this string and construct a new | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator