Beispiel #1
0
 /// <summary>
 ///     Creates a DEFLATE archive for the provided files in source Directory at the given target.
 /// </summary>
 /// <param name="target">
 ///     Target archive which will contain the compressed source Directory.
 /// </param>
 /// <param name="source">
 ///     Source Directory on the filesystem containing the files.
 /// </param>
 /// <param name="files">
 ///     Files in the source Directory to compress to the target archive.
 /// </param>
 public void Compress(File target, Directory source, IEnumerable <File> files)
 {
     using (var zip = ZipFile.Open(target, ZipArchiveMode.Create))
     {
         foreach (var file in files)
         {
             zip.CreateEntryFromFile(Path.Combine(source, file), file, Level);
         }
     }
 }
Beispiel #2
0
        /// <inheritdoc />
        public override void Compress(File target, Directory source, IEnumerable <File> whitelist)
        {
            using (var zip = ZipFile.Open(target, ZipArchiveMode.Create))
            {
                const CompressionLevel level = CompressionLevel.Optimal;

                foreach (var file in whitelist)
                {
                    zip.CreateEntryFromFile(Path.Combine(source, file), file, level);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Creates a DEFLATE archive for the provided files in source Directory at the given target.
        /// </summary>
        /// <param name="target">
        ///     Target archive which will contain the compressed source Directory.
        /// </param>
        /// <param name="source">
        ///     Source Directory on the filesystem containing the files.
        /// </param>
        /// <param name="files">
        ///     Files in the source Directory to compress to the target archive.
        /// </param>
        public void Compress(File target, Directory source, IEnumerable <File> files)
        {
            var args = new StringBuilder($"a -tzip \"{(string) target}\" ");

            foreach (var file in files)
            {
                var path = Path.Combine(source, file);
                args.Append($"\"{path}\" ");
            }

            InvokeProcess(args.ToString());
        }
Beispiel #4
0
 /// <inheritdoc />
 public override void Compress(File target, Directory source)
 {
     ZipFile.CreateFromDirectory(source, target);
 }
Beispiel #5
0
 /// <summary>
 ///     Creates a DEFLATE archive for the provided source Directory at the given target.
 /// </summary>
 /// <param name="target">
 ///     Target archive which will contain the compressed source Directory.
 /// </param>
 /// <param name="source">
 ///     Source Directory on the filesystem to compress to the target archive.
 /// </param>
 public void Compress(File target, Directory source)
 {
     ZipFile.CreateFromDirectory(source, target, Level, true);
 }
Beispiel #6
0
        /// <summary>
        ///     Creates a DEFLATE archive for the provided source Directory at the given target.
        /// </summary>
        /// <param name="target">
        ///     Target archive which will contain the compressed source Directory.
        /// </param>
        /// <param name="source">
        ///     Source Directory on the filesystem to compress to the target archive.
        /// </param>
        public void Compress(File target, Directory source)
        {
            var args = new StringBuilder($"a -tzip \"{(string) target}\" \"{(string) source}\"");

            InvokeProcess(args.ToString());
        }