diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2024-08-07 17:53:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-07 08:53:33 -0700 |
| commit | 9b580e58417a77109617804362be872f05885f23 (patch) | |
| tree | a2af2c0da8036913ca0f3f5515bb81e7c88ec57f /source/core | |
| parent | 2f2ae8c31490ab01ce0d0cc76d5d7fcf1d21efe7 (diff) | |
Reduce dependency on std library (#4785)
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-io.cpp | 14 | ||||
| -rw-r--r-- | source/core/slang-io.h | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index f5850a5b6..54a8fc79e 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -562,6 +562,13 @@ namespace Slang #endif } + bool Path::createDirectoryRecursive(const String& path) + { + std::error_code ec; + std::filesystem::create_directories(path.getBuffer(), ec); + return !ec; + } + /* static */SlangResult Path::getPathType(const String& path, SlangPathType* pathTypeOut) { #ifdef _WIN32 @@ -661,6 +668,13 @@ namespace Slang #endif } + String Path::getCurrentPath() + { + Slang::String path; + getCanonical(".", path); + return path; + } + String Path::getRelativePath(String base, String path) { std::filesystem::path p1(base.getBuffer()); diff --git a/source/core/slang-io.h b/source/core/slang-io.h index fcacee1db..763907c98 100644 --- a/source/core/slang-io.h +++ b/source/core/slang-io.h @@ -145,6 +145,7 @@ namespace Slang static void append(StringBuilder& ioBuilder, const UnownedStringSlice& path); static bool createDirectory(const String& path); + static bool createDirectoryRecursive(const String& path); /// Accept either style of delimiter SLANG_FORCE_INLINE static bool isDelimiter(char c) { return c == '/' || c == '\\'; } @@ -197,6 +198,10 @@ namespace Slang /// @return SLANG_OK on success static SlangResult getCanonical(const String& path, String& outCanonicalPath); + /// Returns the current working directory + /// @return The path in platform native format. Returns empty string if failed. + static String getCurrentPath(); + /// Returns the executable path /// @return The path in platform native format. Returns empty string if failed. static String getExecutablePath(); |
