summaryrefslogtreecommitdiffstats
path: root/source/core/slang-io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-io.cpp')
-rw-r--r--source/core/slang-io.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp
index c546dd059..c08f499b9 100644
--- a/source/core/slang-io.cpp
+++ b/source/core/slang-io.cpp
@@ -36,6 +36,7 @@
#include <limits.h> /* PATH_MAX */
#include <stdio.h>
#include <stdlib.h>
+#include <filesystem>
namespace Slang
{
@@ -660,6 +661,17 @@ namespace Slang
#endif
}
+ String Path::getRelativePath(String base, String path)
+ {
+ std::filesystem::path p1(base.getBuffer());
+ std::filesystem::path p2(path.getBuffer());
+ std::error_code ec;
+ auto result = std::filesystem::relative(p2, p1, ec);
+ if (ec)
+ return path;
+ return String(UnownedStringSlice(result.generic_u8string().c_str()));
+ }
+
SlangResult Path::remove(const String& path)
{
#ifdef _WIN32