diff options
Diffstat (limited to 'src/FileUtil.cpp')
-rw-r--r-- | src/FileUtil.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index 899a1af..7248537 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -206,7 +206,26 @@ namespace sibs return Result<bool>::Ok(true); } + + Result<string> getRealPath(const char *path) + { + // TODO: Verify NULL can be passed as 'resolved' argument with different compilers and operating systems (clang, freebsd etc) + char *resolved = realpath(path, nullptr); + if(!resolved) + { + int error = errno; + string errMsg = "Failed to get real path for \""; + errMsg += path; + errMsg += "\": "; + errMsg += strerror(error); + return Result<string>::Err(errMsg, error); + } + + string result = resolved; + free(resolved); + return Result<string>::Ok(resolved); + } #else -#error "TODO: Implement createDirectoryRecursive on windows" +#error "TODO: Implement createDirectoryRecursive and getRealPath on windows" #endif }
\ No newline at end of file |