From cc0b81350f6b681c794b4ac7c0f3b5fe73cb19eb Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 1 Sep 2022 16:39:08 -0400 Subject: Make ISlangFileSystem derive from ICastable (#2386) * #include an absolute path didn't work - because paths were taken to always be relative. * Make ISlangFileSystem derive from ICastable. * Make ArchiveFileSystem into an interface Make file systems atomically reference counted. * Small fix. * Some small fixes to work around issues of ICastable on ISlangFileSystem * Use ISlangFileSystem derived type instead of IArchiveFileSystem. Can always get other interface with castAs. * Some small fixes around change of interface returned from archive type functions. * Remove CacheFileSystem member from linkage. Can access easily from m_fileSystemExt if necessary with as cast. * Fix RiffFileSystem casting issue. * Add a check around CacheFileSystem. --- source/core/slang-riff-file-system.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'source/core/slang-riff-file-system.cpp') diff --git a/source/core/slang-riff-file-system.cpp b/source/core/slang-riff-file-system.cpp index e916cf689..a8e0f2073 100644 --- a/source/core/slang-riff-file-system.cpp +++ b/source/core/slang-riff-file-system.cpp @@ -21,9 +21,36 @@ RiffFileSystem::RiffFileSystem(ICompressionSystem* compressionSystem): { } -ISlangMutableFileSystem* RiffFileSystem::getInterface(const Guid& guid) +void* RiffFileSystem::getInterface(const Guid& guid) { - return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid() || guid == ISlangFileSystemExt::getTypeGuid() || guid == ISlangMutableFileSystem::getTypeGuid()) ? static_cast(this) : nullptr; + if ( guid == ISlangUnknown::getTypeGuid() || + guid == ISlangCastable::getTypeGuid() || + guid == ISlangFileSystem::getTypeGuid() || + guid == ISlangFileSystemExt::getTypeGuid() || + guid == ISlangMutableFileSystem::getTypeGuid()) + { + return static_cast(this); + } + else if (guid == IArchiveFileSystem::getTypeGuid()) + { + return static_cast(this); + } + return nullptr; +} + +void* RiffFileSystem::getObject(const Guid& guid) +{ + SLANG_UNUSED(guid); + return nullptr; +} + +void* RiffFileSystem::castAs(const Guid& guid) +{ + if (auto ptr = getInterface(guid)) + { + return ptr; + } + return getObject(guid); } SlangResult RiffFileSystem::_calcCanonicalPath(const char* path, StringBuilder& out) -- cgit v1.2.3