예제 #1
0
        public static void ExportBinary(PackedFile CurrentPackedFile, string _exportDirectory)
        {
            string extractTo = null;

            // TODO: Add support for ModManager
            //extractTo = ModManager.Instance.CurrentModSet ? ModManager.Instance.CurrentModDirectory : null;
            if (extractTo == null)
            {
                DirectoryDialog dialog = new DirectoryDialog
                {
                    Description  = "Please point to folder to extract to",
                    SelectedPath = String.IsNullOrEmpty(_exportDirectory)
                                    ? System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
                                    : _exportDirectory
                };
                extractTo        = dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK ? dialog.SelectedPath : null;
                _exportDirectory = dialog.SelectedPath;
            }
            if (!string.IsNullOrEmpty(extractTo))
            {
                List <PackedFile> files = new List <PackedFile>();
                files.Add(CurrentPackedFile);
                FileExtractor extractor = new FileExtractor(extractTo);
                extractor.ExtractFiles(files);
                MessageBox.Show(string.Format("File exported as binary."));
            }
        }
예제 #2
0
        public async Task ExtractFiles_WithManifestItemsInContentDirectory_ReturnsFiles()
        {
            var zip           = new Mock <IZip>();
            var content       = Encoding.ASCII.GetBytes("test");
            var manifestItems = new[]
            {
                new ManifestItem(string.Empty, "chapter1.xml", string.Empty, ContentType.Unknown),
            };
            var opf = await XmlStructureFile.LoadFromTextAsync("content/opf.opf", "<Doc />");

            zip.Setup(x => x.GetFileContent("content/chapter1.xml")).Returns(content);
            var testee = new FileExtractor();

            var result = (await testee.ExtractFiles(opf, manifestItems, zip.Object)).Single();

            Assert.AreEqual(content, result.Content);
            Assert.AreEqual("chapter1.xml", result.Name);
            Assert.AreEqual("content/chapter1.xml", result.Path);
        }
예제 #3
0
        private void ExportData(object sender, EventArgs e)
        {
            string extractTo = ModManager.Instance.CurrentModSet ? ModManager.Instance.CurrentModDirectory : null;

            if (extractTo == null)
            {
                DirectoryDialog dialog = new DirectoryDialog {
                    Description  = "Please point to folder to extract to",
                    SelectedPath = Settings.Default.LastPackDirectory
                };
                extractTo = dialog.ShowDialog() == DialogResult.OK ? dialog.SelectedPath : null;
            }
            if (!string.IsNullOrEmpty(extractTo))
            {
                List <PackedFile> files = new List <PackedFile>();
                files.Add(CurrentPackedFile);
                FileExtractor extractor = new FileExtractor(null, null, extractTo)
                {
                    Preprocessor = new TsvExtractionPreprocessor()
                };
                extractor.ExtractFiles(files);
                MessageBox.Show(string.Format("File exported to TSV."));
            }
        }