@@ -13,23 +13,16 @@ public static void Unpack(string archivePath, bool rename = false)
13
13
Directory . CreateDirectory ( systemDir ) ;
14
14
15
15
Stream stream = File . OpenRead ( archivePath ) ;
16
- int fileNameLength = stream . ReadByte ( ) ;
16
+ int fileNameLength = stream . ReadByte ( ) * 2 - 2 ;
17
17
while ( fileNameLength > 0 )
18
18
{
19
- string fileName = string . Empty ;
20
- for ( int i = 0 ; i < fileNameLength ; i ++ )
21
- {
22
- int currentByte = stream . ReadByte ( ) ;
23
- if ( currentByte > 0 )
24
- {
25
- fileName += Convert . ToChar ( currentByte ) ;
26
- }
27
- stream . ReadByte ( ) ;
28
- }
29
-
19
+ string fileName = ReadUtf16Le ( stream , fileNameLength ) ;
30
20
string filePath = Path . Combine ( systemDir , fileName ) ;
31
21
File . WriteAllText ( filePath , string . Empty ) ;
32
22
23
+ stream . ReadByte ( ) ;
24
+ stream . ReadByte ( ) ;
25
+
33
26
int chunkSize = 65536 ;
34
27
int fileLength = BitConverter . ToInt32 ( ReadBytes ( stream , 4 ) , 0 ) ;
35
28
for ( int i = chunkSize ; i < fileLength ; i += chunkSize )
@@ -40,7 +33,7 @@ public static void Unpack(string archivePath, bool rename = false)
40
33
int remained = fileLength - fileLength / chunkSize * chunkSize ;
41
34
WriteChunkFromStream ( stream , remained , filePath ) ;
42
35
43
- fileNameLength = stream . ReadByte ( ) ;
36
+ fileNameLength = stream . ReadByte ( ) * 2 - 2 ;
44
37
}
45
38
stream . Close ( ) ;
46
39
@@ -54,6 +47,12 @@ private static byte[] ReadBytes(Stream stream, int length)
54
47
return bytesArray ;
55
48
}
56
49
50
+ private static string ReadUtf16Le ( Stream stream , int size )
51
+ {
52
+ byte [ ] bytesArray = ReadBytes ( stream , size ) ;
53
+ return Encoding . Unicode . GetString ( bytesArray ) ;
54
+ }
55
+
57
56
private static void WriteChunkFromStream ( Stream stream , int size , string filePath )
58
57
{
59
58
byte [ ] bytesArray = ReadBytes ( stream , size ) ;
0 commit comments