yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#include "slang-archive-file-system.h" 2 3#include "../core/slang-castable.h" 4#include "slang-blob.h" 5#include "slang-com-helper.h" 6#include "slang-com-ptr.h" 7#include "slang-io.h" 8#include "slang-riff-file-system.h" 9#include "slang-string-util.h" 10 11// Compression systems 12#include "slang-deflate-compression-system.h" 13#include "slang-lz4-compression-system.h" 14 15// Zip file system 16#include "slang-riff.h" 17#include "slang-zip-file-system.h" 18 19namespace Slang 20{ 21 22SlangResult loadArchiveFileSystem ( 23const void * data , 24size_t dataSizeInBytes , 25ComPtr < ISlangFileSystemExt >& outFileSystem ) 26{ 27ComPtr < ISlangMutableFileSystem > fileSystem ; 28if (ZipFileSystem ::isArchive (data ,dataSizeInBytes )) 29 { 30// It's a zip 31SLANG_RETURN_ON_FAIL (ZipFileSystem ::create (fileSystem )); 32 } 33else if (RiffFileSystem ::isArchive (data ,dataSizeInBytes )) 34 { 35// It's riff contained (Slang specific) 36fileSystem = new RiffFileSystem (nullptr ); 37 } 38else 39 { 40return SLANG_FAIL ; 41 } 42 43auto archiveFileSystem = as < IArchiveFileSystem > (fileSystem ); 44if (!archiveFileSystem ) 45 { 46return SLANG_FAIL ; 47 } 48 49SLANG_RETURN_ON_FAIL (archiveFileSystem -> loadArchive (data ,dataSizeInBytes )); 50 51outFileSystem = fileSystem ; 52return SLANG_OK ; 53} 54 55SlangResult createArchiveFileSystem ( 56SlangArchiveType type , 57ComPtr < ISlangMutableFileSystem >& outFileSystem ) 58{ 59switch (type ) 60 { 61case SLANG_ARCHIVE_TYPE_ZIP : 62 { 63return ZipFileSystem ::create (outFileSystem ); 64 } 65case SLANG_ARCHIVE_TYPE_RIFF : 66 { 67outFileSystem = new RiffFileSystem (nullptr ); 68return SLANG_OK ; 69 } 70case SLANG_ARCHIVE_TYPE_RIFF_DEFLATE : 71 { 72outFileSystem = new RiffFileSystem (DeflateCompressionSystem ::getSingleton ()); 73return SLANG_OK ; 74 } 75case SLANG_ARCHIVE_TYPE_RIFF_LZ4 : 76 { 77outFileSystem = new RiffFileSystem (LZ4CompressionSystem ::getSingleton ()); 78return SLANG_OK ; 79 } 80 } 81 82return SLANG_FAIL ; 83} 84 85}// namespace Slang