private static void Main(string[] args) { Args = new List <string>(args); for (var index = 0; index < Args.Count; index++) { var x = Args[index]; Args[index] = x.Trim('"'); } var ind = Args.FindIndex(x => x.Equals("-skipWarning", StringComparison.OrdinalIgnoreCase)); if (ind >= 0) { ZZZ.SkipWarning = true; Args.RemoveAt(ind); } if ((Args.Count == 1 || Args.Count == 3) && (Args[0].Equals("-folderMerge", StringComparison.OrdinalIgnoreCase) || Args[0].Equals("-mergeFolder", StringComparison.OrdinalIgnoreCase)) && (Directory.EnumerateFiles(ZZZ.ID1).Count() > 1 || Directory.EnumerateFiles(ZZZ.ID2).Count() > 1 || Directory.EnumerateDirectories(ZZZ.ID1).Count() > 1 || Directory.EnumerateDirectories(ZZZ.ID2).Count() > 1)) { if (Args.Count == 3) { var path = Args[1].Trim(); path = GetFullPath(path); ZZZ.Main = path; path = Args[2].Trim(); path = GetFullPath(path); ZZZ.Other = path; } try { ZZZ.FolderMerge(); } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (Args.Count >= 2 && File.Exists(Args[0] = GetFullPath(Args[0]))) { //merge ZZZ.Path = Args[0]; ZZZ.In = new List <string>(); for (var i = 1; i < Args.Count; i++) { Args[i] = GetFullPath(Args[i]); if (File.Exists(Args[i]) && !ZZZ.In.Contains(Args[i])) { ZZZ.In.Add(Args[i]); } else { Logger.WriteLine($"({Args[i]}) doesn't exist or is already added.\n"); } } try { if (ZZZ.In.Count > 0) { ZZZ.Merge(); } } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (Args.Count == 2 && File.Exists(Args[0] = GetFullPath(Args[0]))) { Args[1] = GetFullPath(Args[1]); Directory.CreateDirectory(Args[1]); ZZZ.In = new List <string>(); if (Directory.Exists(Args[1])) { ZZZ.In.Add(Args[0]); ZZZ.Path = Args[1]; try { ZZZ.Extract(); } catch (PathTooLongException) { } catch (InvalidDataException) { } } else { Logger.WriteLine("Invalid Directory"); } } else if (Args.Count == 1 && Directory.Exists(Args[0] = GetFullPath(Args[0]))) { ZZZ.Path = Args[0]; try { ZZZ.Write(); } catch (PathTooLongException) { } catch (InvalidDataException) { } } else { do { var k = MainMenu(); switch (k.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: OpenFolder(ExtractMenu()); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: OpenFolder(WriteMenu()); break; case ConsoleKey.D3: case ConsoleKey.NumPad3: OpenFolder(MergeMenu()); break; default: { if ((k.Key == ConsoleKey.D4 || k.Key == ConsoleKey.NumPad4) && (Directory.EnumerateFiles(ZZZ.ID1).Count() > 1 || Directory.EnumerateFiles(ZZZ.ID2).Count() > 1)) { try { OpenFolder(ZZZ.FolderMerge()); } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (k.Key == ConsoleKey.T) { TestMenu(); } break; } } } while (true); } void OpenFolder(string folder) { try { folder = GetFullPath(folder); if (Directory.Exists(folder)) { Process.Start(folder); } } catch { // ignored } } Logger.DisposeChildren(); }
private static void Main(string[] args) { Args = new List <string>(args); Args.ForEach(x => x.Trim('"')); int ind = Args.FindIndex(x => x.Equals("-skipwarning", StringComparison.OrdinalIgnoreCase)); if (ind >= 0) { zzz.SkipWarning = true; Args.RemoveAt(ind); } if ((Args.Count == 1 || Args.Count == 3) && (Args[0].Equals("-foldermerge", StringComparison.OrdinalIgnoreCase) || Args[0].Equals("-mergefolder", StringComparison.OrdinalIgnoreCase)) && (Directory.EnumerateFiles(zzz.id1).Count() > 1 || Directory.EnumerateFiles(zzz.id2).Count() > 1 || Directory.EnumerateDirectories(zzz.id1).Count() > 1 || Directory.EnumerateDirectories(zzz.id2).Count() > 1)) { if (Args.Count == 3) { string path = Args[1].Trim(); path = GetFullPath(path); zzz.Main = path; path = Args[2].Trim(); path = GetFullPath(path); zzz.Other = path; } try { zzz.FolderMerge(); } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (Args.Count >= 2 && File.Exists(Args[0] = GetFullPath(Args[0]))) { //merge zzz.Path_ = Args[0]; zzz.In = new List <string>(); for (int i = 1; i < Args.Count; i++) { Args[i] = GetFullPath(Args[i]); if (File.Exists(Args[i]) && !zzz.In.Contains(Args[i])) { zzz.In.Add(Args[i]); } else { Logger.WriteLine($"({Args[i]}) doesn't exist or is already added.\n"); } } try { if (zzz.In.Count > 0) { zzz.Merge(); } } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (Args.Count == 2 && File.Exists(Args[0] = GetFullPath(Args[0]))) { Args[1] = GetFullPath(Args[1]); Directory.CreateDirectory(Args[1]); zzz.In = new List <string>(); if (Directory.Exists(Args[1])) { zzz.In.Add(Args[0]); zzz.Path_ = Args[1]; try { zzz.Extract(); } catch (PathTooLongException) { } catch (InvalidDataException) { } } else { Logger.WriteLine("Invalid Directory"); } } else if (Args.Count == 1 && Directory.Exists(Args[0] = GetFullPath(Args[0]))) { zzz.Path_ = Args[0]; try { zzz.Write(); } catch (PathTooLongException) { } catch (InvalidDataException) { } } else { start: ConsoleKeyInfo k = MainMenu(); if (k.Key == ConsoleKey.D1 || k.Key == ConsoleKey.NumPad1) { openfolder(ExtractMenu()); } else if (k.Key == ConsoleKey.D2 || k.Key == ConsoleKey.NumPad2) { openfolder(WriteMenu()); } else if (k.Key == ConsoleKey.D3 || k.Key == ConsoleKey.NumPad3) { openfolder(MergeMenu()); } else if ((k.Key == ConsoleKey.D4 || k.Key == ConsoleKey.NumPad4) && (Directory.EnumerateFiles(zzz.id1).Count() > 1 || Directory.EnumerateFiles(zzz.id2).Count() > 1)) { try { openfolder(zzz.FolderMerge()); } catch (PathTooLongException) { } catch (InvalidDataException) { } catch (ArgumentException) { } } else if (k.Key == ConsoleKey.T) { TestMenu(); } goto start; } void openfolder(string folder) { try { folder = GetFullPath(folder); if (Directory.Exists(folder)) { Process.Start(folder); } } catch { } } Logger.DisposeChildren(); }