private static int Run(CommandLineOptions opts) { var files = FileGlobExpander.Expand(opts.Inputs, Reporter); if (files == null) { return(2); } foreach (var file in files) { Reporter.VerboseLine($"Loading file: [{file.FullName}]"); var context = new ParseContext { DisplayedPath = file.Name, FullPath = file.FullName, GeneratedFrames = new List <IcoFrame>(), Reporter = Reporter, }; ExceptionWrapper.Try(() => DoPrintFileInfo(context, opts), context, Reporter); } Reporter.PrintHelpUrls(); return(0); }
private static int Run(CommandLineOptions opts) { CommandContext.SetVerbose(opts.Verbose); var files = FileGlobExpander.Expand(opts.Inputs, Reporter); if (files == null) { return(2); } foreach (var file in files) { Reporter.VerboseLine($"Loading file: [{file.FullName}]"); var context = new ParseContext { DisplayedPath = file.Name, FullPath = file.FullName, GeneratedFrames = new List <IcoFrame>(), Reporter = Reporter, PngEncoder = new SixLabors.ImageSharp.Formats.Png.PngEncoder { CompressionLevel = 9, ColorType = SixLabors.ImageSharp.Formats.Png.PngColorType.RgbWithAlpha, }, }; ExceptionWrapper.Try(() => DoExtractFile(context, opts), context, Reporter); } return(0); }
private static void DoFile(ParseContext context, CommandLineOptions opts) { byte[] data = null; try { if (!opts.AllowGiantFiles) { var length = new FileInfo(context.FullPath).Length; if (length > FileFormatConstants.MaxIcoFileSize) { Reporter.WarnLine(IcoErrorCode.FileTooLarge, $"Skipping file because it is unusually large ({length} bytes). Re-run with --allow-giant-inputs to bypass this safety.", context.FullPath); return; } } data = File.ReadAllBytes(context.FullPath); } catch (Exception e) { System.Console.WriteLine($"Exception {e} while reading file \"{context.DisplayedPath}\""); return; } ExceptionWrapper.Try(() => DoFile(data, context, opts), context, Reporter); }
private static int Run(CommandLineOptions opts) { CommandContext.SetVerbose(opts.Verbose); foreach (var warning in opts.DisabledWarnings) { var munged = warning; if (munged.StartsWith("ico", StringComparison.InvariantCultureIgnoreCase)) { munged = warning.Substring(3); } int code; if (!int.TryParse(munged, out code) || null == Enum.GetName(typeof(IcoErrorCode), code)) { Reporter.ErrorLine(IcoErrorCode.NoError, $"Unknown warning number \"{warning}\""); return(1); } Reporter.WarningsToIgnore.Add((IcoErrorCode)code); } var files = FileGlobExpander.Expand(opts.Inputs, Reporter); if (files == null) { return(2); } foreach (var file in files) { Reporter.VerboseLine($"Loading file: [{file.FullName}]"); var context = new ParseContext { DisplayedPath = file.Name, FullPath = file.FullName, GeneratedFrames = new List <IcoFrame>(), Reporter = Reporter, }; ExceptionWrapper.Try(() => DoLintFile(context, opts), context, Reporter); } Reporter.PrintHelpUrls(); if (Reporter.NumberOfWarningsOrErrors > 0) { return(3); } return(0); }