Exemple #1
0
        private void validate_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(modLocation.Text))
            {
                MessageBox.Show("Please enter a mod location before clicking Validate.", "Error", MessageBoxButtons.OK);
                return;
            }
            else if (!File.Exists(modLocation.Text) && !Directory.Exists(modLocation.Text))
            {
                MessageBox.Show("The zip file or directory was not found.", "Error", MessageBoxButtons.OK);
                return;
            }

            try
            {
                ModValidator v      = new ModValidator(modLocation.Text);
                var          result = v.Validate();

                output.Clear();

                WriteErrors(result);

                WriteExpansionsUsed(result);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
Exemple #2
0
        static int Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    Console.Error.WriteLine("No path specified.");
                    return((int)ExitCodes.NoPathSpecified);
                }

                string path = args[0];

                if (!File.Exists(path))
                {
                    Console.Error.WriteLine("File not found.");
                    return((int)ExitCodes.FileNotFound);
                }

                if (Path.GetExtension(path).ToLower() != ".zip")
                {
                    Console.Error.WriteLine("Specified file is not a zip file.");
                    return((int)ExitCodes.FileIsNotZip);
                }

                ModValidator v      = new ModValidator(path);
                var          result = v.Validate();

                StringBuilder builder = new StringBuilder();

                BuildErrors(result, builder);

                try
                {
                    File.WriteAllText(Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".ValidationLog.txt"), builder.ToString());
                }
                catch (Exception)
                {
                    //we do nothing if the log file fails to write.
                }

                if (result.IsValid)
                {
                    return((int)ExitCodes.SuccessNoErrors);
                }
                else
                {
                    return((int)ExitCodes.SuccessWithErrors);
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.GetType().FullName);
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
                return((int)ExitCodes.UnknownError);
            }
        }