summaryrefslogtreecommitdiffstats
path: root/source/core/slang-archive-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-archive-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-archive-file-system.cpp')
-rw-r--r--source/core/slang-archive-file-system.cpp107
1 files changed, 0 insertions, 107 deletions
diff --git a/source/core/slang-archive-file-system.cpp b/source/core/slang-archive-file-system.cpp
index 88093239b..63e1c0b01 100644
--- a/source/core/slang-archive-file-system.cpp
+++ b/source/core/slang-archive-file-system.cpp
@@ -23,113 +23,6 @@
namespace Slang
{
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! StringSliceIndexMap !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-StringSliceIndexMap::CountIndex StringSliceIndexMap::add(const UnownedStringSlice& key, Index valueIndex)
-{
- StringSlicePool::Handle handle;
- m_pool.findOrAdd(key, handle);
- const CountIndex countIndex = StringSlicePool::asIndex(handle);
- if (countIndex >= m_indexMap.getCount())
- {
- SLANG_ASSERT(countIndex == m_indexMap.getCount());
- m_indexMap.add(valueIndex);
- }
- else
- {
- m_indexMap[countIndex] = valueIndex;
- }
- return countIndex;
-}
-
-StringSliceIndexMap::CountIndex StringSliceIndexMap::findOrAdd(const UnownedStringSlice& key, Index defaultValueIndex)
-{
- StringSlicePool::Handle handle;
- m_pool.findOrAdd(key, handle);
- const CountIndex countIndex = StringSlicePool::asIndex(handle);
- if (countIndex >= m_indexMap.getCount())
- {
- SLANG_ASSERT(countIndex == m_indexMap.getCount());
- m_indexMap.add(defaultValueIndex);
- }
- return countIndex;
-}
-
-void StringSliceIndexMap::clear()
-{
- m_pool.clear();
- m_indexMap.clear();
-}
-
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ImplicitDirectoryCollector !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-ImplicitDirectoryCollector::ImplicitDirectoryCollector(const String& canonicalPath, bool directoryExists) :
- m_directoryExists(directoryExists)
-{
- StringBuilder buffer;
- if (canonicalPath != ".")
- {
- buffer << canonicalPath;
- buffer.append('/');
- }
- m_prefix = buffer.ProduceString();
-}
-
-void ImplicitDirectoryCollector::addRemainingPath(SlangPathType pathType, const UnownedStringSlice& inPathRemainder)
-{
- // If it's zero length we probably don't want to add it
- if (inPathRemainder.getLength() == 0)
- {
- // It's empty so don't add normal way - implies the directory exists
- m_directoryExists = true;
- return;
- }
-
- UnownedStringSlice pathRemainder(inPathRemainder);
- const Index slashIndex = pathRemainder.indexOf('/');
-
- // If we have a following / that means it's an implicit directory.
- if (slashIndex >= 0)
- {
- pathType = SLANG_PATH_TYPE_DIRECTORY;
- pathRemainder = UnownedStringSlice(pathRemainder.begin(), pathRemainder.begin() + slashIndex);
- }
-
- const Index countIndex = m_map.findOrAdd(pathRemainder, pathType);
- SLANG_UNUSED(countIndex);
- // Make sure they are the same type
- SLANG_ASSERT(SlangPathType(m_map.getValueAt(countIndex)) == pathType);
-}
-
-void ImplicitDirectoryCollector::addPath(SlangPathType pathType, const UnownedStringSlice& canonicalPath)
-{
- if (hasPrefix(canonicalPath))
- {
- UnownedStringSlice remainder = getRemainder(canonicalPath);
- addRemainingPath(pathType, remainder);
- }
-}
-
-SlangResult ImplicitDirectoryCollector::enumerate(FileSystemContentsCallBack callback, void* userData)
-{
- const Int count = m_map.getCount();
-
- for (Index i = 0; i < count; ++i)
- {
- const auto& pair = m_map.getAt(i);
-
- UnownedStringSlice path = pair.Key;
- SlangPathType pathType = SlangPathType(pair.Value);
-
- // Note *is* 0 terminated in the pool
- // Let's check tho
- SLANG_ASSERT(path.begin()[path.getLength()] == 0);
- callback(pathType, path.begin(), userData);
- }
-
- return getDirectoryExists() ? SLANG_OK : SLANG_E_NOT_FOUND;
-}
-
SlangResult loadArchiveFileSystem(const void* data, size_t dataSizeInBytes, ComPtr<ISlangFileSystemExt>& outFileSystem)
{
ComPtr<ISlangMutableFileSystem> fileSystem;