96 : path((const unsigned char*)p, (const unsigned char*)p+strlen(p))
104 : path(p, p+wcslen(p))
110 : path((const unsigned char*)s.c_str(), (const unsigned char*)s.c_str()+s.length())
140 std::filesystem::path fileSystemPath()
const 142 return std::filesystem::path(path);
162 std::string spath(path.begin(), path.end());
177 return path < rhs.
path;
182 return path == rhs.
path;
194 return path[path.length()-1] == separator;
199 const size_t idxSlash = path.find_last_of(separator);
200 if(idxSlash == String::npos)
202 return path.substr(0, idxSlash);
207 const size_t idxSlash = path.find_last_of(separator);
208 if(idxSlash == String::npos)
210 return path.substr(idxSlash+1);
215 const Path filename = Filename();
216 const size_t idxDot = filename.
string().find_last_of(
'.');
217 if(idxDot == String::npos)
219 return filename.
string().substr(0, idxDot);
225 const Path filename = Filename();
226 const size_t idxDot = filename.
string().find_last_of(
'.');
227 if(idxDot == String::npos)
229 return filename.
string().substr(idxDot);
234 return Parent() /
Path(Basename().
string() + extension.
string());
245 if(rhs.
path.find((ret.
separator ==
'/')?
'\\' :
'/') != String::npos)
247 PrintToDebugOutput();
270 const size_t idx = ret.
path.rfind(other.
path);
271 if(idx == String::npos)
274 return path.substr(0, idx);
277 static Status Validate(String::value_type c);
282 debug_printf(
"Path %s, separator %c\n", string8().c_str(), (
char)separator);
287 const size_t idxBackslash = path.find(
'\\');
289 if(path.find(
'/') != String::npos && idxBackslash != String::npos)
291 PrintToDebugOutput();
296 separator = (idxBackslash == String::npos)?
'/' :
'\\';
308 wchar_t separator = L
'/';
332 return m_StringHash(path.
string());
340 #endif // #ifndef INCLUDED_PATH Path operator/(Path rhs) const
Definition: path.h:237
void DetectSeparator()
Definition: path.h:285
std::hash< std::wstring > m_StringHash
Definition: path.h:336
const String & string() const
Definition: path.h:146
const Status OK
Definition: status.h:384
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
Definition: utf8.cpp:212
const Status PATH_CHARACTER_ILLEGAL
Definition: path.h:52
bool operator==(const FCDJointWeightPair &a, const FCDJointWeightPair &b)
Definition: GeomReindex.cpp:59
Path(const char *p)
Definition: path.h:95
Definition: ShaderDefines.cpp:30
Path ChangeExtension(Path extension) const
Definition: path.h:232
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:51
Path Filename() const
Definition: path.h:205
const Status PATH_CHARACTER_UNSAFE
Definition: path.h:53
wchar_t separator
Definition: path.h:308
std::size_t operator()(const Path &path) const
Definition: path.h:330
bool operator!=(const Path &rhs) const
Definition: path.h:185
Path Basename() const
Definition: path.h:213
String path
Definition: path.h:299
Path(const wchar_t *p)
Definition: path.h:103
const wchar_t * path_name_only(const wchar_t *path)
Get the path component of a path.
Definition: path.cpp:85
Path Extension() const
Definition: path.h:223
bool empty() const
Definition: path.h:128
i64 Status
Error handling system.
Definition: status.h:169
bool operator==(const Path &rhs) const
Definition: path.h:180
const Status PATH_MIXED_SEPARATORS
Definition: path.h:55
void debug_printf(const char *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
Definition: debug.cpp:148
Path(const std::wstring &s)
Definition: path.h:115
Path(const std::string &s)
Definition: path.h:109
Path BeforeCommon(Path other) const
Return the path before the common part of both paths.
Definition: path.h:260
std::wstring String
Definition: path.h:82
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
Definition: debug.h:339
std::wstring wstring_from_utf8(const std::string &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:229
Introduction
Definition: debug.h:407
const char * extension
Definition: mongoose.cpp:1741
static std::wistream & operator>>(std::wistream &s, Path &path)
Definition: path.h:317
Path(const Path &p)
Definition: path.h:89
bool IsDirectory() const
Definition: path.h:190
Path & operator=(const Path &rhs)
Definition: path.h:121
void PrintToDebugOutput() const
Definition: path.h:280
Path Parent() const
Definition: path.h:197
Path()
Definition: path.h:84
std::string string8() const
Return a UTF-8 version of the path, in a human-readable but potentially lossy form.
Definition: path.h:157
static std::wostream & operator<<(std::wostream &s, const Path &path)
Definition: path.h:311
const Status PATH_NOT_FOUND
Definition: path.h:54
bool operator<(const Path &rhs) const
Definition: path.h:175