Exemple #1
0
        /// <summary>
        /// Compress (TAR/BZip2) an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, TAR/BZip2 compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            FileAES_IntUtilities.CreateEncryptionFilePath(unencryptedFile, "TAR", out string tempRawPath, out _, out string tempOutputPath);

            TarWriterOptions wo = new TarWriterOptions(CompressionType.BZip2, true);

            using (Stream stream = File.OpenWrite(tempOutputPath))
                using (var writer = new TarWriter(stream, wo))
                {
                    writer.WriteAll(tempRawPath, "*", SearchOption.AllDirectories);
                }
            return(tempOutputPath);
        }
Exemple #2
0
        /// <summary>
        /// Compress (LZMA) an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, LZMA compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            FileAES_IntUtilities.CreateEncryptionFilePath(unencryptedFile, "LZMA", out string tempRawPath, out _, out string tempOutputPath);

            WriterOptions wo = new WriterOptions(CompressionType.LZMA);

            using (Stream stream = File.OpenWrite(tempOutputPath))
                using (var writer = WriterFactory.Open(stream, ArchiveType.Zip, wo))
                {
                    writer.WriteAll(tempRawPath, "*", SearchOption.AllDirectories);
                }

            return(tempOutputPath);
        }
Exemple #3
0
        /// <summary>
        /// Compress (ZIP) an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, ZIP compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            FileAES_IntUtilities.CreateEncryptionFilePath(unencryptedFile, "ZIP", out string tempRawPath, out _, out string tempOutputPath);

            ZipWriterOptions wo = new ZipWriterOptions(CompressionType.Deflate)
            {
                DeflateCompressionLevel = _compressLevel
            };

            using (Stream stream = File.OpenWrite(tempOutputPath))
                using (var writer = new ZipWriter(stream, wo))
                {
                    writer.WriteAll(tempRawPath, "*", SearchOption.AllDirectories);
                }
            return(tempOutputPath);
        }
Exemple #4
0
        /// <summary>
        /// Compress (LGYZIP) an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, LGYZIP compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            FileAES_IntUtilities.CreateEncryptionFilePath(unencryptedFile, "LGYZIP", out string tempRawPath, out _, out string tempOutputPath);

            if (unencryptedFile.IsFile())
            {
                using (ZipArchive zip = ZipFile.Open(tempOutputPath, ZipArchiveMode.Create))
                {
                    zip.CreateEntryFromFile(unencryptedFile.GetPath(), unencryptedFile.GetFileName());
                    zip.Dispose();
                }
            }
            else
            {
                FileAES_IntUtilities.DirectoryCopy(unencryptedFile.GetPath(), tempRawPath);

                ZipFile.CreateFromDirectory(tempRawPath, tempOutputPath);
            }

            return(tempOutputPath);
        }