public static string GetCommandString(CPboMode mode) { switch (mode) { case CPboMode.Extract: return("-e"); case CPboMode.Make: return("-p"); default: throw new ArgumentException($"'{mode}' is undefined.", nameof(mode)); } }
private static Tuple <string, string> LoadIOPath(string path, CPboMode mode) { var fullPath = LoadPath(path); var outputPath = ""; switch (mode) { case CPboMode.Extract: if (Directory.Exists(fullPath)) { throw new FileNotFoundException($"'{fullPath}' was not file.", path); } if (!File.Exists(fullPath)) { throw new FileNotFoundException($"'{fullPath}' was could be not found.", path); } var ext = Path.GetExtension(fullPath); if (ext.ToLower() != PboExtention) { throw new ArgumentException($"input file was not '.pbo'.", nameof(path)); } outputPath = fullPath.Remove(fullPath.Length - ext.Length); break; case CPboMode.Make: if (File.Exists(fullPath)) { throw new FileNotFoundException($"'{fullPath}' was not directory.", path); } if (!Directory.Exists(fullPath)) { throw new FileNotFoundException($"'{fullPath}' was could be not found.", path); } outputPath = fullPath + PboExtention; break; default: throw new ArgumentException($"'{mode}' is undefined.", nameof(mode)); } if (string.IsNullOrEmpty(outputPath)) { throw new InvalidProgramException($"'{nameof(outputPath)}' is null or empty."); } return(new Tuple <string, string>(fullPath, outputPath)); }