public MediaInjector() { MultimediaPath = null; BasePath = Path.Combine(DataPath, "base"); Base = GetLoadedBase(); Id = 0; }
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()); } }
public void Inject(bool encrypt, string outputPath, string shortName, string longName, Bitmap menuIconImg, Bitmap bootTvImg, Bitmap bootDrcImg) { string outPath = encrypt ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "decrypted") : GetValidOutputPath(outputPath, shortName); if (!encrypt && 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."); } if (encrypt && Directory.Exists(outPath)) { Directory.Delete(outPath, true); } CopyBase(outPath); BasePath = outPath; Base = GetLoadedBase(); if (!BaseIsLoaded) { throw new Exception("The base is not ready."); } InjectImages(menuIconImg, bootTvImg, bootDrcImg); InjectMeta(shortName, longName); BasePath = Path.Combine(DataPath, "base"); InjectMultimedia(Path.Combine(outPath, "content", "app")); if (encrypt) { if (Directory.Exists(GetValidOutputPath(outputPath, shortName))) { Directory.Delete(GetValidOutputPath(outputPath, shortName), true); } Directory.CreateDirectory(GetValidOutputPath(outputPath, shortName)); NUSContent.Encrypt(outPath, GetValidOutputPath(outputPath, shortName)); } }