/ src / Ryujinx.HLE / Loaders / Npdm / FsAccessHeader.cs
FsAccessHeader.cs
 1  using Ryujinx.HLE.Exceptions;
 2  using System;
 3  using System.IO;
 4  
 5  namespace Ryujinx.HLE.Loaders.Npdm
 6  {
 7      class FsAccessHeader
 8      {
 9          public int Version { get; private set; }
10          public ulong PermissionsBitmask { get; private set; }
11  
12          /// <exception cref="InvalidNpdmException">The stream contains invalid data.</exception>
13          /// <exception cref="NotImplementedException">The ContentOwnerId section is not implemented.</exception>
14          /// <exception cref="ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
15          /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
16          /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
17          /// <exception cref="IOException">An I/O error occurred.</exception>
18          public FsAccessHeader(Stream stream, int offset, int size)
19          {
20              stream.Seek(offset, SeekOrigin.Begin);
21  
22              BinaryReader reader = new(stream);
23  
24              Version = reader.ReadInt32();
25              PermissionsBitmask = reader.ReadUInt64();
26  
27              int dataSize = reader.ReadInt32();
28  
29              if (dataSize != 0x1c)
30              {
31                  throw new InvalidNpdmException("FsAccessHeader is corrupted!");
32              }
33  #pragma warning disable IDE0059 // Remove unnecessary value assignment
34              int contentOwnerIdSize = reader.ReadInt32();
35  #pragma warning restore IDE0059
36              int dataAndContentOwnerIdSize = reader.ReadInt32();
37  
38              if (dataAndContentOwnerIdSize != 0x1c)
39              {
40                  throw new NotImplementedException("ContentOwnerId section is not implemented!");
41              }
42          }
43      }
44  }