diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-08-15 18:38:59 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-08-15 15:38:59 -0700 |
| commit | 77fe3dd74446fb07dd0de31114f7033f111ef868 (patch) | |
| tree | 835044f955d4f2afc02894448864321fca3344df /source/slang/slang-file-system.cpp | |
| parent | 44506607215247be4bf33c1a629bf39971bc966f (diff) | |
A more convoluted #pragma once file identity test, using relative paths. (#1021)
* A more convoluted #pragma once file identity test, using relative paths.
* Fix bug with passing - to slang as a command line option causes a crash.
Ability to set file-system to use on command line.
#pragma once tests try with 'normal' and 'read-file' only versions
* OSFileSystem -> OSFileSystemExt
LoadFileOSFileSystem -> OSFileSystem
Implemented OSFileSystem like OSFileSystemExt as as singleton.
Fixes to comments.
Diffstat (limited to 'source/slang/slang-file-system.cpp')
| -rw-r--r-- | source/slang/slang-file-system.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/slang/slang-file-system.cpp b/source/slang/slang-file-system.cpp index f8c423e84..975d35f2c 100644 --- a/source/slang/slang-file-system.cpp +++ b/source/slang/slang-file-system.cpp @@ -36,9 +36,18 @@ static SlangResult _calcCombinedPath(SlangPathType fromPathType, const char* fro return SLANG_OK; } -/* !!!!!!!!!!!!!!!!!!!!!!!!!! IncludeFileSystem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! OSFileSystem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ -/* static */OSFileSystem OSFileSystem::s_singleton; +/* static */OSFileSystem OSFileSystem::s_singleton; + +ISlangUnknown* OSFileSystem::getInterface(const Guid& guid) +{ + return (guid == IID_ISlangUnknown || guid == IID_ISlangFileSystem ) ? static_cast<ISlangFileSystem*>(this) : nullptr; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!! OSFileSystemExt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +/* static */OSFileSystemExt OSFileSystemExt::s_singleton; template <typename T> static ISlangFileSystemExt* _getInterface(T* ptr, const Guid& guid) @@ -46,7 +55,7 @@ static ISlangFileSystemExt* _getInterface(T* ptr, const Guid& guid) return (guid == IID_ISlangUnknown || guid == IID_ISlangFileSystem || guid == IID_ISlangFileSystemExt) ? static_cast<ISlangFileSystemExt*>(ptr) : nullptr; } -ISlangUnknown* OSFileSystem::getInterface(const Guid& guid) +ISlangUnknown* OSFileSystemExt::getInterface(const Guid& guid) { return _getInterface(this, guid); } @@ -62,13 +71,13 @@ static String _fixPathDelimiters(const char* pathIn) #endif } -SlangResult OSFileSystem::getFileUniqueIdentity(const char* pathIn, ISlangBlob** outUniqueIdentity) +SlangResult OSFileSystemExt::getFileUniqueIdentity(const char* pathIn, ISlangBlob** outUniqueIdentity) { // By default we use the canonical path to uniquely identify a file return getCanonicalPath(pathIn, outUniqueIdentity); } -SlangResult OSFileSystem::getCanonicalPath(const char* path, ISlangBlob** outCanonicalPath) +SlangResult OSFileSystemExt::getCanonicalPath(const char* path, ISlangBlob** outCanonicalPath) { String canonicalPath; SLANG_RETURN_ON_FAIL(Path::getCanonical(_fixPathDelimiters(path), canonicalPath)); @@ -76,25 +85,25 @@ SlangResult OSFileSystem::getCanonicalPath(const char* path, ISlangBlob** outCan return SLANG_OK; } -SlangResult OSFileSystem::getSimplifiedPath(const char* pathIn, ISlangBlob** outSimplifiedPath) +SlangResult OSFileSystemExt::getSimplifiedPath(const char* pathIn, ISlangBlob** outSimplifiedPath) { String simplifiedPath = Path::simplify(_fixPathDelimiters(pathIn)); *outSimplifiedPath = StringUtil::createStringBlob(simplifiedPath).detach(); return SLANG_OK; } -SlangResult OSFileSystem::calcCombinedPath(SlangPathType fromPathType, const char* fromPath, const char* path, ISlangBlob** pathOut) +SlangResult OSFileSystemExt::calcCombinedPath(SlangPathType fromPathType, const char* fromPath, const char* path, ISlangBlob** pathOut) { // Don't need to fix delimiters - because combine path handles both path delimiter types return _calcCombinedPath(fromPathType, fromPath, path, pathOut); } -SlangResult SLANG_MCALL OSFileSystem::getPathType(const char* pathIn, SlangPathType* pathTypeOut) +SlangResult SLANG_MCALL OSFileSystemExt::getPathType(const char* pathIn, SlangPathType* pathTypeOut) { return Path::getPathType(_fixPathDelimiters(pathIn), pathTypeOut); } -SlangResult OSFileSystem::loadFile(char const* pathIn, ISlangBlob** outBlob) +SlangResult OSFileSystemExt::loadFile(char const* pathIn, ISlangBlob** outBlob) { // Default implementation that uses the `core` libraries facilities for talking to the OS filesystem. // |
