aboutsummaryrefslogtreecommitdiff
path: root/src/FileUtil.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-16 04:21:33 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-16 04:21:44 +0100
commit94caff5f66cacdd21e5a93cd3de9150a22eeaa3a (patch)
treeb3b7689e5a25c908369bb5fad5a59e085253b76e /src/FileUtil.cpp
parent28d6b571139998915bce147abb58617884431192 (diff)
Add support for sub project (unit tests)
Diffstat (limited to 'src/FileUtil.cpp')
-rw-r--r--src/FileUtil.cpp21
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