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-archive-file-system.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/core/slang-archive-file-system.cpp') diff --git a/source/core/slang-archive-file-system.cpp b/source/core/slang-archive-file-system.cpp index 0d998c849..98c995d23 100644 --- a/source/core/slang-archive-file-system.cpp +++ b/source/core/slang-archive-file-system.cpp @@ -11,6 +11,8 @@ #include "slang-riff-file-system.h" +#include "slang-destroyable.h" + // Compression systems #include "slang-deflate-compression-system.h" #include "slang-lz4-compression-system.h" @@ -130,9 +132,9 @@ SlangResult ImplicitDirectoryCollector::enumerate(FileSystemContentsCallBack cal return getDirectoryExists() ? SLANG_OK : SLANG_E_NOT_FOUND; } -SlangResult loadArchiveFileSystem(const void* data, size_t dataSizeInBytes, RefPtr& outFileSystem) +SlangResult loadArchiveFileSystem(const void* data, size_t dataSizeInBytes, ComPtr& outFileSystem) { - RefPtr fileSystem; + ComPtr fileSystem; if (ZipFileSystem::isArchive(data, dataSizeInBytes)) { // It's a zip @@ -147,13 +149,20 @@ SlangResult loadArchiveFileSystem(const void* data, size_t dataSizeInBytes, RefP { return SLANG_FAIL; } - SLANG_RETURN_ON_FAIL(fileSystem->loadArchive(data, dataSizeInBytes)); + + auto archiveFileSystem = as(fileSystem); + if (!archiveFileSystem) + { + return SLANG_FAIL; + } + + SLANG_RETURN_ON_FAIL(archiveFileSystem->loadArchive(data, dataSizeInBytes)); outFileSystem = fileSystem; return SLANG_OK; } -SlangResult createArchiveFileSystem(SlangArchiveType type, RefPtr& outFileSystem) +SlangResult createArchiveFileSystem(SlangArchiveType type, ComPtr& outFileSystem) { switch (type) { -- cgit v1.2.3