diff options
Diffstat (limited to 'source/core/slang-riff-file-system.cpp')
| -rw-r--r-- | source/core/slang-riff-file-system.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/source/core/slang-riff-file-system.cpp b/source/core/slang-riff-file-system.cpp index da73cb2a5..6fe8b0952 100644 --- a/source/core/slang-riff-file-system.cpp +++ b/source/core/slang-riff-file-system.cpp @@ -93,6 +93,23 @@ SlangResult RiffFileSystem::saveFile(const char* path, const void* data, size_t return SLANG_OK; } +SlangResult RiffFileSystem::saveFileBlob(const char* path, ISlangBlob* dataBlob) +{ + if (!dataBlob) + { + return SLANG_E_INVALID_ARG; + } + + if (m_compressionSystem) + { + return saveFile(path, dataBlob->getBufferPointer(), dataBlob->getBufferSize()); + } + else + { + return Super::saveFileBlob(path, dataBlob); + } +} + SlangResult RiffFileSystem::loadArchive(const void* archive, size_t archiveSizeInBytes) { // Load the riff @@ -189,6 +206,12 @@ SlangResult RiffFileSystem::loadArchive(const void* archive, size_t archiveSizeI default: return SLANG_FAIL; } + // If it's the root entry we can ignore (as already added) + if (dstEntry.m_canonicalPath == ".") + { + continue; + } + // Add to the list of entries m_entries.Add(dstEntry.m_canonicalPath, dstEntry); } @@ -214,10 +237,16 @@ SlangResult RiffFileSystem::storeArchive(bool blobOwnsContent, ISlangBlob** outB for (const auto& pair : m_entries) { - RiffContainer::ScopeChunk scopeData(&container, RiffContainer::Chunk::Kind::Data, RiffFileSystemBinary::kEntryFourCC); - const Entry* srcEntry = &pair.Value; + // Ignore the root entry + if (srcEntry->m_canonicalPath == toSlice(".")) + { + continue; + } + + RiffContainer::ScopeChunk scopeData(&container, RiffContainer::Chunk::Kind::Data, RiffFileSystemBinary::kEntryFourCC); + RiffFileSystemBinary::Entry dstEntry; dstEntry.uncompressedSize = 0; dstEntry.compressedSize = 0; |
