diff --git a/Tinke/Program.cs b/Tinke/Program.cs index d1070b0..f981fb9 100644 --- a/Tinke/Program.cs +++ b/Tinke/Program.cs @@ -66,6 +66,9 @@ internal class OpenOptions [Option('f', "folder", HelpText = "Call a folder select dialog then open the selected folder.")] public bool IsFolder { get; set; } + [Option('d', "dir", HelpText = "Open the folder directly instead of calling folder select dialog. Will be ignore if -f/--folder not passed.")] + public string DirPath { get; set; } + [Value(0, MetaName = "RomPath", HelpText = "Path of the file(s). Can be provided multiple. Will be ignore if -f/--folder passed.")] public IEnumerable Props { @@ -100,6 +103,7 @@ static class Program public static List tblRoms; public static bool bIsFolder = false; public static bool bOpenDefault = false; + public static string openDirPath; /// /// Punto de entrada principal para la aplicaciĆ³n. @@ -108,7 +112,7 @@ static class Program static void Main(string[] args) { #region ComprobaciĆ³n de archivos necesarios - string[] archivos = new string[] { "Ekona.dll", "DSDecmp.dll" , "Be.Windows.Forms.HexBox.dll" }; + string[] archivos = new string[] { "Ekona.dll", "DSDecmp.dll" , "Be.Windows.Forms.HexBox.dll", "CommandLine.dll" }; string faltan = ""; for (int i = 0; i < archivos.Length; i++) { @@ -190,6 +194,7 @@ private static void RunOpen(OpenOptions opts) else curCommand = 3; tblRoms = opts.Props.ToList(); + openDirPath = opts.DirPath; bIsFolder = opts.IsFolder; } diff --git a/Tinke/Sistema.cs b/Tinke/Sistema.cs index 9a4f8e8..2720097 100644 --- a/Tinke/Sistema.cs +++ b/Tinke/Sistema.cs @@ -139,15 +139,28 @@ void Sistema_Load(object sender, EventArgs e) } if (Program.bIsFolder) { - FolderBrowserDialog o = new FolderBrowserDialog(); - o.ShowNewFolderButton = false; - if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK) + if (string.IsNullOrWhiteSpace(Program.openDirPath)) { - Application.Exit(); - return; + FolderBrowserDialog o = new FolderBrowserDialog(); + o.ShowNewFolderButton = false; + if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK) + { + Application.Exit(); + return; + } + filesToRead[0] = o.SelectedPath; + o.Dispose(); + } else { + if (Directory.Exists(Program.openDirPath)) + filesToRead[0] = Program.openDirPath; + else + { + MessageBox.Show(Tools.Helper.GetTranslation("Messages", "S2E"), Tools.Helper.GetTranslation("Messages", "S01")); + this.Close(); + Application.Exit(); + return; + } } - filesToRead[0] = o.SelectedPath; - o.Dispose(); } else if (Program.tblRoms.Count() == 1) { @@ -2706,7 +2719,12 @@ private void Sistema_DragDrop(object sender, DragEventArgs e) { foreach (string item in filePaths) { - inFile = String.Format("\"{0}\"", item); + FileAttributes attr = File.GetAttributes(item); + if ((attr & FileAttributes.Directory) == FileAttributes.Directory) + inFile = "open -f -d"; + else + inFile = "open "; + inFile += String.Format("\"{0}\"", item); System.Diagnostics.Process.Start(Application.ExecutablePath, inFile); } }