-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEsfsSector.cs
56 lines (47 loc) · 1.46 KB
/
EsfsSector.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
using System;
namespace EsfsLite
{
public class EsfsSector
{
public EsfsSal Sal { get; }
public Int64 Index { get; set; }
private readonly byte[] _sectorData;
private readonly byte[] _sectorContents;
public EsfsSector(EsfsSal sal)
{
Sal = sal;
_sectorData = new byte[Esfs.SectorSizeRawBytes];
_sectorContents = new byte[Esfs.SectorSizeContentBytes];
}
public void Read()
{
Array.Copy(Sal.GetSector(Index), _sectorData, _sectorData.Length);
Array.Copy(_sectorData, _sectorContents, _sectorContents.Length);
}
public void Store()
{
Array.Copy(_sectorContents, _sectorData, _sectorContents.Length);
Sal.PutSector(Index, _sectorData, 0);
}
public byte[] Data
{
get
{
return _sectorContents;
}
set
{
Array.Copy(value, _sectorContents, _sectorContents.Length);
}
}
public Int64 Link
{
get { return BitConverter.ToInt64(_sectorData, _sectorData.Length - sizeof (Int64)); }
set
{
Array.Copy(BitConverter.GetBytes(value), 0, _sectorData, _sectorData.Length - sizeof (Int64),
sizeof (Int64));
}
}
}
}