106 :
path((const unsigned char*)p, (const unsigned char*)p+strlen(p))
114 :
path(p, p+wcslen(p))
120 :
path((const unsigned char*)s.c_str(), (const unsigned char*)s.c_str()+s.length())
131 Path(
const std::wstring_view& s)
146 path = std::move(rhs.path);
161 return std::filesystem::path(
path);
180 std::string spath(
path.begin(),
path.end());
218 if(idxSlash == String::npos)
220 return path.substr(0, idxSlash);
226 if(idxSlash == String::npos)
228 return path.substr(idxSlash+1);
234 const size_t idxDot = filename.
string().find_last_of(
'.');
235 if(idxDot == String::npos)
237 return filename.
string().substr(0, idxDot);
242 const std::wstring_view filename{
path};
243 const size_t idxDot = filename.find_last_of(
'.');
244 if(idxDot == String::npos)
246 return filename.substr(idxDot);
262 if(rhs.
path.find((ret.
separator ==
'/')?
'\\' :
'/') != String::npos)
287 const size_t idx = ret.
path.rfind(other.
path);
288 if(idx == String::npos)
291 return path.substr(0, idx);
304 const size_t idxBackslash =
path.find(
'\\');
306 if(
path.find(
'/') != String::npos && idxBackslash != String::npos)
313 separator = (idxBackslash == String::npos)?
'/' :
'\\';
349 return m_StringHash(path.
string());
Path(std::wstring s)
Definition: path.h:125
std::string string8() const
Return a UTF-8 version of the path, in a human-readable but potentially lossy form.
Definition: path.h:175
void PrintToDebugOutput() const
Definition: path.h:297
wchar_t separator
Definition: path.h:325
Path(const Path &p)
Definition: path.h:93
Path(const std::wstring_view &s)
Definition: path.h:131
Path & operator=(Path &&rhs)
Definition: path.h:144
void DetectSeparator()
Definition: path.h:302
bool IsDirectory() const
Definition: path.h:208
bool operator!=(const Path &rhs) const
Definition: path.h:203
Path ChangeExtension(Path extension) const
Definition: path.h:249
Path(const wchar_t *p)
Definition: path.h:113
bool empty() const
Definition: path.h:151
bool operator==(const Path &rhs) const
Definition: path.h:198
Path(const char *p)
Definition: path.h:105
Path(Path &&p)
Definition: path.h:99
std::filesystem::path fileSystemPath() const
Definition: path.h:159
std::wstring String
Definition: path.h:86
Path Filename() const
Definition: path.h:223
Path operator/(const Path &rhs) const
Definition: path.h:254
static Status Validate(String::value_type c)
Definition: path.cpp:102
Path BeforeCommon(Path other) const
Return the path before the common part of both paths.
Definition: path.h:277
Path Basename() const
Definition: path.h:231
Path & operator=(const Path &rhs)
Definition: path.h:137
bool operator<(const Path &rhs) const
Definition: path.h:193
String path
Definition: path.h:316
std::wstring_view Extension() const
Definition: path.h:240
const String & string() const
Definition: path.h:164
Path Parent() const
Definition: path.h:215
Path()
Definition: path.h:88
Path(const std::string &s)
Definition: path.h:119
void debug_printf(const char *fmt,...)
write a formatted string to the debug channel.
Definition: debug.cpp:71
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
Definition: debug.h:271
const Status PATH_CHARACTER_ILLEGAL
Definition: path.h:56
const Status PATH_MIXED_SEPARATORS
Definition: path.h:59
const Status PATH_NOT_FOUND
Definition: path.h:58
const Status PATH_CHARACTER_UNSAFE
Definition: path.h:57
const Status OK
Definition: status.h:394
Definition: ShaderDefines.cpp:43
static std::wostream & operator<<(std::wostream &s, const Path &path)
Definition: path.h:328
bool path_is_subpath(const wchar_t *s1, const wchar_t *s2)
is s2 a subpath of s1, or vice versa? (equal counts as subpath)
Definition: path.cpp:54
static std::wistream & operator>>(std::wistream &s, Path &path)
Definition: path.h:334
const wchar_t * path_name_only(const wchar_t *path)
Get the path component of a path.
Definition: path.cpp:88
std::int64_t Status
Error handling system.
Definition: status.h:174
std::size_t operator()(const Path &path) const
Definition: path.h:347
std::hash< std::wstring > m_StringHash
Definition: path.h:353
std::string utf8_from_wstring(const std::wstring_view src, Status *err)
opposite of wstring_from_utf8
Definition: utf8.cpp:217
std::wstring wstring_from_utf8(const std::string_view src, Status *err)
convert UTF-8 to a wide string (UTF-16 or UCS-4, depending on the platform's wchar_t).
Definition: utf8.cpp:234