Example #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);
            }
        }
Example #2
0
        public async Task CanRebuildExefs(string filename)
        {
            using var originalRom = new ThreeDsRom();
            await originalRom.OpenFile(filename);

            for (int i = 0; i < originalRom.Partitions.Length; i++)
            {
                var exefs = originalRom.Partitions[i]?.ExeFs;
                if (exefs != null)
                {
                    var exeFsDirName = "/" + ThreeDsRom.GetExeFsDirectoryName(i);
                    using var data   = new BinaryFile(exefs.ToByteArray());
                    using var newRom = new ThreeDsRom(await ExeFs.Load(data), i);
                    await AssertDirectoriesEqual(exeFsDirName, originalRom, exeFsDirName, newRom);
                }
            }
        }
Example #3
0
 public ThreeDsRom(ExeFs exefs, int partitionIndex = 0)
 {
     Container = new SingleNcchPartitionContainer(new NcchPartition(exefs: exefs), partitionIndex);
 }
Example #4
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));
 }