예제 #1
0
        public async Task Initalize()
        {
            // To-do: determine which NCSD header to use
            Header = new CartridgeNcsdHeader(await NcsdData.ReadArrayAsync(0, 0x1500));

            Partitions = new NcchPartition[Header.Partitions.Length];

            await Task.WhenAll(Enumerable.Range(0, Header.Partitions.Length).Select(async i =>
            {
                var partitionStart  = (long)Header.Partitions[i].Offset * MediaUnitSize;
                var partitionLength = (long)Header.Partitions[i].Length * MediaUnitSize;
                Partitions[i]       = await NcchPartition.Load(NcsdData.GetReadOnlyDataReference(partitionStart, partitionLength));
            }));
        }
예제 #2
0
        public static async Task <NcsdFile> Load(IReadOnlyBinaryDataAccessor data)
        {
            var header     = new CartridgeNcsdHeader(await data.ReadArrayAsync(0, 0x1500));
            var partitions = new NcchPartition[header.Partitions.Length];

            await Task.WhenAll(Enumerable.Range(0, header.Partitions.Length).Select(async i =>
            {
                var partitionStart  = (long)header.Partitions[i].Offset * MediaUnitSize;
                var partitionLength = (long)header.Partitions[i].Length * MediaUnitSize;
                partitions[i]       = await NcchPartition.Load(data.Slice(partitionStart, partitionLength));
            }));

            return(new NcsdFile(header, partitions));
        }