summaryrefslogtreecommitdiffstats
path: root/source/slang/default-file-system.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-10-22 20:48:59 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-10-22 17:48:59 -0700
commit2700a89f8c80620f1d523563cc80ec0da39e9761 (patch)
tree375f29ffcc5ad4e0ced42b51f1cc214f7b37374a /source/slang/default-file-system.cpp
parentcda9c3b1a712715209a3f4ba155c1425898334cb (diff)
Fix problem with __import not working (#688)
* Added getPathType to ISlangFileSystemExt. This is needed so that when searching for a file it's existance can be tested without loading the file. On some platforms a getCanonicalPath can do this - but depending on how getCanonicalPath is implemented, it may not do. This test is made after the relative path is produced before finding the canonical path. * Test for importing along search path. * Added comment to explain the issue around WrapFileSystem impl of getPathType. * Make search path use / not \
Diffstat (limited to 'source/slang/default-file-system.cpp')
-rw-r--r--source/slang/default-file-system.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/source/slang/default-file-system.cpp b/source/slang/default-file-system.cpp
index be171d37c..f9c66b7d7 100644
--- a/source/slang/default-file-system.cpp
+++ b/source/slang/default-file-system.cpp
@@ -51,10 +51,16 @@ SlangResult DefaultFileSystem::calcRelativePath(SlangPathType fromPathType, cons
return SLANG_OK;
}
+SlangResult SLANG_MCALL DefaultFileSystem::getPathType(
+ const char* path,
+ SlangPathType* pathTypeOut)
+{
+ return Path::GetPathType(path, pathTypeOut);
+}
+
SlangResult DefaultFileSystem::loadFile(char const* path, ISlangBlob** outBlob)
{
- // Default implementation that uses the `core`
- // libraries facilities for talking to the OS filesystem.
+ // Default implementation that uses the `core` libraries facilities for talking to the OS filesystem.
//
// TODO: we might want to conditionally compile these in, so that
// a user could create a build of Slang that doesn't include any OS
@@ -93,7 +99,7 @@ SlangResult WrapFileSystem::loadFile(char const* path, ISlangBlob** outBlob)
SlangResult WrapFileSystem::getCanoncialPath(const char* path, ISlangBlob** canonicalPathOut)
{
- // This isn't a very good 'canonical path' because the same file might be referenced
+ // This isn't a very good 'canonical path' because the same file might be referenced
// multiple ways - for example by using relative paths.
// But it's simple and matches slangs previous behavior.
String canonicalPath(path);
@@ -107,4 +113,15 @@ SlangResult WrapFileSystem::calcRelativePath(SlangPathType fromPathType, const c
return DefaultFileSystem::getSingleton()->calcRelativePath(fromPathType, fromPath, path, pathOut);
}
+SlangResult WrapFileSystem::getPathType(const char* path, SlangPathType* pathTypeOut)
+{
+ // TODO:
+ // This might be undesirable in the longer term because it means that ISlangFileSystem will not be used
+ // to test file existence - but the file system will be.
+ //
+ // It would probably be better to use some kind of cache that uses 'loadFile' to load files, but also
+ // to test for existence.
+ return DefaultFileSystem::getSingleton()->getPathType(path, pathTypeOut);
+}
+
} \ No newline at end of file