示例#1
0
        public async Task EditThenSaveArcAsTwice(string filename, string entryPath, string replacementFile, string expectedFile)
        {
            using (ArcFile arcFile = new ArcFile(filename))
            {
                ContainerEntry arcEntry = arcFile.GetEntry(entryPath);
                if (arcEntry == null)
                {
                    Assert.Fail("Entry not found.");
                }
                using (FileStream fileStream = new FileStream(replacementFile, FileMode.Open, FileAccess.Read))
                {
                    await arcEntry.SetData(fileStream);
                }
                await arcFile.SaveAs("temp1.arc", progress);

                await arcFile.SaveAs("temp2.arc", progress);
            }
            bool eq1 = Compare.CompareFiles(expectedFile, "temp1.arc");
            bool eq2 = Compare.CompareFiles(ArcFile.GetBinName(expectedFile), "temp1.bin");
            bool eq3 = Compare.CompareFiles(expectedFile, "temp2.arc");
            bool eq4 = Compare.CompareFiles(ArcFile.GetBinName(expectedFile), "temp2.bin");

            File.Delete("temp1.arc");
            File.Delete("temp1.bin");
            File.Delete("temp2.arc");
            File.Delete("temp2.bin");
            Assert.IsTrue(eq1);
            Assert.IsTrue(eq2);
            Assert.IsTrue(eq3);
            Assert.IsTrue(eq4);
        }
示例#2
0
        public async Task EditEntryReextractTest(string filename, string entryFilepath, string replacementFile, string expectedDir)
        {
            using (ArcFile arcFile = new ArcFile(filename))
            {
                ContainerEntry arcEntry = arcFile.GetEntry(entryFilepath);
                if (arcEntry == null)
                {
                    Assert.Fail("Entry not found.");
                }
                using (FileStream fileStream = new FileStream(replacementFile, FileMode.Open, FileAccess.Read))
                {
                    await arcEntry.SetData(fileStream);
                }
                await arcFile.SaveAs("temp.arc", progress);
            }
            using (ArcFile arcFile = new ArcFile("temp.arc"))
            {
                await arcFile.ExtractAllAsync("tempdir", false, progress);
            }
            File.Move(expectedDir + "/" + entryFilepath, "backup");
            File.Copy(replacementFile, expectedDir + "/" + entryFilepath);
            bool eq = Compare.CompareDirectories(expectedDir, "tempdir");

            File.Delete(expectedDir + "/" + entryFilepath);
            File.Move("backup", expectedDir + "/" + entryFilepath);

            DirectoryInfo directoryInfo = new DirectoryInfo("tempdir");

            directoryInfo.Delete(true);
            File.Delete("temp.arc");
            File.Delete("temp.bin");
            Assert.IsTrue(eq);
        }
示例#3
0
        public async Task SaveArcAs(string filename)
        {
            using (ArcFile arcFile = new ArcFile(filename))
            {
                await arcFile.SaveAs("temp.arc", progress);
            }
            bool eq = Compare.CompareFiles(filename, "temp.arc") && Compare.CompareFiles(ArcFile.GetBinName(filename), "temp.bin");

            File.Delete("temp.arc");
            File.Delete("temp.bin");
            Assert.IsTrue(eq);
        }
示例#4
0
        public async Task SaveAs()
        {
            try
            {
                ClearStatus();
                string fileName = _getFileName.SaveGetFileName("Save As", "", "Arc file (*.arc)|*.arc|Arc dat file (*.arc.dat)|*.arc.dat");
                if (fileName != null)
                {
                    await ArcFile.SaveAs(fileName, ProgressReporter);

                    ReportMessage("Done.");
                }
            }
            catch (Exception ex)
            {
                ReportException(ex);
            }
        }
示例#5
0
        public async Task ReplaceTest(string filename, string replacementFolder, string expectedFolder)
        {
            using (ArcFile arcFile = new ArcFile(filename))
            {
                await arcFile.ReplaceEntries(new FileSource(replacementFolder), progress);

                await arcFile.SaveAs("temp.arc");
            }
            using (ArcFile arcFile = new ArcFile("temp.arc"))
            {
                await arcFile.ExtractAllAsync("tempdir", true, progress);
            }
            bool eq = Compare.CompareDirectories(expectedFolder, "tempdir");

            File.Delete("temp.arc");
            File.Delete("temp.bin");
            DirectoryInfo directoryInfo = new DirectoryInfo("tempdir");

            directoryInfo.Delete(true);
            Assert.IsTrue(eq);
        }