mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-15 11:25:36 +02:00
Always use correct path separator when normalizing
This commit is contained in:
parent
3abbc7e21f
commit
6bf1913a09
2 changed files with 16 additions and 5 deletions
|
@ -74,13 +74,23 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool
|
|||
|
||||
stdPath.lexically_normal();
|
||||
std::string ret(stdPath);
|
||||
for (int i = 0; i < ret.length(); i++) {
|
||||
char sep;
|
||||
char sep_alt;
|
||||
#ifdef __WINDOWS__
|
||||
if (!preferred) {
|
||||
for (int i = 0; i < ret.length(); i++) {
|
||||
if (ret[i] == '\\')
|
||||
ret[i] = '/';
|
||||
if (!preferred) {
|
||||
sep = '\\';
|
||||
sep_alt = '/';
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sep = '/';
|
||||
sep_alt = '\\';
|
||||
}
|
||||
|
||||
if (ret[i] == sep_alt)
|
||||
ret[i] = sep;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool
|
|||
if (!absolute) {
|
||||
nspath = [nspath stringByReplacingOccurrencesOfString:pwd withString:@""];
|
||||
}
|
||||
nspath = [nspath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
|
||||
return std::string(NSTOPATH(nspath));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue