Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RawAcl.cs
Go to the documentation of this file.
3
5
6public sealed class RawAcl : GenericAcl
7{
8 private byte _revision;
9
11
12 public override byte Revision => _revision;
13
14 public override int Count => _aces.Count;
15
16 public override int BinaryLength
17 {
18 get
19 {
20 int num = 8;
21 for (int i = 0; i < Count; i++)
22 {
24 num += genericAce.BinaryLength;
25 }
26 return num;
27 }
28 }
29
30 public override GenericAce this[int index]
31 {
32 get
33 {
34 return _aces[index];
35 }
36 set
37 {
38 if (value == null)
39 {
40 throw new ArgumentNullException("value");
41 }
42 if (value.BinaryLength % 4 != 0)
43 {
44 throw new InvalidOperationException();
45 }
46 int num = BinaryLength - ((index < _aces.Count) ? _aces[index].BinaryLength : 0) + value.BinaryLength;
48 {
50 }
51 _aces[index] = value;
52 }
53 }
54
55 private static void VerifyHeader(byte[] binaryForm, int offset, out byte revision, out int count, out int length)
56 {
57 if (binaryForm == null)
58 {
59 throw new ArgumentNullException("binaryForm");
60 }
61 if (offset < 0)
62 {
64 }
65 if (binaryForm.Length - offset >= 8)
66 {
68 length = binaryForm[offset + 2] + (binaryForm[offset + 3] << 8);
69 count = binaryForm[offset + 4] + (binaryForm[offset + 5] << 8);
70 if (length <= binaryForm.Length - offset)
71 {
72 return;
73 }
74 }
76 }
77
78 private void MarshalHeader(byte[] binaryForm, int offset)
79 {
80 if (binaryForm == null)
81 {
82 throw new ArgumentNullException("binaryForm");
83 }
84 if (offset < 0)
85 {
87 }
89 {
91 }
92 if (binaryForm.Length - offset < BinaryLength)
93 {
95 }
97 binaryForm[offset + 1] = 0;
98 binaryForm[offset + 2] = (byte)BinaryLength;
99 binaryForm[offset + 3] = (byte)(BinaryLength >> 8);
100 binaryForm[offset + 4] = (byte)Count;
101 binaryForm[offset + 5] = (byte)(Count >> 8);
102 binaryForm[offset + 6] = 0;
103 binaryForm[offset + 7] = 0;
104 }
105
106 [MemberNotNull("_aces")]
107 internal void SetBinaryForm(byte[] binaryForm, int offset)
108 {
110 length += offset;
111 offset += 8;
113 int num = 8;
114 int num2 = 0;
115 while (true)
116 {
117 if (num2 < count)
118 {
120 int binaryLength = genericAce.BinaryLength;
122 {
124 }
126 if (binaryLength % 4 != 0)
127 {
128 throw new InvalidOperationException();
129 }
130 num += binaryLength;
132 if (offset > length)
133 {
134 break;
135 }
136 num2++;
137 continue;
138 }
139 return;
140 }
142 }
143
144 public RawAcl(byte revision, int capacity)
145 {
148 }
149
150 public RawAcl(byte[] binaryForm, int offset)
151 {
153 }
154
155 public override void GetBinaryForm(byte[] binaryForm, int offset)
156 {
158 offset += 8;
159 for (int i = 0; i < Count; i++)
160 {
162 genericAce.GetBinaryForm(binaryForm, offset);
163 int binaryLength = genericAce.BinaryLength;
164 if (binaryLength % 4 != 0)
165 {
166 throw new InvalidOperationException();
167 }
169 }
170 }
171
172 public void InsertAce(int index, GenericAce ace)
173 {
174 if (ace == null)
175 {
176 throw new ArgumentNullException("ace");
177 }
178 if (BinaryLength + ace.BinaryLength > GenericAcl.MaxBinaryLength)
179 {
181 }
182 _aces.Insert(index, ace);
183 }
184
185 public void RemoveAce(int index)
186 {
187 _aces.RemoveAt(index);
188 }
189}
void Add(TKey key, TValue value)
static string ArgumentOutOfRange_ArrayTooSmall
Definition SR.cs:74
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
static string AccessControl_AclTooLong
Definition SR.cs:14
static string ArgumentException_InvalidAclBinaryForm
Definition SR.cs:66
Definition SR.cs:7
static GenericAce CreateFromBinaryForm(byte[] binaryForm, int offset)
RawAcl(byte revision, int capacity)
Definition RawAcl.cs:144
void MarshalHeader(byte[] binaryForm, int offset)
Definition RawAcl.cs:78
static void VerifyHeader(byte[] binaryForm, int offset, out byte revision, out int count, out int length)
Definition RawAcl.cs:55
override void GetBinaryForm(byte[] binaryForm, int offset)
Definition RawAcl.cs:155
RawAcl(byte[] binaryForm, int offset)
Definition RawAcl.cs:150
void InsertAce(int index, GenericAce ace)
Definition RawAcl.cs:172
void SetBinaryForm(byte[] binaryForm, int offset)
Definition RawAcl.cs:107