示例#1
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("MSBT_cmd.exe {file path} {entry name} {label text}");
                return;
            }

            string file      = args[0];
            string entryname = args[1];
            string label     = args[2];

            MsbtAdapter CMD = new MsbtAdapter();

            CMD.Load(file, true);

            bool found = false;

            foreach (MsbtEntry entry in CMD.Entries)
            {
                if (entry.Name == entryname)
                {
                    entry.EditedText = label;
                    found            = true;
                    break;
                }
            }
            CMD.Save();
            if (found == false)
            {
                Console.WriteLine("Entry name not found.");
            }
            Console.WriteLine("Done!");
        }
示例#2
0
        public static MsbtAdapter GetLoadedMsbtAdapter(string fileName)
        {
            var adapter = new MsbtAdapter();

            try
            {
                adapter.Load(fileName);
            }
            catch   // If it fails to load, adapter will be new, empty adapter.   If it doesn't, it will be filled.  either way, its what we want.
            {
            }

            return(adapter);
        }
示例#3
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("MSBT_cmd.exe {file path} {entry name} {label text}");
                return;
            }

            if (FileOrDirectoryExists(args[0]))
            {
                //organize args
                FileAttributes msbt      = File.GetAttributes(args[0]);
                string         entryname = args[1];
                string         label     = args[2];

                MsbtAdapter CMD = new MsbtAdapter();

                if ((msbt & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (entryname == "*")
                    {
                        DirectoryInfo msbtdir   = new DirectoryInfo(args[0]);
                        FileInfo[]    msbtfiles = msbtdir.GetFiles("*.msbt", SearchOption.AllDirectories);
                        FileInfo[]    bakfiles  = msbtdir.GetFiles("*.bak", SearchOption.AllDirectories);

                        if (msbtfiles[0].Exists)
                        {
                            foreach (FileInfo file in msbtfiles)
                            {
                                CMD.Load(file.FullName, true);
                                foreach (MsbtEntry entry in CMD.Entries)
                                {
                                    entry.EditedText = label;
                                }
                                CMD.Save();
                                File.Delete($"{file.FullName}.bak");
                            }
                        }
                        else
                        {
                            Console.WriteLine("No MSBT files exists in that directory.");
                        }
                    }
                    else
                    {
                        var entry = CMD.Entries.FirstOrDefault(e => e.Name == entryname);
                        if (entry != null)
                        {
                            entry.EditedText = label;
                        }
                        else
                        {
                            Console.WriteLine("Entry name not found.");
                        }
                    }
                }
                else
                {
                    FileInfo msbtfile = new FileInfo(args[0]);

                    //load MSBT
                    CMD.Load(msbtfile.FullName, true);

                    //find entry
                    if (entryname == "*")
                    {
                        foreach (MsbtEntry entry in CMD.Entries)
                        {
                            entry.EditedText = label;
                        }
                    }
                    else
                    {
                        var entry = CMD.Entries.FirstOrDefault(e => e.Name == entryname);
                        if (entry != null)
                        {
                            entry.EditedText = label;
                        }
                        else
                        {
                            Console.WriteLine("Entry name not found.");
                        }
                    }

                    CMD.Save();
                    File.Delete($"{msbtfile.FullName}.bak");
                    Console.WriteLine("Done!");
                }
            }
            else
            {
                Console.WriteLine("That file or Directory Doesn't Exist.");
            }
        }