summaryrefslogtreecommitdiffstats
path: root/source/core/slang-io.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-01-26 12:15:08 -0500
committerGitHub <noreply@github.com>2021-01-26 09:15:08 -0800
commit798d7731eca286df456bc2ec56c0695ba006b472 (patch)
tree37ced2db457a08aa8cfc81f19f18daf9ca26d3f2 /source/core/slang-io.cpp
parent00fad59d49d31538270b811903aeb449c97ca152 (diff)
Improved NVRTC location finding (#1674)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP more sophisticated mechanism to find NVRTC. * Improve nvrtc searching to include PATH. * Make getting an extension able to differentiate between no extension, and just a . * Add comment. * Add support for searching instance path. * Small improvements around scope and finding NVRTC. * Improve documentation around NVRTC loading.
Diffstat (limited to 'source/core/slang-io.cpp')
-rw-r--r--source/core/slang-io.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp
index d4f603109..0755a6a2f 100644
--- a/source/core/slang-io.cpp
+++ b/source/core/slang-io.cpp
@@ -175,9 +175,9 @@ namespace Slang
return sb.ProduceString();
}
- /* static */ Index Path::findLastSeparatorIndex(String const& path)
+ /* static */ Index Path::findLastSeparatorIndex(UnownedStringSlice const& path)
{
- const char* chars = path.getBuffer();
+ const char* chars = path.begin();
for (Index i = path.getLength() - 1; i >= 0; --i)
{
const char c = chars[i];
@@ -189,7 +189,7 @@ namespace Slang
return -1;
}
- /* static */Index Path::findExtIndex(String const& path)
+ /* static */Index Path::findExtIndex(UnownedStringSlice const& path)
{
const Index sepIndex = findLastSeparatorIndex(path);
@@ -238,13 +238,22 @@ namespace Slang
return path;
}
- String Path::getPathExt(const String& path)
+ UnownedStringSlice Path::getPathExt(const UnownedStringSlice& path)
{
const Index dotPos = findExtIndex(path);
if (dotPos >= 0)
+ {
return path.subString(dotPos + 1, path.getLength() - dotPos - 1);
+ }
else
- return "";
+ {
+ // Note that the caller can identify if path has no extension or just a .
+ // as if it's a dot a zero length slice is returned in path
+ // If it's not then a default slice is returned (which doesn't point into path).
+ //
+ // Granted this is a little obscure and perhaps should be improved.
+ return UnownedStringSlice();
+ }
}
String Path::getParentDirectory(const String& path)