@@ -103,8 +103,8 @@ mod win {
103
103
opts. access_mode ( FILE_READ_ATTRIBUTES ) ;
104
104
opts. custom_flags ( FILE_FLAG_BACKUP_SEMANTICS |
105
105
FILE_FLAG_OPEN_REPARSE_POINT ) ;
106
- let file = r#try ! ( File :: open( path, & opts) ) ;
107
- ( r#try ! ( get_path( & file) ) , r#try ! ( file. file_attr( ) ) )
106
+ let file = File :: open ( path, & opts) ? ;
107
+ ( get_path ( & file) ? , file. file_attr ( ) ? )
108
108
} ;
109
109
110
110
let mut ctx = RmdirContext {
@@ -131,7 +131,7 @@ mod win {
131
131
fn readdir ( p : & Path ) -> io:: Result < ReadDir > {
132
132
let root = p. to_path_buf ( ) ;
133
133
let star = p. join ( "*" ) ;
134
- let path = r#try ! ( to_u16s( & star) ) ;
134
+ let path = to_u16s ( & star) ? ;
135
135
136
136
unsafe {
137
137
let mut wfd = mem:: zeroed ( ) ;
@@ -157,14 +157,14 @@ mod win {
157
157
fn remove_dir_all_recursive ( path : & Path , ctx : & mut RmdirContext )
158
158
-> io:: Result < ( ) > {
159
159
let dir_readonly = ctx. readonly ;
160
- for child in r#try ! ( readdir( path) ) {
161
- let child = r#try ! ( child) ;
162
- let child_type = r#try ! ( child. file_type( ) ) ;
163
- ctx. readonly = r#try ! ( child. metadata( ) ) . perm ( ) . readonly ( ) ;
160
+ for child in readdir ( path) ? {
161
+ let child = child? ;
162
+ let child_type = child. file_type ( ) ? ;
163
+ ctx. readonly = child. metadata ( ) ? . perm ( ) . readonly ( ) ;
164
164
if child_type. is_dir ( ) {
165
- r#try ! ( remove_dir_all_recursive( & child. path( ) , ctx) ) ;
165
+ remove_dir_all_recursive ( & child. path ( ) , ctx) ? ;
166
166
} else {
167
- r#try ! ( remove_item( & child. path( ) . as_ref( ) , ctx) ) ;
167
+ remove_item ( & child. path ( ) . as_ref ( ) , ctx) ? ;
168
168
}
169
169
}
170
170
ctx. readonly = dir_readonly;
@@ -178,20 +178,20 @@ mod win {
178
178
opts. custom_flags ( FILE_FLAG_BACKUP_SEMANTICS | // delete directory
179
179
FILE_FLAG_OPEN_REPARSE_POINT | // delete symlink
180
180
FILE_FLAG_DELETE_ON_CLOSE ) ;
181
- let file = r#try ! ( File :: open( path, & opts) ) ;
181
+ let file = File :: open ( path, & opts) ? ;
182
182
move_item ( & file, ctx)
183
183
} else {
184
184
// remove read-only permision
185
- r#try ! ( set_perm( & path, FilePermissions :: new( ) ) ) ;
185
+ set_perm ( & path, FilePermissions :: new ( ) ) ? ;
186
186
// move and delete file, similar to !readonly.
187
187
// only the access mode is different.
188
188
let mut opts = OpenOptions :: new ( ) ;
189
189
opts. access_mode ( DELETE | FILE_WRITE_ATTRIBUTES ) ;
190
190
opts. custom_flags ( FILE_FLAG_BACKUP_SEMANTICS |
191
191
FILE_FLAG_OPEN_REPARSE_POINT |
192
192
FILE_FLAG_DELETE_ON_CLOSE ) ;
193
- let file = r#try ! ( File :: open( path, & opts) ) ;
194
- r#try ! ( move_item( & file, ctx) ) ;
193
+ let file = File :: open ( path, & opts) ? ;
194
+ move_item ( & file, ctx) ? ;
195
195
// restore read-only flag just in case there are other hard links
196
196
let mut perm = FilePermissions :: new ( ) ;
197
197
perm. set_readonly ( true ) ;
@@ -445,13 +445,13 @@ mod win {
445
445
446
446
impl File {
447
447
fn open ( path : & Path , opts : & OpenOptions ) -> io:: Result < File > {
448
- let path = r#try ! ( to_u16s( path) ) ;
448
+ let path = to_u16s ( path) ? ;
449
449
let handle = unsafe {
450
450
CreateFileW ( path. as_ptr ( ) ,
451
- r#try ! ( opts. get_access_mode( ) ) ,
451
+ opts. get_access_mode ( ) ? ,
452
452
opts. share_mode ,
453
453
opts. security_attributes as * mut _ ,
454
- r#try ! ( opts. get_creation_mode( ) ) ,
454
+ opts. get_creation_mode ( ) ? ,
455
455
opts. get_flags_and_attributes ( ) ,
456
456
ptr:: null_mut ( ) )
457
457
} ;
@@ -465,8 +465,8 @@ mod win {
465
465
fn file_attr ( & self ) -> io:: Result < FileAttr > {
466
466
unsafe {
467
467
let mut info: BY_HANDLE_FILE_INFORMATION = mem:: zeroed ( ) ;
468
- r#try ! ( cvt( GetFileInformationByHandle ( self . handle. raw( ) ,
469
- & mut info) ) ) ;
468
+ cvt ( GetFileInformationByHandle ( self . handle . raw ( ) ,
469
+ & mut info) ) ? ;
470
470
let mut attr = FileAttr {
471
471
attributes : info. dwFileAttributes ,
472
472
creation_time : info. ftCreationTime ,
@@ -498,12 +498,12 @@ mod win {
498
498
FileAttributes : attr,
499
499
} ;
500
500
let size = mem:: size_of_val ( & info) ;
501
- r#try ! ( cvt( unsafe {
501
+ cvt ( unsafe {
502
502
SetFileInformationByHandle ( self . handle . raw ( ) ,
503
503
FileBasicInfo ,
504
504
& mut info as * mut _ as * mut _ ,
505
505
size as DWORD )
506
- } ) ) ;
506
+ } ) ? ;
507
507
Ok ( ( ) )
508
508
}
509
509
@@ -531,15 +531,15 @@ mod win {
531
531
( * info) . ReplaceIfExists = if replace { -1 } else { FALSE } ;
532
532
( * info) . RootDirectory = ptr:: null_mut ( ) ;
533
533
( * info) . FileNameLength = ( size - STRUCT_SIZE ) as DWORD ;
534
- r#try ! ( cvt( SetFileInformationByHandle ( self . handle( ) . raw( ) ,
534
+ cvt ( SetFileInformationByHandle ( self . handle ( ) . raw ( ) ,
535
535
FileRenameInfo ,
536
536
data. as_mut_ptr ( ) as * mut _ as * mut _ ,
537
- size as DWORD ) ) ) ;
537
+ size as DWORD ) ) ? ;
538
538
Ok ( ( ) )
539
539
}
540
540
}
541
541
fn set_perm ( & self , perm : FilePermissions ) -> io:: Result < ( ) > {
542
- let attr = r#try ! ( self . file_attr( ) ) . attributes ;
542
+ let attr = self . file_attr ( ) ? . attributes ;
543
543
if perm. readonly == ( attr & FILE_ATTRIBUTE_READONLY != 0 ) {
544
544
Ok ( ( ) )
545
545
} else if perm. readonly {
@@ -556,7 +556,7 @@ mod win {
556
556
-> io:: Result < ( DWORD , & ' a REPARSE_DATA_BUFFER ) > {
557
557
unsafe {
558
558
let mut bytes = 0 ;
559
- r#try ! ( cvt( {
559
+ cvt ( {
560
560
DeviceIoControl ( self . handle . raw ( ) ,
561
561
FSCTL_GET_REPARSE_POINT ,
562
562
ptr:: null_mut ( ) ,
@@ -565,7 +565,7 @@ mod win {
565
565
space. len ( ) as DWORD ,
566
566
& mut bytes,
567
567
ptr:: null_mut ( ) )
568
- } ) ) ;
568
+ } ) ? ;
569
569
Ok ( ( bytes, & * ( space. as_ptr ( ) as * const REPARSE_DATA_BUFFER ) ) )
570
570
}
571
571
}
@@ -792,7 +792,7 @@ mod win {
792
792
let mut opts = OpenOptions :: new ( ) ;
793
793
opts. access_mode ( FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES ) ;
794
794
opts. custom_flags ( FILE_FLAG_BACKUP_SEMANTICS ) ;
795
- let file = r#try ! ( File :: open( path, & opts) ) ;
795
+ let file = File :: open ( path, & opts) ? ;
796
796
file. set_perm ( perm)
797
797
}
798
798
0 commit comments