コード例 #1
0
        internal static void Create(string filePath)
        {
            var zipFilePath    = ZipFilePath();
            var sourceFilePath = SourceFilePath(filePath);
            var sourceFileName = SourceFileName(sourceFilePath);

            Archives.Zip(filePath, zipFilePath, sourceFileName, Directories.Temp());
        }
コード例 #2
0
        private static void CreateZipFile(string tempPath)
        {
            Consoles.Write(
                text: DisplayAccessor.Displays.Get("InCompression"), type: Consoles.Types.Info);
            var zipFileName = ZipFileName();

            Archives.Zip(
                zipFilePath: tempPath,
                sourceFilePath: Path.Combine(Parameters.General.SolutionBackupPath, zipFileName),
                distinationFileName: zipFileName,
                tempPath: Directories.Temp());
        }
コード例 #3
0
ファイル: Sng.cs プロジェクト: K1llMan/RocksmithLibNeXt
        public void Save(Stream output, GamePlatform platform)
        {
            using MemoryStream decrypted = new();
            using BinaryWriter writer    = new(decrypted);
            Data.Write(writer);

            using MemoryStream zipped = new();
            Archives.Zip(decrypted, zipped, decrypted.Length, false);

            using MemoryStream encrypted = new();
            Encrypt(zipped, encrypted, GetEncodingKey(platform));

            output.Write(encrypted.GetBuffer());
        }
コード例 #4
0
        /// <summary>
        /// Write deflated data directly to output stream
        /// </summary>
        /// <param name="outputStream">Output file stream</param>
        /// <param name="blockSize">Block size</param>
        public void WriteDeflatedStream(Stream outputStream, int blockSize)
        {
            using Stream inputStream = Data;

            BlockSizes.Clear();
            Length = inputStream.Length;
            inputStream.Seek(0, SeekOrigin.Begin);

            while (inputStream.Position < inputStream.Length)
            {
                byte[] arrayI = new byte[blockSize];
                byte[] arrayO = new byte[blockSize * 2];

                using MemoryStream memoryStream = new(arrayO);

                int  plainLen  = inputStream.Read(arrayI);
                long packedLen = Archives.Zip(arrayI, memoryStream, plainLen, false);

                // If packed data "worse" than plain (i.e. already packed) z = 0
                if (packedLen >= plainLen)
                {
                    BlockSizes.Add(plainLen);
                    outputStream.Write(arrayI, 0, plainLen);
                }
                // If packed data is good
                else
                {
                    int size = packedLen < blockSize - 1 ? (int)packedLen : plainLen;

                    BlockSizes.Add(size);
                    outputStream.Write(memoryStream.ToArray(), 0, size);
                }
            }

            #if DEBUG
            Logger.LogDebug($"Deflating \"{Name}\": {inputStream.Length} -> {BlockSizes.Sum()}");
            #endif
        }