Exemplo n.º 1
0
        public bool LoadBase(string path)
        {
            if (Directory.Exists("base"))
            {
                Directory.Delete("base", true);
                Cll.Log.WriteLine("Previous base deleted.");
            }

            if (IsValidBase(path))
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid base.");
                Useful.DirectoryCopy(path, "base", true);
            }
            else if (IsValidEncryptedBase(path))
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid encrypted base.");
                NusContent.Decrypt(path, "base");
            }
            else
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder not contains a valid base.");
            }

            _base = GetLoadedBase();

            return(BaseIsLoaded);
        }
Exemplo n.º 2
0
        private void PackUnpack(string[] args)
        {
            bool _continue = true;

            if (args.Length == 3 && args[1] == "-in")
            {
                injector.InPath  = args[2];
                injector.OutPath = Environment.CurrentDirectory + "\\" + args[0] + "_result";

                if (Directory.Exists(injector.OutPath))
                {
                    Directory.Delete(injector.OutPath, true);
                }
                Directory.CreateDirectory(injector.OutPath);
            }
            else if (args.Length == 5 && args[1] == "-in" && args[3] == "-out")
            {
                injector.InPath  = args[2];
                injector.OutPath = args[4];
            }
            else
            {
                Cll.Log.WriteLine("Incorrect " + args[0] + " syntax.");
                Cll.Log.WriteLine("");
                _continue = false;
            }

            if (_continue)
            {
                if (!Directory.Exists(injector.InPath) || !Path.IsPathRooted(injector.InPath))
                {
                    Cll.Log.WriteLine("The input folder \"" + injector.InPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
                if (!Directory.Exists(injector.OutPath) || !Path.IsPathRooted(injector.OutPath))
                {
                    Cll.Log.WriteLine("The output folder \"" + injector.OutPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue && Directory.Exists(injector.OutPath))
            {
                if (Directory.GetDirectories(injector.OutPath).Length != 0 ||
                    Directory.GetFiles(injector.OutPath).Length != 0)
                {
                    Cll.Log.WriteLine("The \"" + injector.OutPath + "\" folder exist and not empty.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue)
            {
                Cll.Log.WriteLine("in: " + injector.InPath);
                Cll.Log.WriteLine("out: " + injector.OutPath);
                Cll.Log.WriteLine("");

                if (args[0] == "pack")
                {
                    if (NusContent.Encrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The encryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The encryption failed.");
                    }
                }
                else if (args[0] == "unpack")
                {
                    if (NusContent.Decrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The decryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The decryption failed.");
                    }
                }
            }
            else if (args[0] == "pack")
            {
                Cll.Log.WriteLine("The encryption failed.");
            }
            else
            {
                Cll.Log.WriteLine("The decryption failed.");
            }
        }