From f7db44a236bb867003395d1a91d6907901653528 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 28 Feb 2023 15:09:19 -0800 Subject: Add `SourceBlobWithPathInfoArtifactRepresentation`. (#2682) --- source/core/slang-io.cpp | 18 +++++++++++++++++- source/core/slang-io.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'source/core') diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index f2be44f4f..12cbb9ba8 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -286,7 +286,23 @@ namespace Slang // If ioBuilder doesn't end in a delimiter, add one if (!isDelimiter(ioBuilder[ioBuilder.getLength() - 1])) { - ioBuilder.append(kPathDelimiter); + // Determine the preferred delimiter to use based on existing path. + char preferedDelimiter = kOSCanonicalPathDelimiter; + if (kOSAlternativePathDelimiter != preferedDelimiter) + { + // If we found the existing path uses the alternative delimiter, we will + // use that instead of the canonical one. + constexpr Index kMaxDelimiterSearchRange = 32; + for (Index i = 0; i < Math::Min(kMaxDelimiterSearchRange, ioBuilder.getLength()); i++) + { + if (ioBuilder[i] == kOSAlternativePathDelimiter) + { + preferedDelimiter = kOSAlternativePathDelimiter; + break; + } + } + } + ioBuilder.append(preferedDelimiter); } // Check that path doesn't start with a path delimiter SLANG_ASSERT(!isDelimiter(path[0])); diff --git a/source/core/slang-io.h b/source/core/slang-io.h index e766359ff..60487e6af 100644 --- a/source/core/slang-io.h +++ b/source/core/slang-io.h @@ -96,8 +96,11 @@ namespace Slang #if SLANG_WINDOWS_FAMILY static const char kOSCanonicalPathDelimiter = '\\'; + static const char kOSAlternativePathDelimiter = '/'; + #else static const char kOSCanonicalPathDelimiter = '/'; + static const char kOSAlternativePathDelimiter = '/'; #endif /// Finds all all the items in the specified directory, that matches the pattern. -- cgit v1.2.3