mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-15 19:35: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();
|
stdPath.lexically_normal();
|
||||||
std::string ret(stdPath);
|
std::string ret(stdPath);
|
||||||
|
for (int i = 0; i < ret.length(); i++) {
|
||||||
|
char sep;
|
||||||
|
char sep_alt;
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
if (!preferred) {
|
if (!preferred) {
|
||||||
for (int i = 0; i < ret.length(); i++) {
|
sep = '\\';
|
||||||
if (ret[i] == '\\')
|
sep_alt = '/';
|
||||||
ret[i] = '/';
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
sep = '/';
|
||||||
|
sep_alt = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret[i] == sep_alt)
|
||||||
|
ret[i] = sep;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool
|
||||||
if (!absolute) {
|
if (!absolute) {
|
||||||
nspath = [nspath stringByReplacingOccurrencesOfString:pwd withString:@""];
|
nspath = [nspath stringByReplacingOccurrencesOfString:pwd withString:@""];
|
||||||
}
|
}
|
||||||
|
nspath = [nspath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
|
||||||
return std::string(NSTOPATH(nspath));
|
return std::string(NSTOPATH(nspath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue