This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GmadHeader.File.cs
72 lines (62 loc) · 2.56 KB
/
GmadHeader.File.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
namespace GmadFileFormat
{
public readonly partial struct GmadHeader
{
/// <summary>
/// The information of a GMAD file
/// </summary>
public readonly struct File : IEquatable<File>
{
/// <summary>
/// The (relative) path of the file
/// </summary>
public String Path { get; }
/// <summary>
/// The CRC32 of the file's contents
/// </summary>
public UInt32 Crc { get; } // GMOD doesn't checks this
/// <summary>
/// The offset the file is located at from the start of the GMAD addon file
/// </summary>
public Int64 Offset { get; }
/// <summary>
/// The size of the file
/// </summary>
public Int64 Size { get; }
/// <summary>
/// Initializes this <see cref="File"/>
/// </summary>
/// <param name="path"></param>
/// <param name="crc"></param>
/// <param name="offset"></param>
/// <param name="size"></param>
internal File ( String path, UInt32 crc, Int64 offset, Int64 size )
{
this.Path = path ?? throw new ArgumentNullException ( nameof ( path ) );
this.Crc = crc;
this.Offset = offset;
this.Size = size;
}
/// <inheritdoc/>
public override Boolean Equals ( Object obj ) => obj is File file && this.Equals ( file );
/// <inheritdoc/>
public Boolean Equals ( File other ) => this.Path == other.Path && this.Crc == other.Crc && this.Offset == other.Offset && this.Size == other.Size;
/// <inheritdoc/>
public override Int32 GetHashCode ( )
{
var hashCode = -2125415227;
hashCode = hashCode * -1521134295 + EqualityComparer<String>.Default.GetHashCode ( this.Path );
hashCode = hashCode * -1521134295 + this.Crc.GetHashCode ( );
hashCode = hashCode * -1521134295 + this.Offset.GetHashCode ( );
hashCode = hashCode * -1521134295 + this.Size.GetHashCode ( );
return hashCode;
}
/// <inheritdoc/>
public static Boolean operator == ( File left, File right ) => left.Equals ( right );
/// <inheritdoc/>
public static Boolean operator != ( File left, File right ) => !( left == right );
}
}
}