BootRes.Program.Main C# (CSharp) Method

Main() static private method

static private Main ( string args ) : int
args string
return int
        static int Main(string[] args)
        {
            Console.WriteLine("BootRes Copyright (C) 2010-2012  Jeffrey Bush <[email protected]>");
            Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY;");
            Console.WriteLine("This is free software, and you are welcome to redistribute it");
            Console.WriteLine("under certain conditions;");
            Console.WriteLine("See http://www.gnu.org/licenses/gpl.html for more details.");
            Console.WriteLine();

            if (args.Length != 2 && args.Length != 3)
            {
                Console.WriteLine("Usage: BOOTRES src dest [BMP|PNG|GIF|TIF]");
                Console.WriteLine("If src is a file and the dest is a directory, it will break the file up");
                Console.WriteLine("If src is a directory and the dest is a file, it will piece the files together");
                Console.WriteLine("The last parameter is for file type of pieces, defaults to BMP");
                return 1;
            }

            string src = args[0];
            string dest = args[1];
            ImageFormat format = ImageFormat.Bmp;
            if (args.Length == 3)
            {
                string f = args[2].ToUpper();
                if (f == "PNG")
                {
                    format = ImageFormat.Png;
                }
                else if (f == "GIF")
                {
                    format = ImageFormat.Png;
                }
                else if (f == "TIF")
                {
                    format = ImageFormat.Tiff;
                }
                else if (f != "BMP")
                {
                    Console.Error.WriteLine("The format for pieces was not understood, defaulting to BMP");
                }
            }

            if (Directory.Exists(src))
            {
                if (Directory.Exists(dest))
                {
                    Console.Error.WriteLine("Source and destination cannot both be directories.");
                    return 1;
                }
                return PieceTogether(src, dest, format) ? 0 : 1;
            }
            else if (File.Exists(src))
            {
                if (File.Exists(dest))
                {
                    Console.Error.WriteLine("Source and destination cannot both be files.");
                    return 1;
                }
                return BreakUp(src, dest, format) ? 0 : 1;
            }
            else
            {
                Console.Error.WriteLine("The source does not exist.");
                return 1;
            }
        }