File tree 2 files changed +30
-3
lines changed
2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ use std::{
8
8
time:: Duration ,
9
9
} ;
10
10
11
+ #[ cfg( windows) ]
12
+ use std:: os:: windows:: fs:: OpenOptionsExt ;
13
+
11
14
use filetime:: { set_file_times, set_symlink_file_times, FileTime } ;
12
15
use fslock:: LockFile ;
13
16
use rayon:: prelude:: * ;
@@ -215,7 +218,13 @@ pub fn decompress(
215
218
}
216
219
if verification == 2 {
217
220
// verify checksums
218
- let target = File :: open ( & path) ;
221
+ #[ cfg( windows) ]
222
+ let target = File :: options ( )
223
+ . read ( true )
224
+ . custom_flags ( 0x08000000 ) // FILE_FLAG_SEQUENTIAL_SCAN
225
+ . open ( & path) ;
226
+ #[ cfg( not( windows) ) ]
227
+ let target = File :: options ( ) . read ( true ) . open ( & path) ;
219
228
if target. is_err ( ) {
220
229
eprintln ! (
221
230
"verification failed: couldn't open file: {}" ,
@@ -343,7 +352,12 @@ pub fn decompress(
343
352
let mut reader = HashReader :: new ( content, XxHash64 :: with_seed ( HASH_SEED ) ) ;
344
353
{
345
354
let mut reader = BufReader :: with_capacity ( DCtx :: in_size ( ) , & mut reader) ;
346
- let output = File :: create ( & path) . unwrap ( ) ;
355
+ let output = File :: options ( )
356
+ . write ( true )
357
+ . create ( true )
358
+ . truncate ( true )
359
+ . open ( & path)
360
+ . unwrap_or_else ( |e| panic ! ( "failed to create file {}: {}" , path. display( ) , e) ) ;
347
361
let mut output = BufWriter :: with_capacity ( DCtx :: out_size ( ) , output) ;
348
362
let decoder = if let Some ( dict) = & dictionary {
349
363
Decoder :: with_prepared_dictionary ( & mut reader, dict)
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ use std::{
8
8
time:: SystemTime ,
9
9
} ;
10
10
11
+ #[ cfg( windows) ]
12
+ use std:: os:: windows:: fs:: OpenOptionsExt ;
13
+
11
14
#[ cfg( any( unix, target_os = "redox" ) ) ]
12
15
use std:: os:: unix:: process:: CommandExt ;
13
16
#[ cfg( not( any( unix, target_os = "redox" ) ) ) ]
@@ -66,7 +69,17 @@ fn main() {
66
69
while let Ok ( link) = read_link ( & exe) {
67
70
exe = link;
68
71
}
69
- let file = File :: open ( & exe) . expect ( "couldn't open current executable" ) ;
72
+ #[ cfg( windows) ]
73
+ let file = File :: options ( )
74
+ . read ( true )
75
+ . custom_flags ( 0x10000000 ) // FILE_FLAG_RANDOM_ACCESS
76
+ . open ( & exe)
77
+ . expect ( "couldn't open current executable" ) ;
78
+ #[ cfg( not( windows) ) ]
79
+ let file = File :: options ( )
80
+ . read ( true )
81
+ . open ( & exe)
82
+ . expect ( "couldn't open current executable" ) ;
70
83
71
84
let mmap = unsafe {
72
85
MmapOptions :: new ( )
You can’t perform that action at this time.
0 commit comments