-
Notifications
You must be signed in to change notification settings - Fork 5
/
SLFileHeader.cs
31 lines (24 loc) · 963 Bytes
/
SLFileHeader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SL3Reader;
[StructLayout(LayoutKind.Sequential, Size = Size)]
[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
internal readonly ref struct SLFileHeader
{
public const int Size = 8;
public readonly LogFileFormat FileFormat { get; }
public readonly short DeviceID { get; }
public readonly short BlockSize { get; }
public readonly short Reserved { get; }
[SkipLocalsInit]
public readonly override string ToString() =>
FileFormat.ToString() + " (" + BlockSize.ToString() + ')';
[MethodImpl(MethodImplOptions.AggressiveInlining), SkipLocalsInit]
public readonly void ThrowIfInvalidFormatDetected()
{
if (FileFormat is not LogFileFormat.SL3)
throw new InvalidDataException("Unsupported file type. Expected type SL3.");
}
};