summaryrefslogtreecommitdiffstats
path: root/source/core/slang-io.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-22 07:14:55 -0800
committerGitHub <noreply@github.com>2024-02-22 07:14:55 -0800
commit8ec5b3e6ef2e7e5c3adaa5accb375676b1c09ff0 (patch)
treef3023dc51c32d74d1b5dd4701f5535c8227fe17e /source/core/slang-io.cpp
parentc5ac7dee8a47dcb168a6556d2e8cdb8d2fe09a37 (diff)
Add API for querying and reusing precompiled binary modules. (#3614)
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