From 723796a0a0fed8e5b8c3222b1c90443189113098 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 11 Jan 2021 15:24:11 -0500 Subject: LZ4 compression support (#1654) * #include an absolute path didn't work - because paths were taken to always be relative. * Testing out use of lz4. * Added ICompressionSystem, and LZ4 implementation. * Add support for deflate compression. Simplify compression interface - to make more easily work across apis. * WIP on CompressedFileSystem. * ImplicitDirectoryCollector * SubStringIndexMap - > StringSliceIndexMap. * WIP save stdlib in different containers. * Support for different archive types for stdlib. * Fix project. * CompressedFileSystem -> ArchiveFileSystem. Added CompressionSystemType::None * Added ArchiveFileSystem * Fix problem RiffFileSystem load withoug compression system. * Test archive types. Improve diagnostic message. * Fix typo in testing file system archives. * Split out archive detection. * Fix gcc warning issue. * Fix warning. * RiffArchiveFileSystem -> RiffFileSystem Co-authored-by: Tim Foley --- source/core/slang-io.cpp | 54 +++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'source/core/slang-io.cpp') diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 2e2ec3d8b..d4f603109 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -3,6 +3,8 @@ #include "../../slang-com-helper.h" +#include "slang-string-util.h" + #ifndef __STDC__ # define __STDC__ 1 #endif @@ -400,52 +402,56 @@ namespace Slang return false; } - /* static */String Path::simplify(const UnownedStringSlice& path) + /* static */void Path::simplify(List& ioSplit) { - List splitPath; - split(path, splitPath); - // Strictly speaking we could do something about case on platforms like window, but here we won't worry about that - for (Index i = 0; i < splitPath.getCount(); i++) + for (Index i = 0; i < ioSplit.getCount(); i++) { - const UnownedStringSlice& cur = splitPath[i]; - if (cur == "." && splitPath.getCount() > 1) + const UnownedStringSlice& cur = ioSplit[i]; + if (cur == "." && ioSplit.getCount() > 1) { // Just remove it - splitPath.removeAt(i); + ioSplit.removeAt(i); i--; } else if (cur == ".." && i > 0) { // Can we remove this and the one before ? - UnownedStringSlice& before = splitPath[i - 1]; + UnownedStringSlice& before = ioSplit[i - 1]; if (before == ".." || (i == 1 && isDriveSpecification(before))) { - // Can't do it + // Can't do it, but we allow relative, so just leave for now continue; } - splitPath.removeRange(i - 1, 2); + ioSplit.removeRange(i - 1, 2); i -= 2; } } + } - // If its empty it must be . - if (splitPath.getCount() == 0) + /* static */void Path::join(const UnownedStringSlice* slices, Index count, StringBuilder& out) + { + out.Clear(); + + if (count == 0) { - splitPath.add(UnownedStringSlice::fromLiteral(".")); + out << "."; + return; } - + + StringUtil::join(slices, count, kPathDelimiter, out); + } + + + /* static */String Path::simplify(const UnownedStringSlice& path) + { + List splitPath; + split(path, splitPath); + simplify(splitPath); + // Reconstruct the string StringBuilder builder; - for (Index i = 0; i < splitPath.getCount(); i++) - { - if (i > 0) - { - builder.Append(kPathDelimiter); - } - builder.Append(splitPath[i]); - } - + join(splitPath.getBuffer(), splitPath.getCount(), builder); return builder.ToString(); } -- cgit v1.2.3