Exemple #1
0
        public async Task OpenFile(BinaryFile file)
        {
            // Clear virtual path if it exists
            if (!string.IsNullOrEmpty(VirtualPath) && CurrentFileSystem.DirectoryExists(VirtualPath))
            {
                CurrentFileSystem.DeleteDirectory(VirtualPath);
            }

            VirtualPath = CurrentFileSystem.GetTempDirectory();

            if (await NcsdFile.IsNcsd(file))
            {
                Container = await NcsdFile.Load(file);
            }
            else if (await CiaFile.IsCia(file))
            {
                Container = await CiaFile.Load(file);
            }
            else if (await NcchPartition.IsNcch(file))
            {
                Container = new SingleNcchPartitionContainer(await NcchPartition.Load(file));
            }
            else if (await RomFs.IsRomFs(file))
            {
                Container = new SingleNcchPartitionContainer(new NcchPartition(romfs: await RomFs.Load(file)));
            }
            else if (await ExeFs.IsExeFs(file))
            {
                Container = new SingleNcchPartitionContainer(new NcchPartition(exefs: await ExeFs.Load(file)));
            }
            else
            {
                throw new BadImageFormatException(Properties.Resources.ThreeDsRom_UnsupportedFileFormat);
            }
        }
Exemple #2
0
        public async Task CanRebuildRomfs(string filename)
        {
            var fs = new PhysicalFileSystem();

            using (var originalRom = new ThreeDsRom())
            {
                await originalRom.OpenFile(filename);

                using (var newRom = new ThreeDsRom(await RomFs.Build("/RomFS", originalRom)))
                {
                    await AssertDirectoriesEqual("/RomFS", originalRom, "/RomFS", newRom);
                }
            }
        }
Exemple #3
0
        public async Task CanRebuildRomfs(string filename)
        {
            using var originalRom = new ThreeDsRom();
            await originalRom.OpenFile(filename);

            for (int i = 0; i < originalRom.Partitions.Length; i++)
            {
                var partition = originalRom.Partitions[i]?.RomFs;
                if (partition != null)
                {
                    var romFsDirName = "/" + originalRom.GetRomFsDirectoryName(i);
                    using var newRom = new ThreeDsRom(await RomFs.Build(romFsDirName, originalRom), i);
                    await AssertDirectoriesEqual(romFsDirName, originalRom, romFsDirName, newRom);
                }
            }
        }
    public ValueTask ExecuteAsync(IConsole console)
    {
        if (string.IsNullOrEmpty(DestinationFolder))
        {
            DestinationFolder = Path.GetDirectoryName(NdsPath);
        }
        else
        {
            Directory.CreateDirectory(DestinationFolder);
        }

        var romFsConfig = new RomFsConfig
                          (
            nameTableStartOffsetPositon: NtStartOffsetPosition ?? RomFs.NdsConfig.NameTableStartOffsetPositon,
            allocationTableStartOffsetPosition: FatStartOffsetPosition ?? RomFs.NdsConfig.AllocationTableStartOffsetPosition
                          );

        using IRomFs nds = new RomFs(NdsPath, romFsConfig);
        nds.ExtractCopyOfDirectory(FilePath, DestinationFolder);

        return(default);
Exemple #5
0
 public ThreeDsRom(RomFs romFs, int partitionIndex = 0)
 {
     Container = new SingleNcchPartitionContainer(new NcchPartition(romFs), partitionIndex);
 }
Exemple #6
0
 public static async Task <bool> IsThreeDsRom(BinaryFile file)
 {
     return(await NcsdFile.IsNcsd(file) || await CiaFile.IsCia(file) || await NcchPartition.IsNcch(file) || await RomFs.IsRomFs(file) || await ExeFs.IsExeFs(file));
 }
Exemple #7
0
 public ThreeDsRom(RomFs romFs)
 {
     Container = new SingleNcchPartitionContainer(new NcchPartition(romFs));
 }