diff --git a/KFTempArchiveExtractor/Program.cs b/KFTempArchiveExtractor/Program.cs index 02c8ec4..a11ed4f 100644 --- a/KFTempArchiveExtractor/Program.cs +++ b/KFTempArchiveExtractor/Program.cs @@ -31,6 +31,8 @@ public class Program /// Application arguments. public static void Main(string[] args) { + Console.WriteLine("KF Temp Archive Extractor 1.2"); + if (args.Length != 0) { OriginalBehaviour(args); @@ -53,16 +55,7 @@ public static void Main(string[] args) return; } - // If needed, create the sub-folder in application's path - _baseExtractionPath = - Path.Combine( - Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), - "KF Archive Files"); - - if (!Directory.Exists(_baseExtractionPath)) - { - Directory.CreateDirectory(_baseExtractionPath); - } + SetAndCreateBaseExtractionPath(); // Process the files foreach (FileInfo archiveFile in archiveFiles) @@ -77,18 +70,6 @@ public static void Main(string[] args) #region Methods - /// - /// Retrieves KF installation directory from the system registry. - /// - /// The path to the local KF installation directory. - private static string GetKFInstallDir() - { - return Microsoft.Win32.Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1250", - "InstallLocation", - null).ToString(); - } - /// /// Original behaviour: drag and drop one file onto the executable. /// One difference though: the function will create a sub-folder per Archive file. @@ -102,14 +83,45 @@ private static void OriginalBehaviour(string[] args) return; } - FileInfo archiveFile = new FileInfo(args[0]); + SetAndCreateBaseExtractionPath(); + FileInfo archiveFile = new FileInfo(args[0]); if (!Process(archiveFile)) { Console.WriteLine($"File {archiveFile.Name} incorrectly processed."); } } + /// + /// Sets the base extraction path, and creates it if it doesn't already exists. + /// + private static void SetAndCreateBaseExtractionPath() + { + // If needed, create the sub-folder in application's path + _baseExtractionPath = + Path.Combine( + Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "KF Archive Files"); + + if (!Directory.Exists(_baseExtractionPath)) + { + Console.WriteLine("Creating base extraction directory..."); + Directory.CreateDirectory(_baseExtractionPath); + } + } + + /// + /// Retrieves KF installation directory from the system registry. + /// + /// The path to the local KF installation directory. + private static string GetKFInstallDir() + { + return Microsoft.Win32.Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1250", + "InstallLocation", + null).ToString(); + } + /// /// Processes a KF Archive file. /// @@ -238,4 +250,4 @@ private static void ProcessOverPausing() #endregion Methods } -} +} \ No newline at end of file