diff --git a/RecrownedAthenaeum.ConsoleTools/NinePatchTools/NinePatchCommand.cs b/RecrownedAthenaeum.ConsoleTools/NinePatchTools/NinePatchCommand.cs index d07960b..4e4b216 100644 --- a/RecrownedAthenaeum.ConsoleTools/NinePatchTools/NinePatchCommand.cs +++ b/RecrownedAthenaeum.ConsoleTools/NinePatchTools/NinePatchCommand.cs @@ -8,6 +8,11 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools { public class NinePatchCommand : EngineCommand { + private enum SupportedExtensions + { + jpeg, jpg, png + } + public NinePatchCommand() : base("9p", "ninepatch", "9patch") { help = "Generates a 9 patch file for a given image."; @@ -41,6 +46,9 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound); string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented); + if (!File.Exists(imagePath)) throw new ArgumentException("Input file does not exist."); + SupportedExtensions extension; + if (!Enum.TryParse(Path.GetExtension(imagePath).ToLower().Substring(1), out extension)) throw new ArgumentException("Input file extension not supported."); using (StreamWriter stringWriter = new StreamWriter(outPath + ".9p")) { stringWriter.WriteLine(serialized);