Beispiel #1
0
        /// <summary>
        /// Check if the arguments are valid. Store errors in this.Errors
        /// </summary>
        public void Validate()
        {
            FileIO fileIO = new FileIO();

            // Check every menmber
            if (this.RawArguments == null || this.RawArguments.Count <= 0)
            {
                this.Errors.Add("Arguments is empty.");
            }
            if (this.Problem.ID == null || this.Problem.ID.Length <= 0)
            {
                this.Errors.Add("Problem ID must be set! Use -p to set the problem ID.");
            }
            if ((this.Input.Mode == InputMode.File && (this.Input.Paths.Count <= 0 || this.Input.Paths == null)))
            {
                this.Errors.Add("Input file path is empty! Use -if to set the input file paths.");
            }
            else
            {
                FileIO.FileState state;
                for (int i = 0; i < this.Input.Paths.Count; i++)
                {
                    state = fileIO.GetFileState(Input.Paths[i]);
                    if (!(state == FileIO.FileState.CanRead || state == FileIO.FileState.Accessible))
                    {
                        this.Errors.Add("Cannot open \"" + Input.Paths[i] + "\"");
                    }
                }
            }
            if ((this.Output.Mode != OutputMode.ConsoleOnly && this.Input.Mode == InputMode.String)
                && (this.Output.Paths.Count <= 0 || this.Output.Paths == null))
            {
                this.Errors.Add("Output file path is empty! Use -of to set the output file paths.");
            }
            else
            {
                FileIO.FileState state;
                for (int i = 0; i < this.Output.Paths.Count; i++)
                {
                    state = fileIO.GetFileState(Output.Paths[i]);
                    if (!(state == FileIO.FileState.CanWrite || state == FileIO.FileState.Accessible || state == FileIO.FileState.NotExists))
                    {
                        this.Errors.Add("Cannot write to \"" + Output.Paths[i] + "\"");
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initialize new instance of IO handler
 /// </summary>
 public IOHandler()
 {
     this.fileIO = new FileIO();
 }