From b7f3ce7598aeaa058aa420a5af51e142a2ca27ea Mon Sep 17 00:00:00 2001 From: ASNiVOR Date: Tue, 27 Jun 2017 14:08:34 +0100 Subject: [PATCH] Implemented mednafen downloading - #81 --- MedLaunch/Classes/BackupConfig.cs | 2 +- MedLaunch/Classes/IO/Archiving.cs | 24 ++- MedLaunch/MainWindow.xaml | 36 ++++- MedLaunch/MainWindow.xaml.cs | 255 +++++++++++++++++++++++++++++- MedLaunch/Models/Paths.cs | 89 ++++++++--- MedLaunch/Models/Versions.cs | 36 ++++- 6 files changed, 413 insertions(+), 29 deletions(-) diff --git a/MedLaunch/Classes/BackupConfig.cs b/MedLaunch/Classes/BackupConfig.cs index df3f282..7eed79c 100644 --- a/MedLaunch/Classes/BackupConfig.cs +++ b/MedLaunch/Classes/BackupConfig.cs @@ -31,7 +31,7 @@ public static void BackupMain() Directory.CreateDirectory(backupDir); string destPath = backupDir + "\\mednafen-09x(MLBackup-" + timeStamp + ").cfg"; // create a backup - File.Copy(cfgPath, destPath); + File.Copy(cfgPath, destPath, true); } } } diff --git a/MedLaunch/Classes/IO/Archiving.cs b/MedLaunch/Classes/IO/Archiving.cs index be03e07..7422ec6 100644 --- a/MedLaunch/Classes/IO/Archiving.cs +++ b/MedLaunch/Classes/IO/Archiving.cs @@ -29,6 +29,13 @@ public class Archiving public static List ArchiveMultiple { get; set; } // constructors + public Archiving(string archivePath) + { + ArchiveMultiple = new List(); + ArchivePath = archivePath; + ArchiveExtension = System.IO.Path.GetExtension(ArchivePath).ToLower(); + } + public Archiving(string archivePath, int systemId) { //if (ArchiveMultiple == null) @@ -55,7 +62,6 @@ public Archiving(string _hash, string filename, string archivePath, int systemId /* methods */ - /// /// Process the selected archive @@ -211,6 +217,22 @@ public void ExtractArchive(string destinationDirectory) } } + public void ExtractArchiveZipOverwrite(string destinationDirectory) + { + // determine archive type + if (ArchiveExtension == ".zip") + { + var archive = ArchiveFactory.Open(ArchivePath); + foreach (var entry in archive.Entries) + { + if (entry.IsDirectory) + continue; + + entry.WriteToDirectory(destinationDirectory, new SharpCompress.Readers.ExtractionOptions() { Overwrite = true }); + } + } + } + public static List GetSbiListFrom7z(string path) { diff --git a/MedLaunch/MainWindow.xaml b/MedLaunch/MainWindow.xaml index aa7dfed..2179f7a 100644 --- a/MedLaunch/MainWindow.xaml +++ b/MedLaunch/MainWindow.xaml @@ -10986,7 +10986,7 @@ xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Micro - +