コード例 #1
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);
        }
コード例 #2
0
        public async Task ExtractAllAsync(string filename, bool extractPar, string expectedFolder)
        {
            using ArcFile arcFile = new ArcFile(filename);
            await Task.Run(() => arcFile.ExtractAllAsync("temp", extractPar, progress));

            bool          eq            = Compare.CompareDirectories(expectedFolder, "temp");
            DirectoryInfo directoryInfo = new DirectoryInfo("temp");

            directoryInfo.Delete(true);
            Assert.IsTrue(eq);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: faraplay/ImasArchiveS
        static async Task Extract(ExtractOptions o)
        {
            var progress = o.Verbose ? consoleProgress : null;

            if (!o.Commu &&
                !o.Parameter &&
                !o.Image &&
                !o.Lyrics &&
                !o.All)
            {
                Console.Error.WriteLine("No data specified to extract. Use --help for guidelines on usage.");
                return;
            }

            using ArcFile arcFile = new ArcFile(o.Input);
            if (o.Commu)
            {
                await arcFile.ExtractCommusToXlsx(o.Output, o.Overwrite, progress);
            }
            if (o.Parameter)
            {
                await arcFile.ExtractParameterToXlsx(o.Output, o.Overwrite, progress);
            }
            if (o.Image)
            {
                if (o.Overwrite && Directory.Exists(o.Output))
                {
                    Directory.Delete(o.Output, true);
                }
                await arcFile.ExtractAllImages(o.Output, progress);
            }
            if (o.Lyrics)
            {
                if (o.Overwrite && Directory.Exists(o.Output))
                {
                    Directory.Delete(o.Output, true);
                }
                await arcFile.ExtractLyrics(o.Output, o.Overwrite, progress);
            }
            if (o.All)
            {
                if (o.Overwrite && Directory.Exists(o.Output))
                {
                    Directory.Delete(o.Output, true);
                }
                await arcFile.ExtractAllAsync(o.Output, false, progress);
            }
        }
コード例 #4
0
        public async Task ReplaceSaveZipTest(string filename, string replacementZip, string expectedFolder)
        {
            await ArcFile.PatchArcFromZip(filename, replacementZip, "temp.arc", progress);

            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);
        }
コード例 #5
0
        public async Task ExtractAll()
        {
            try
            {
                ClearStatus();
                string fileName = _getFileName.SaveGetFileName("Extract to...", ArcFile.RemoveArcExtension(ArcPath).Item1, "");
                if (fileName != null)
                {
                    await ArcFile.ExtractAllAsync(fileName, false, ProgressReporter);

                    ReportMessage("Done.");
                }
            }
            catch (Exception ex)
            {
                ReportException(ex);
            }
        }
コード例 #6
0
        public async Task BuildNewArcTest(string dir)
        {
            await ArcFile.BuildFromDirectory(dir, "temp.arc", progress);

            using (ArcFile arcFile = new ArcFile("temp.arc"))
            {
                await arcFile.ExtractAllAsync("tempdir", false, progress);
            }

            bool eq = Compare.CompareDirectories(dir, "tempdir");

            DirectoryInfo directoryInfo = new DirectoryInfo("tempdir");

            directoryInfo.Delete(true);
            File.Delete("temp.arc");
            File.Delete("temp.bin");

            Assert.IsTrue(eq);
        }
コード例 #7
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);
        }