diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-10-06 10:27:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-06 10:27:50 -0400 |
| commit | d1e740d8b25e03a734093bd84b792eaf969649d1 (patch) | |
| tree | bd19d69b54b00c9920dd6b02cc28d90dd8a639d5 /source/core/slang-implicit-directory-collector.cpp | |
| parent | cf34d2830a3103b2b47a4140d27d054b797705f2 (diff) | |
Improvements around absolute paths and file systems (#2433)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Add handling for root paths.
* Fixes around absolute paths.
* Add SimplifyStyle
* Remove unrequire include.
* Fix some details around RelativeFileSystem canonical paths.
* For MemoryFileSystem make sure "/a" and "a" maps to same canonical path.
* Add test for canonicalPath.
* Improve comment.
* More testing around canonical paths.
Diffstat (limited to 'source/core/slang-implicit-directory-collector.cpp')
| -rw-r--r-- | source/core/slang-implicit-directory-collector.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source/core/slang-implicit-directory-collector.cpp b/source/core/slang-implicit-directory-collector.cpp index 199fd6155..994ebd4d7 100644 --- a/source/core/slang-implicit-directory-collector.cpp +++ b/source/core/slang-implicit-directory-collector.cpp @@ -1,5 +1,7 @@ #include "slang-implicit-directory-collector.h" +#include "slang-io.h" + namespace Slang { @@ -8,13 +10,28 @@ namespace Slang ImplicitDirectoryCollector::ImplicitDirectoryCollector(const String& canonicalPath, bool directoryExists) : m_directoryExists(directoryExists) { - StringBuilder buffer; - if (canonicalPath != ".") + if (!isRootPath(canonicalPath.getUnownedSlice())) { + StringBuilder buffer; buffer << canonicalPath; buffer.append('/'); + m_prefix = buffer.ProduceString(); + } +} + +/* static */bool ImplicitDirectoryCollector::isRootPath(const UnownedStringSlice& path) +{ + const auto length = path.getLength(); + if (length == 0) + { + return true; + } + else if (length == 1) + { + const auto c = path[0]; + return c == '.' || Path::isDelimiter(c); } - m_prefix = buffer.ProduceString(); + return false; } void ImplicitDirectoryCollector::addRemainingPath(SlangPathType pathType, const UnownedStringSlice& inPathRemainder) |
