Exemple #1
0
        internal static void CreateNca(Option option)
        {
            AuthoringConfiguration config    = option.Config;
            CreateNcaOption        createNca = option.CreateNca;

            Directory.CreateDirectory(Path.GetDirectoryName(createNca.OutputFile));
            string str = createNca.InputAdfFile;

            if (createNca.ContentType != null)
            {
                List <Pair <FilterType, Regex> > fdf = FilterDescription.ParseFdf(createNca.InputFdfPath);
                str = Path.GetDirectoryName(createNca.OutputFile) + "\\" + Path.GetFileName(createNca.OutputFile) + ".adf";
                new NintendoContentAdfWriter(str, createNca.ContentType, createNca.MetaFilePath, createNca.DescFilePath, createNca.KeyAreaEncryptionKeyIndex).Write(createNca.InputDirs, fdf);
            }
            if (createNca.IsOnlyAdf)
            {
                return;
            }
            if (ContentArchiveLibraryInterface.GetArchiveType(str) != ArchiveFormatType.NintendoContent)
            {
                throw new FormatException("invalid formatType is indicated by .adf file.");
            }
            using (FileStream fileStream = Program.OpenNewFileStream(createNca.OutputFile, FileOptions.RandomAccess))
                ContentArchiveLibraryInterface.CreateArchiveFromAdf((Stream)fileStream, str, config);
            if (createNca.IsSaveAdf)
            {
                return;
            }
            File.Delete(str);
            File.Delete(Path.GetDirectoryName(str) + "\\" + Path.GetFileNameWithoutExtension(str) + ".code.adf");
            File.Delete(Path.GetDirectoryName(str) + "\\" + Path.GetFileNameWithoutExtension(str) + ".rom.adf");
        }
Exemple #2
0
        internal static void CreateFs(Option option)
        {
            AuthoringConfiguration config   = option.Config;
            CreateFsOption         createFs = option.CreateFs;

            Directory.CreateDirectory(Path.GetDirectoryName(createFs.OutputFile));
            string str = createFs.InputAdfFile;

            if (createFs.Format != ArchiveFormatType.Invalid)
            {
                List <Pair <FilterType, Regex> > fdf = FilterDescription.ParseFdf(createFs.InputFdfPath);
                str = Path.GetDirectoryName(createFs.OutputFile) + "\\" + Path.GetFileName(createFs.OutputFile) + ".adf";
                switch (createFs.Format)
                {
                case ArchiveFormatType.PartitionFs:
                    new PartitionFsAdfWriter(str).Write(createFs.InputDir);
                    break;

                case ArchiveFormatType.RomFs:
                    new RomFsAdfWriter(str).Write(createFs.InputDir, fdf);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            if (createFs.IsOnlyAdf)
            {
                return;
            }
            switch (ContentArchiveLibraryInterface.GetArchiveType(str))
            {
            case ArchiveFormatType.PartitionFs:
            case ArchiveFormatType.RomFs:
                using (FileStream fileStream = Program.OpenNewFileStream(createFs.OutputFile, FileOptions.RandomAccess))
                    ContentArchiveLibraryInterface.CreateArchiveFromAdf((Stream)fileStream, str, config);
                if (createFs.IsSaveAdf)
                {
                    break;
                }
                File.Delete(str);
                break;

            default:
                throw new FormatException("invalid formatType is indicated by .adf file.");
            }
        }
Exemple #3
0
        internal static void CreateNsp(Option option)
        {
            AuthoringConfiguration config    = option.Config;
            CreateNspOption        createNsp = option.CreateNsp;

            Directory.CreateDirectory(Path.GetDirectoryName(createNsp.OutputFile));
            if (createNsp.GeneratesApplicationControl)
            {
                ApplicationControl.Generate(createNsp.NspContentInfos[0].MetaFilePath, createNsp.NspContentInfos[0].IconList, createNsp.NspContentInfos[0].NxIconList, createNsp.NspContentInfos[0].NxIconMaxSize, createNsp.GetApplicationControlGeneratePath(), true);
            }
            string str = createNsp.InputAdfFile;

            if (str == null)
            {
                List <Pair <FilterType, Regex> > fdf = FilterDescription.ParseFdf(createNsp.InputFdfPath);
                str = Path.GetDirectoryName(createNsp.OutputFile) + "\\" + Path.GetFileName(createNsp.OutputFile) + ".adf";
                new NintendoSubmissionPackageAdfWriter(str).Write(createNsp.NspContentInfos, fdf);
            }
            if (createNsp.IsOnlyAdf)
            {
                return;
            }
            if (ContentArchiveLibraryInterface.GetArchiveType(str) != ArchiveFormatType.NintendoSubmissionPackage)
            {
                throw new FormatException("invalid formatType is indicated by .adf file.");
            }
            using (FileStream fileStream = Program.OpenNewFileStream(createNsp.OutputFile, FileOptions.RandomAccess))
                ContentArchiveLibraryInterface.CreateArchiveFromAdf((Stream)fileStream, str, config);
            if (!createNsp.IsSaveAdf)
            {
                File.Delete(str);
                foreach (string file in Directory.GetFiles(Path.GetDirectoryName(str), Path.GetFileNameWithoutExtension(str) + ".c?.*.nca.*adf"))
                {
                    File.Delete(file);
                }
            }
            if (!createNsp.GeneratesApplicationControl)
            {
                return;
            }
            Directory.Delete(createNsp.GetApplicationControlGeneratePath(), true);
        }