From 94caff5f66cacdd21e5a93cd3de9150a22eeaa3a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Dec 2017 04:21:33 +0100 Subject: Add support for sub project (unit tests) --- src/FileUtil.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/FileUtil.cpp') 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::Ok(true); } + + Result 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::Err(errMsg, error); + } + + string result = resolved; + free(resolved); + return Result::Ok(resolved); + } #else -#error "TODO: Implement createDirectoryRecursive on windows" +#error "TODO: Implement createDirectoryRecursive and getRealPath on windows" #endif } \ No newline at end of file -- cgit v1.2.3