summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-io.cpp18
-rw-r--r--source/core/slang-io.h3
2 files changed, 20 insertions, 1 deletions
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.