summaryrefslogtreecommitdiffstats
path: root/source/core/slang-riff-file-system.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-10-03 21:09:16 -0400
committerGitHub <noreply@github.com>2022-10-03 18:09:16 -0700
commit0b51ea6bb54b1d8a12695ccc2c259fd591069791 (patch)
tree1ff0587eb1454891bf8421a86b95ed5e95419e75 /source/core/slang-riff-file-system.cpp
parentcc3548c92b1cf028b94d7a264a55df83e6d4d212 (diff)
IMutableFileSystem::saveFileBlob (#2427)
* #include an absolute path didn't work - because paths were taken to always be relative. * Remove ref count for Entry in RiffFileSystem. Free up backing Entry types (to work around Dictionary not doing this). * Some small improvements to RiffFileSystem. * Add testing for file systems. * Split out MemoryFileSystem. * Add some documentation around different FileSystems. * Small tiry up - removing unused headers, fixing some comments. Use StringBlob::moveCreate where appropriate. * Small improvement to MemoryFileSystem. Improve documentation comments a little. * Added PathKind * * Make MemoryFileSystem not have implicit directories * Make RelativeFileSystem only allow access to files in file system (kind of like chroot) * Added Path::simplifyAbsolute * Special handling for root of MemoryFileSystem * Improvements around paths for different impls * More improvements around RelativeFileSystem. Special case root handling. * Test archive serialization. Move testinf from compression. Remove the implicit directory test -> doesn't work on all file systems. * Small optimization that removes need for check for a parent unless an item is being *created*. * Add implicit path testing. * Add support for saveFileBlob Add testing for saveFileBlob * Removed TemporaryFileSet Added PlatformUtil::outputDebugMessage * Some small improvements around RelativeFileSystem. * Split out ImplicitDirectoryCollector so can use without requiring compression systems. * Split out StringSliceIndexMap into own files.
Diffstat (limited to 'source/core/slang-riff-file-system.cpp')
-rw-r--r--source/core/slang-riff-file-system.cpp33
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;