@@ -13,23 +13,16 @@ public static void Unpack(string archivePath, bool rename = false)
1313 Directory . CreateDirectory ( systemDir ) ;
1414
1515 Stream stream = File . OpenRead ( archivePath ) ;
16- int fileNameLength = stream . ReadByte ( ) ;
16+ int fileNameLength = stream . ReadByte ( ) * 2 - 2 ;
1717 while ( fileNameLength > 0 )
1818 {
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 ) ;
3020 string filePath = Path . Combine ( systemDir , fileName ) ;
3121 File . WriteAllText ( filePath , string . Empty ) ;
3222
23+ stream . ReadByte ( ) ;
24+ stream . ReadByte ( ) ;
25+
3326 int chunkSize = 65536 ;
3427 int fileLength = BitConverter . ToInt32 ( ReadBytes ( stream , 4 ) , 0 ) ;
3528 for ( int i = chunkSize ; i < fileLength ; i += chunkSize )
@@ -40,7 +33,7 @@ public static void Unpack(string archivePath, bool rename = false)
4033 int remained = fileLength - fileLength / chunkSize * chunkSize ;
4134 WriteChunkFromStream ( stream , remained , filePath ) ;
4235
43- fileNameLength = stream . ReadByte ( ) ;
36+ fileNameLength = stream . ReadByte ( ) * 2 - 2 ;
4437 }
4538 stream . Close ( ) ;
4639
@@ -54,6 +47,12 @@ private static byte[] ReadBytes(Stream stream, int length)
5447 return bytesArray ;
5548 }
5649
50+ private static string ReadUtf16Le ( Stream stream , int size )
51+ {
52+ byte [ ] bytesArray = ReadBytes ( stream , size ) ;
53+ return Encoding . Unicode . GetString ( bytesArray ) ;
54+ }
55+
5756 private static void WriteChunkFromStream ( Stream stream , int size , string filePath )
5857 {
5958 byte [ ] bytesArray = ReadBytes ( stream , size ) ;
0 commit comments