Esempio n. 1
0
        //TODO: Add correct output for subdirectories.

        static LaunchParameters GetLaunchParameters(string[] args)
        {
            LaunchParameters parameters = new LaunchParameters();

            for (int i = 0; i < args.Length; ++i)
            {
                if (Utils.CheckParameter(args[i], new string[] { "/nologo", "--no-logo" }))
                {
                    parameters["NoLogo"] = "true";
                    continue;
                }
                if (Utils.CheckParameter(args[i], new string[] { "/i", "-i", "--input-directory" }))
                {
                    if (i + 1 >= args.Length)
                    {
                        throw new Exception("Invalid parameter value for input directory.");
                    }
                    if (Utils.CheckDirectory(args[i + 1], false))
                    {
                        parameters["InputDirectory"] = args[++i];
                    }
                    else
                    {
                        throw new Exception(String.Format("Directory \"{0}\" doesn't exists.", args[i + 1]));
                    }
                    continue;
                }
                if (Utils.CheckParameter(args[i], new string[] { "/o", "-o", "--output-directory" }))
                {
                    if (i + 1 >= args.Length)
                    {
                        throw new Exception("Invalid parameter value for output directory.");
                    }
                    if (Utils.CheckDirectory(args[i + 1], true))
                    {
                        parameters["OutputDirectory"] = args[++i];
                    }
                    else
                    {
                        throw new Exception(String.Format("Cannot create directory \"{0}\".", args[i + 1]));
                    }
                    continue;
                }
                if (Utils.CheckParameter(args[i], new string[] { "/r", "-r", "--recursive" }))
                {
                    parameters["Recursive"] = "true";
                    continue;
                }
            }
            return(parameters);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try {
                parameters = GetLaunchParameters(args);
                if (!parameters["NoLogo"].Equals("true"))
                {
                    Logo();
                }
                if (args.Length == 0)
                {
                    PrintUsage();
                }
                if (parameters["InputDirectory"].Equals(String.Empty) || parameters["OutputDirectory"].Equals(String.Empty))
                {
                    PrintUsage();
                }

                Prepare();

                DirectoryListBuilder list = new DirectoryListBuilder(parameters["InputDirectory"], "*.xnb", parameters["Recursive"].Equals("true"));
                string p = parameters["InputDirectory"];
                if (p[p.Length - 1] != '\\')
                {
                    p += '\\';
                }
                int counter = 0;
                int count   = list.Files.Count;
                foreach (string file in list.Files)
                {
                    string f = file.Substring(p.Length);
                    f = f.Substring(0, f.Length - 4);
                    ProcessFile(f, parameters["OutputDirectory"]);

                    ++counter;
                    if (counter % 10 == 0)
                    {
                        Console.Write(String.Format("{0:##.##} %\r", ((float)counter / (float)count * 100.0f)));
                    }
                }

                Shutdown();
            } catch (Exception e) {
                Console.WriteLine("Error: " + e.Message);
            }
        }