2
2
using System . IO ;
3
3
using System . Security . Cryptography ;
4
4
using System . Text ;
5
- using Ionic . Zlib ;
5
+ using System . IO . Compression ;
6
6
using PatchKit . Network ;
7
7
using PatchKit . Unity . Patcher . AppData . FileSystem ;
8
8
using PatchKit . Unity . Patcher . Cancellation ;
@@ -40,9 +40,7 @@ public class Pack1Unarchiver : IUnarchiver
40
40
/// The range (in bytes) of the partial pack1 source file
41
41
/// </summary>
42
42
private readonly BytesRange _range ;
43
-
44
- private MapHashExtractedFiles _mapHashExtractedFiles ;
45
-
43
+
46
44
public event UnarchiveProgressChangedHandler UnarchiveProgressChanged ;
47
45
48
46
// set to true to continue unpacking on error. Check HasErrors later to see if there are any
@@ -51,24 +49,23 @@ public class Pack1Unarchiver : IUnarchiver
51
49
// After Unarchive() finishes if this set to true, there were unpacking errors.
52
50
public bool HasErrors { get ; private set ; }
53
51
54
- public Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , MapHashExtractedFiles mapHashExtractedFiles , string key , string suffix = "" )
55
- : this ( packagePath , metaData , destinationDirPath , mapHashExtractedFiles , Encoding . ASCII . GetBytes ( key ) , suffix , new BytesRange ( 0 , - 1 ) )
52
+ public Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , string key , string suffix = "" )
53
+ : this ( packagePath , metaData , destinationDirPath , Encoding . ASCII . GetBytes ( key ) , suffix , new BytesRange ( 0 , - 1 ) )
56
54
{
57
55
// do nothing
58
56
}
59
57
60
- public Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , MapHashExtractedFiles mapHashExtractedFiles , string key , string suffix , BytesRange range )
61
- : this ( packagePath , metaData , destinationDirPath , mapHashExtractedFiles , Encoding . ASCII . GetBytes ( key ) , suffix , range )
58
+ public Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , string key , string suffix , BytesRange range )
59
+ : this ( packagePath , metaData , destinationDirPath , Encoding . ASCII . GetBytes ( key ) , suffix , range )
62
60
{
63
61
// do nothing
64
62
}
65
63
66
- private Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , MapHashExtractedFiles mapHashExtractedFiles , byte [ ] key , string suffix , BytesRange range )
64
+ private Pack1Unarchiver ( string packagePath , Pack1Meta metaData , string destinationDirPath , byte [ ] key , string suffix , BytesRange range )
67
65
{
68
66
Checks . ArgumentFileExists ( packagePath , "packagePath" ) ;
69
67
Checks . ArgumentDirectoryExists ( destinationDirPath , "destinationDirPath" ) ;
70
68
Checks . ArgumentNotNull ( suffix , "suffix" ) ;
71
- Checks . ArgumentNotNull ( mapHashExtractedFiles , "mapHashExtractedFiles" ) ;
72
69
73
70
if ( range . Start == 0 )
74
71
{
@@ -85,7 +82,6 @@ private Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinati
85
82
_destinationDirPath = destinationDirPath ;
86
83
_suffix = suffix ;
87
84
_range = range ;
88
- _mapHashExtractedFiles = mapHashExtractedFiles ;
89
85
90
86
using ( var sha256 = SHA256 . Create ( ) )
91
87
{
@@ -203,7 +199,7 @@ private void Unpack(Pack1Meta.FileEntry file, Action<double> progress, Cancellat
203
199
204
200
private void UnpackDirectory ( Pack1Meta . FileEntry file , CancellationToken cancellationToken )
205
201
{
206
- string destPath = Path . Combine ( _destinationDirPath , _mapHashExtractedFiles . Add ( file . Name ) ) ;
202
+ string destPath = Path . Combine ( _destinationDirPath , HashCalculator . ComputeMD5Hash ( file . Name ) ) ;
207
203
208
204
DebugLogger . Log ( "Creating directory " + destPath ) ;
209
205
DirectoryOperations . CreateDirectory ( destPath , cancellationToken ) ;
@@ -212,7 +208,7 @@ private void UnpackDirectory(Pack1Meta.FileEntry file, CancellationToken cancell
212
208
213
209
private void UnpackSymlink ( Pack1Meta . FileEntry file )
214
210
{
215
- string destPath = Path . Combine ( _destinationDirPath , _mapHashExtractedFiles . Add ( file . Name ) ) ;
211
+ string destPath = Path . Combine ( _destinationDirPath , HashCalculator . ComputeMD5Hash ( file . Name ) ) ;
216
212
DebugLogger . Log ( "Creating symlink: " + destPath ) ;
217
213
// TODO: how to create a symlink?
218
214
}
@@ -234,7 +230,7 @@ private DecompressorCreator ResolveDecompressor(Pack1Meta meta)
234
230
235
231
private void UnpackRegularFile ( Pack1Meta . FileEntry file , Action < double > onProgress , CancellationToken cancellationToken , string destinationDirPath = null )
236
232
{
237
- string destPath = Path . Combine ( destinationDirPath == null ? _destinationDirPath : destinationDirPath , _mapHashExtractedFiles . Add ( file . Name ) + _suffix ) ;
233
+ string destPath = Path . Combine ( destinationDirPath == null ? _destinationDirPath : destinationDirPath , HashCalculator . ComputeMD5Hash ( file . Name ) + _suffix ) ;
238
234
239
235
DebugLogger . LogFormat ( "Unpacking regular file {0} to {1}" , file , destPath ) ;
240
236
0 commit comments