diff options
Diffstat (limited to 'src/FileUtil.cpp')
-rw-r--r-- | src/FileUtil.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index db68bb4..e53aa85 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -308,8 +308,6 @@ namespace sibs } #else -#pragma comment(lib, "Userenv.lib") - Result<FileString> getHomeDir() { BOOL ret; @@ -410,4 +408,26 @@ namespace sibs return Result<FileString>::Ok(fullPath); } #endif -}
\ No newline at end of file + + // TODO: Support better path equality check. For example if path contains several slashes in a row: /home/userName/.sibs//lib////libraryName + // then it should equal: /home/userName/.sibs/lib/libraryName + // Maybe check with OS operation if they refer to the same inode? + bool pathEquals(const std::string &path, const std::string &otherPath) + { + if(path.size() != otherPath.size()) + return false; + + size_t size = path.size(); + for(size_t i = 0; i < size; ++i) + { + char c = path[i]; + char otherC = otherPath[i]; + if(c == '\\') c = '/'; + if(otherC == '\\') otherC = '/'; + if(c != otherC) + return false; + } + + return true; + } +} |