@@ -90,8 +90,8 @@ public class ArkPackage : AbstractPackage
90
90
private ArkDirectory root ;
91
91
private Stream [ ] contentFiles ;
92
92
private MultiStream contentFileMeta ;
93
- private ulong [ ] arkFileSizes ;
94
- private ulong totalArkFileSizes ;
93
+ private long [ ] arkFileSizes ;
94
+ private long totalArkFileSizes ;
95
95
96
96
public override string FileName { get ; }
97
97
public override IDirectory RootDirectory => root ;
@@ -106,13 +106,13 @@ public static bool IsArk(string fn)
106
106
public static bool IsArk ( Stream s )
107
107
{
108
108
s . Position = 0 ;
109
- uint version = ( uint ) s . ReadInt32LE ( ) ;
109
+ uint version = s . ReadUInt32LE ( ) ;
110
110
if ( version > 6 )
111
111
{
112
112
// hdr is encrypted, probably
113
113
using ( var decryptor = new HdrCryptStream ( s ) )
114
114
{
115
- version = ( uint ) decryptor . ReadInt32LE ( ) ;
115
+ version = decryptor . ReadUInt32LE ( ) ;
116
116
}
117
117
}
118
118
return version <= 6 && version >= 3 ;
@@ -139,7 +139,7 @@ public ArkPackage(string pathToHdr)
139
139
using ( var hdr = new FileStream ( pathToHdr , FileMode . Open , FileAccess . Read ) )
140
140
{
141
141
Stream actualHdr = hdr ;
142
- uint version = ( uint ) hdr . ReadInt32LE ( ) ;
142
+ uint version = hdr . ReadUInt32LE ( ) ;
143
143
if ( version > 6 )
144
144
{
145
145
// hdr is encrypted, probably
@@ -149,7 +149,7 @@ public ArkPackage(string pathToHdr)
149
149
decryptor . Read ( arr , 0 , ( int ) decryptor . Length ) ;
150
150
actualHdr = new MemoryStream ( arr ) ;
151
151
}
152
- version = ( uint ) actualHdr . ReadInt32LE ( ) ;
152
+ version = actualHdr . ReadUInt32LE ( ) ;
153
153
}
154
154
readHeader ( actualHdr , pathToHdr , version ) ;
155
155
}
@@ -169,11 +169,11 @@ private void readHeader(Stream header, string headerPath, uint version)
169
169
{
170
170
throw new Exception ( "Ark header appears to be invalid (.ark count mismatch)." ) ;
171
171
}
172
- arkFileSizes = new ulong [ numArks ] ;
172
+ arkFileSizes = new long [ numArks ] ;
173
173
for ( var i = 0 ; i < numArks ; i ++ )
174
174
{
175
175
// All versions except 4 use 32-bit file sizes.
176
- arkFileSizes [ i ] = ( ulong ) ( version == 4 ? header . ReadInt64LE ( ) : header . ReadInt32LE ( ) ) ;
176
+ arkFileSizes [ i ] = ( version == 4 ? header . ReadInt64LE ( ) : header . ReadInt32LE ( ) ) ;
177
177
totalArkFileSizes += arkFileSizes [ i ] ;
178
178
}
179
179
@@ -196,7 +196,7 @@ private void readHeader(Stream header, string headerPath, uint version)
196
196
// Version 6: appears to checksums or something for each content file
197
197
if ( version == 6 )
198
198
{
199
- uint numChecksums = ( uint ) header . ReadInt32LE ( ) ;
199
+ uint numChecksums = header . ReadUInt32LE ( ) ;
200
200
header . Seek ( 4 * numChecksums , SeekOrigin . Current ) ;
201
201
}
202
202
}
@@ -214,7 +214,7 @@ private void readHeader(Stream header, string headerPath, uint version)
214
214
contentFileMeta = new MultiStream ( contentFiles ) ;
215
215
216
216
// All versions: read file tables.
217
- uint fileNameTableSize = ( uint ) header . ReadInt32LE ( ) ;
217
+ uint fileNameTableSize = header . ReadUInt32LE ( ) ;
218
218
219
219
// Save position of filename table for later.
220
220
long tableOffset = header . Position ;
@@ -224,7 +224,7 @@ private void readHeader(Stream header, string headerPath, uint version)
224
224
// Rather than read all filenames with their offsets, we read all the
225
225
// offsets first, then read the filenames. This saves a lot of seeking
226
226
// back-and-forth within the header.
227
- uint numFileNames = ( uint ) header . ReadInt32LE ( ) ;
227
+ uint numFileNames = header . ReadUInt32LE ( ) ;
228
228
if ( numFileNames > fileNameTableSize )
229
229
{
230
230
throw new Exception ( "Ark header appears to be invalid (number of filenames exceeds filename table size)." ) ;
@@ -253,16 +253,16 @@ private void readHeader(Stream header, string headerPath, uint version)
253
253
// Directories are not explicitly stored. Rather, they are inferred
254
254
// by the path string each file has, which tells you in which folder
255
255
// the file lives.
256
- uint numFiles = ( uint ) header . ReadInt32LE ( ) ;
256
+ uint numFiles = header . ReadUInt32LE ( ) ;
257
257
root = new ArkDirectory ( null , ROOT_DIR ) ;
258
258
for ( var i = 0 ; i < numFiles ; i ++ )
259
259
{
260
260
// Version 3 uses 32-bit file offsets
261
- long arkFileOffset = ( version == 3 ? ( header . ReadInt32LE ( ) & 0xFFFFFFFF ) : header . ReadInt64LE ( ) ) ;
261
+ long arkFileOffset = ( version == 3 ? header . ReadUInt32LE ( ) : header . ReadInt64LE ( ) ) ;
262
262
int filenameStringId = header . ReadInt32LE ( ) ;
263
- int dirStringId = header . ReadInt32LE ( ) ;
264
- uint size = ( uint ) header . ReadInt32LE ( ) ;
265
- uint zero = ( uint ) header . ReadInt32LE ( ) ;
263
+ uint dirStringId = header . ReadUInt32LE ( ) ;
264
+ uint size = header . ReadUInt32LE ( ) ;
265
+ uint zero = header . ReadUInt32LE ( ) ;
266
266
if ( zero == 0 )
267
267
{
268
268
ArkDirectory parent = makeOrGetDir ( fileNames [ dirStringId ] ) ;
0 commit comments