Beispiel #1
0
        public static int Main(string[] args)
        {
            bool cut_on_move = true;

            foreach (var arg in args)
            {
                if (arg == "--cut")
                {
                    cut_on_move = true;
                }
                else if (arg == "--copy")
                {
                    cut_on_move = false;
                }
            }

            Log.Write("Current Directory " + Directory.GetCurrentDirectory());

            const string kBinaryFolder = @"..\..\game_obj\";

            // Binary name (ie. debug_client, release_client,
            // debug_server, release_server)
            string binary = "";

            // Relative path to binary file
            string binary_fullpath = "";

            // Binaries' filename
            string binary_dll = "";

            try
            {
                binary = args[0];

                binary_dll = binary.ToLower()
                             .Replace("debug_", "")
                             .Replace("release_", "")
                             + ".dll";

                // Capitalize the filename
                binary_dll = char.ToUpper(binary_dll[0]) + binary_dll.Substring(1);

                binary_fullpath = kBinaryFolder + binary + "_final" +
                                  Path.DirectorySeparatorChar +
                                  binary_dll;

                if (!File.Exists(binary_fullpath))
                {
                    throw new FileNotFoundException();
                }
            }
            catch (IndexOutOfRangeException)
            {
                Log.Write("Missing Binary path argument");
                return(1);
            }
            catch (FileNotFoundException)
            {
                Log.Write("Binary File does not exist:" + binary_fullpath);
                return(2);
            }

            string sourcemod = "";

            // if there is a 2nd command line argument read the sourcemod folder
            // from the command line
            if (args.Length > 1)
            {
                try
                {
                    sourcemod = args[1];

                    if (!Directory.Exists(sourcemod))
                    {
                        throw new DirectoryNotFoundException();
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    Log.Write("Missing Sourcemods folder argument");
                    return(3);
                }
                catch (DirectoryNotFoundException)
                {
                    Log.Write("Cannot write to directory " + sourcemod);
                    return(4);
                }
            }
            else
            {
                // Read the config from the users configuration file
                const string kConfigFolder = @"..\..\luminous_dev_config";
                string       username      = Environment.UserName.ToLower();
                const string suffix        = "_sourcemod.txt";

                string filepath = kConfigFolder + Path.DirectorySeparatorChar +
                                  username + suffix;

                // Luminous Forts mod directory is on the first line
                StreamReader reader = new StreamReader(filepath);
                sourcemod = reader.ReadLine();
                reader.Close();
            }

            if (!sourcemod.EndsWith("/") || !sourcemod.EndsWith("\\"))
            {
                sourcemod += Path.DirectorySeparatorChar;
            }

            sourcemod += "bin" + Path.DirectorySeparatorChar;

            // Copy the files to their destination
            BinaryCopy copy = new BinaryCopy(binary_fullpath);

            try
            {
                if (cut_on_move)
                {
                    copy.Move(sourcemod + binary_dll);
                }
                else
                {
                    copy.Copy(sourcemod + binary_dll);
                }
            }
            catch (IOException)
            {
                Log.Write("Failure to move file");
                return(5);
            }

            File.Create(kBinaryFolder + binary + ".txt");
            Log.Write("Successfully moved file: " + binary);

            return(0);
        }
        public static int Main(string[] args)
        {
            bool cut_on_move = true;
            foreach (var arg in args)
            {
                if (arg == "--cut")
                {
                    cut_on_move = true;
                }
                else if (arg == "--copy")
                {
                    cut_on_move = false;
                }
            }

            Log.Write("Current Directory " + Directory.GetCurrentDirectory());

            const string kBinaryFolder = @"..\..\game_obj\";

            // Binary name (ie. debug_client, release_client,
            // debug_server, release_server)
            string binary = "";

            // Relative path to binary file
            string binary_fullpath = "";

            // Binaries' filename
            string binary_dll = "";
            try
            {
                binary = args[0];

                binary_dll = binary.ToLower()
                        .Replace("debug_", "")
                        .Replace("release_", "")
                        + ".dll";

                // Capitalize the filename
                binary_dll = char.ToUpper(binary_dll[0]) + binary_dll.Substring(1);

                binary_fullpath =  kBinaryFolder + binary + "_final" +
                    Path.DirectorySeparatorChar +
                    binary_dll;

                if (!File.Exists(binary_fullpath))
                {
                    throw new FileNotFoundException();
                }

            }
            catch (IndexOutOfRangeException)
            {
                Log.Write("Missing Binary path argument");
                return 1;
            }
            catch (FileNotFoundException)
            {
                Log.Write("Binary File does not exist:" + binary_fullpath);
                return 2;
            }

            string sourcemod = "";
            // if there is a 2nd command line argument read the sourcemod folder
            // from the command line
            if (args.Length > 1)
            {
                try
                {
                    sourcemod = args[1];

                    if (!Directory.Exists(sourcemod))
                    {
                        throw new DirectoryNotFoundException();
                    }

                }
                catch (IndexOutOfRangeException)
                {
                    Log.Write("Missing Sourcemods folder argument");
                    return 3;
                }
                catch (DirectoryNotFoundException)
                {
                    Log.Write("Cannot write to directory " + sourcemod);
                    return 4;
                }
            }
            else
            {
                // Read the config from the users configuration file
                const string kConfigFolder = @"..\..\luminous_dev_config";
                string username = Environment.UserName.ToLower();
                const string suffix = "_sourcemod.txt";

                string filepath = kConfigFolder + Path.DirectorySeparatorChar +
                    username + suffix;

                // Luminous Forts mod directory is on the first line
                StreamReader reader = new StreamReader(filepath);
                sourcemod = reader.ReadLine();
                reader.Close();
            }

            if (!sourcemod.EndsWith("/") || !sourcemod.EndsWith("\\"))
            {
                sourcemod += Path.DirectorySeparatorChar;
            }

            sourcemod += "bin" + Path.DirectorySeparatorChar;

            // Copy the files to their destination
            BinaryCopy copy = new BinaryCopy(binary_fullpath);
            try
            {
                if (cut_on_move)
                {
                    copy.Move(sourcemod + binary_dll);
                }
                else
                {
                    copy.Copy(sourcemod + binary_dll);
                }
            }
            catch (IOException)
            {
                Log.Write("Failure to move file");
                return 5;
            }

            File.Create(kBinaryFolder + binary + ".txt");
            Log.Write("Successfully moved file: " + binary);

            return 0;
        }