public void AddDirectoryOddPaths()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath + $@"\../{nameof (AddDirectoryOddPaths)}/", "temp", CompressionMethod.Deflate);
            }

            AssertZip(
                @"temp/A.txt
temp/B/B.txt");
        }
Exemplo n.º 2
0
        public void AddDirectory()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, "temp");
            }

            AssertZip(
                @"temp/A.txt
temp/B/
temp/B/B.txt");
        }
Exemplo n.º 3
0
        public void AddDirectoryOddPaths()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            using (var archive = new ZipArchiveEx(zip, FileMode.Create)) {
                archive.AddDirectory(temp + $@"\../{nameof (AddDirectoryOddPaths)}/", "temp");
            }

            AssertZip(
                @"temp/A.txt
temp/B/
temp/B/B.txt");
        }
        public void SkipExistingFile_Exist()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, folderInArchive: "", CompressionMethod.Deflate);
            }

            AssertZip(
                @"A.txt
B/B.txt");
            AssertSkipExisting(Path.Combine(TestPath, "A.txt"), "A.txt", expected: true);
            AssertSkipExisting(Path.Combine(TestPath, "B", "B.txt"), "B/B.txt", expected: true);
            AssertSkipExisting(Path.Combine(TestPath, "C.txt"), "C.txt", expected: false);
            AssertSkipExisting(Path.Combine(TestPath, "C", "C.txt"), "C/C.txt", expected: false);
        }
        public void SkipExistingFile_TimeStamp()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, folderInArchive: "", CompressionMethod.Deflate);
            }

            AssertZip(
                @"A.txt
B/B.txt");
            var file = Path.Combine(TestPath, "A.txt");

            File.SetLastWriteTimeUtc(file, DateTime.UtcNow.AddSeconds(1));
            AssertSkipExisting(file, "A.txt", expected: false);
            AssertSkipExisting(Path.Combine(TestPath, "B", "B.txt"), "B/B.txt", expected: true);
        }
Exemplo n.º 6
0
        public void SkipExistingFile_Exist()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            DateTime lastWrite = File.GetLastWriteTimeUtc(Path.Combine(TestPath, "A.txt"));

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, folderInArchive: "");
            }

            AssertZip(
                @"A.txt
B/
B/B.txt");
            AssertSkipExisting(Path.Combine(TestPath, "A.txt"), "A.txt", expected: true);
            AssertSkipExisting(Path.Combine(TestPath, "B", "B.txt"), "B/B.txt", expected: true);
            AssertSkipExisting(Path.Combine(TestPath, "C.txt"), "C.txt", expected: false);
            AssertSkipExisting(Path.Combine(TestPath, "C", "C.txt"), "C/C.txt", expected: false);
        }
        public void AddDirectoryCurrentDirectory()
        {
            CreateDirectories("A.txt", Path.Combine("B", "B.txt"));

            string cwd = Directory.GetCurrentDirectory();

            try {
                Directory.SetCurrentDirectory(TestPath);

                using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                    archive.AddDirectory(".", "temp", CompressionMethod.Deflate);
                }

                AssertZip(
                    @"temp/A.txt
temp/B/B.txt");
            } finally {
                Directory.SetCurrentDirectory(cwd);
            }
        }
        public void SkipExistingFile_Compression()
        {
            var fileName = "A.txt";
            var filePath = Path.Combine(TestPath, fileName);

            CreateDirectories(fileName);

            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, folderInArchive: "", CompressionMethod.Deflate);
            }

            AssertSkipExisting(filePath, fileName, expected: true, method: CompressionMethod.Deflate);
            AssertSkipExisting(filePath, fileName, expected: true, method: CompressionMethod.Default);
            AssertSkipExisting(filePath, fileName, expected: false, method: CompressionMethod.Store);

            File.Delete(Zip);
            using (var archive = new ZipArchiveEx(Zip, FileMode.Create)) {
                archive.AddDirectory(TestPath, folderInArchive: "", method: CompressionMethod.Store);
            }

            AssertSkipExisting(filePath, fileName, expected: true, method: CompressionMethod.Store);
            AssertSkipExisting(filePath, fileName, expected: false, method: CompressionMethod.Deflate);
            AssertSkipExisting(filePath, fileName, expected: false, method: CompressionMethod.Default);
        }