VFS Regression and Accuracy Fixes (#776)
* Regression and Mode Fixes * Review Fixes * string_view correction * Add operator& for FileSys::Mode * Return std::string from SanitizePath * Farming Simulator Fix * Use != With mode operator&
This commit is contained in:
parent
3bf9b59021
commit
bd410ce242
5 changed files with 75 additions and 37 deletions
|
@ -826,7 +826,7 @@ std::string_view GetPathWithoutTop(std::string_view path) {
|
|||
}
|
||||
|
||||
while (path[0] == '\\' || path[0] == '/') {
|
||||
path.remove_suffix(1);
|
||||
path.remove_prefix(1);
|
||||
if (path.empty()) {
|
||||
return path;
|
||||
}
|
||||
|
@ -870,6 +870,15 @@ std::string_view RemoveTrailingSlash(std::string_view path) {
|
|||
return path;
|
||||
}
|
||||
|
||||
std::string SanitizePath(std::string_view path_) {
|
||||
std::string path(path_);
|
||||
std::replace(path.begin(), path.end(), '\\', '/');
|
||||
path.erase(std::unique(path.begin(), path.end(),
|
||||
[](char c1, char c2) { return c1 == '/' && c2 == '/'; }),
|
||||
path.end());
|
||||
return std::string(RemoveTrailingSlash(path));
|
||||
}
|
||||
|
||||
IOFile::IOFile() {}
|
||||
|
||||
IOFile::IOFile(const std::string& filename, const char openmode[], int flags) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue