示例#1
0
        public static string JNUSToolWrapper(string inputPath, int minFileLength, int maxFileLength, string titleId, string filter)
        {
            if (inputPath == null)
            {
                throw new Exception("JNUSToolWrapper: Input path is null.");
            }
            if (minFileLength < 0)
            {
                throw new Exception("JNUSToolWrapper: Min file length < zero.");
            }
            if (minFileLength > maxFileLength)
            {
                throw new Exception("JNUSToolWrapper: Min file length > Max file length.");
            }
            if (titleId == null)
            {
                throw new Exception("JNUSToolWrapper: Title Id is null.");
            }

            try
            {
                string[] directories = Directory.GetDirectories("resources\\jnustool");
                foreach (string dir in directories)
                {
                    Directory.Delete(dir, true);
                }

                Directory.CreateDirectory("resources\\jnustool\\tmp_" + titleId);

                string[]   file     = Directory.GetFiles(inputPath);
                FileInfo[] fileInfo = new FileInfo[file.Length];

                for (int i = 0; i < file.Length; i++)
                {
                    fileInfo[i] = new FileInfo(file[i]);
                    if (fileInfo[i].Length >= minFileLength && fileInfo[i].Length <= maxFileLength)
                    {
                        File.Copy(inputPath + "\\" + fileInfo[i].Name, "resources\\jnustool\\tmp_" + titleId + "\\" + fileInfo[i].Name, true);
                    }
                }

                NusContent.CheckBatchFiles();
                Process decrypt = Process.Start("resources\\unpack.bat", titleId + " " + filter);
                decrypt.WaitForExit();
                decrypt.Dispose();

                Directory.Delete("resources\\jnustool\\tmp_" + titleId, true);
                string[] result = Directory.GetDirectories("resources\\jnustool");

                if (result.Length == 1)
                {
                    return(result[0]);
                }
            }
            catch
            {
                Cll.Log.WriteLine("JNUSToolWrapper: Failed.");
            }
            return(null);
        }
示例#2
0
        public static bool Encrypt(string inputPath, string outputPath)
        {
            string titleId = Check(inputPath);

            if (titleId != null &&
                CheckCommonKeyFiles() &&
                GetJavaVersion() != null &&
                File.Exists("resources\\nuspacker\\NUSPacker.jar"))
            {
                NusContent.CheckBatchFiles();
                Process encrypt = Process.Start("resources\\pack.bat", "\"" + inputPath + "\" \"" + outputPath + "\"");
                encrypt.WaitForExit();
                encrypt.Dispose();
                return(true);
            }
            return(false);
        }