forked from halmaia/SL3Reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSLFileHeader.cs
33 lines (27 loc) · 1.03 KB
/
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
32
33
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SL3Reader
{
[StructLayout(LayoutKind.Sequential, Size = Size)]
[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
public 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)]
public readonly void ThrowIfInvalidFormatDetected()
{
if (FileFormat != LogFileFormat.SL3)
throw new InvalidDataException("Unsupported file type. Expected type SL3.");
}
}
}