public override void Inject(bool encrypt, string outputPath, string shortName, string longName, Bitmap menuIconImg, Bitmap bootTvImg, Bitmap bootDrcImg) { string outPath = GetValidOutputPath(outputPath, shortName); if (Directory.Exists(outPath) && (Directory.GetDirectories(outPath).Length != 0 || Directory.GetFiles(outPath).Length != 0)) { throw new Exception("The output path \"" + outPath + "\"exists and is not empty."); } Base = GetLoadedBase(); if (!BaseIsLoaded) { throw new Exception("The base is not ready."); } InjectImages(menuIconImg, bootTvImg, bootDrcImg); if (RomIsValid) { InjectMeta(shortName, longName); } InjectRom(); if (encrypt) { NusContent.Encrypt(BasePath, outPath); } else if (!Useful.DirectoryCopy(BasePath, outPath, true)) { throw new Exception("\"" + BasePath + "\" copy failed."); } }
public void LoadBase(string path) { NusContent.Format format = NusContent.GetFormat(path); if (format == NusContent.Format.Decrypted) { ValidateBase(path); if (Directory.Exists(BasePath)) { Directory.Delete(BasePath, true); Base = null; } if (Useful.DirectoryCopy(path, BasePath, true)) { Base = GetLoadedBase(); } else { throw new Exception("Could not load base \"" + path + "\"."); } } else if (format == NusContent.Format.Encrypted) { ValidateEncryptedBase(path); if (Directory.Exists(BasePath)) { Directory.Delete(BasePath, true); Base = null; } Directory.CreateDirectory(BasePath); NusContent.Decrypt(path, BasePath); Base = GetLoadedBase(); } else { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine("The folder not contains a valid NUS content."); strBuilder.AppendLine("If it is an unpackaged (decrypted) NUS content, then:"); strBuilder.AppendLine("The \"" + path + "\\code\" folder not exist."); strBuilder.AppendLine("Or \"" + path + "\\content\" folder not exist."); strBuilder.AppendLine("Or \"" + path + "\\meta\" folder not exist."); strBuilder.AppendLine("If it is an packaged (encrypted) NUS content, then:"); strBuilder.AppendLine("The \"" + path + "\\title.tmd\" file not exist."); strBuilder.AppendLine("Or \"" + path + "\\title.tik\" file not exist."); strBuilder.AppendLine("Or \"" + path + "\\title.cert\" file not exist."); throw new Exception(strBuilder.ToString()); } }