@@ -89,6 +89,12 @@ pub struct FileTimes {
89
89
accessed : Option < c:: FILETIME > ,
90
90
modified : Option < c:: FILETIME > ,
91
91
}
92
+ impl core:: fmt:: Debug for c:: FILETIME {
93
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
94
+ let time = ( ( self . dwHighDateTime as u64 ) << 32 ) | self . dwLowDateTime as u64 ;
95
+ f. debug_tuple ( "FILETIME" ) . field ( & time) . finish ( )
96
+ }
97
+ }
92
98
93
99
#[ derive( Debug ) ]
94
100
pub struct DirBuilder ;
@@ -290,6 +296,7 @@ impl File {
290
296
ptr:: null_mut ( ) ,
291
297
)
292
298
} ;
299
+ let handle = unsafe { HandleOrInvalid :: from_raw_handle ( handle) } ;
293
300
if let Ok ( handle) = handle. try_into ( ) {
294
301
Ok ( File { handle : Handle :: from_inner ( handle) } )
295
302
} else {
@@ -501,7 +508,8 @@ impl File {
501
508
}
502
509
503
510
fn readlink ( & self ) -> io:: Result < PathBuf > {
504
- let mut space = Align8 ( [ MaybeUninit :: < u8 > :: uninit ( ) ; c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE ] ) ;
511
+ let mut space =
512
+ Align8 ( [ MaybeUninit :: < u8 > :: uninit ( ) ; c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize ] ) ;
505
513
let ( _bytes, buf) = self . reparse_point ( & mut space) ?;
506
514
unsafe {
507
515
let ( path_buffer, subst_off, subst_len, relative) = match ( * buf) . ReparseTag {
@@ -589,7 +597,11 @@ impl File {
589
597
) ) ;
590
598
}
591
599
cvt ( unsafe {
592
- c:: SetFileTime ( self . as_handle ( ) , None , times. accessed . as_ref ( ) , times. modified . as_ref ( ) )
600
+ let accessed =
601
+ times. accessed . as_ref ( ) . map ( |a| a as * const c:: FILETIME ) . unwrap_or ( ptr:: null ( ) ) ;
602
+ let modified =
603
+ times. modified . as_ref ( ) . map ( |a| a as * const c:: FILETIME ) . unwrap_or ( ptr:: null ( ) ) ;
604
+ c:: SetFileTime ( self . as_raw_handle ( ) , ptr:: null_mut ( ) , accessed, modified)
593
605
} ) ?;
594
606
Ok ( ( ) )
595
607
}
@@ -618,9 +630,9 @@ impl File {
618
630
/// then errors will be `ERROR_NOT_SUPPORTED` or `ERROR_INVALID_PARAMETER`.
619
631
fn posix_delete ( & self ) -> io:: Result < ( ) > {
620
632
let mut info = c:: FILE_DISPOSITION_INFO_EX {
621
- Flags : c:: FILE_DISPOSITION_DELETE
622
- | c:: FILE_DISPOSITION_POSIX_SEMANTICS
623
- | c:: FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE ,
633
+ Flags : c:: FILE_DISPOSITION_FLAG_DELETE
634
+ | c:: FILE_DISPOSITION_FLAG_POSIX_SEMANTICS
635
+ | c:: FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE ,
624
636
} ;
625
637
let size = mem:: size_of_val ( & info) ;
626
638
cvt ( unsafe {
@@ -791,23 +803,23 @@ fn open_link_no_reparse(parent: &File, name: &[u16], access: u32) -> io::Result<
791
803
// See https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile
792
804
unsafe {
793
805
let mut handle = ptr:: null_mut ( ) ;
794
- let mut io_status = c:: IO_STATUS_BLOCK :: default ( ) ;
795
- let name_str = c:: UNICODE_STRING :: from_ref ( name) ;
806
+ let mut io_status = c:: IO_STATUS_BLOCK :: PENDING ;
807
+ let mut name_str = c:: UNICODE_STRING :: from_ref ( name) ;
796
808
use crate :: sync:: atomic:: { AtomicU32 , Ordering } ;
797
809
// The `OBJ_DONT_REPARSE` attribute ensures that we haven't been
798
810
// tricked into following a symlink. However, it may not be available in
799
811
// earlier versions of Windows.
800
812
static ATTRIBUTES : AtomicU32 = AtomicU32 :: new ( c:: OBJ_DONT_REPARSE ) ;
801
- let object = c:: OBJECT_ATTRIBUTES {
802
- ObjectName : & name_str,
813
+ let mut object = c:: OBJECT_ATTRIBUTES {
814
+ ObjectName : & mut name_str,
803
815
RootDirectory : parent. as_raw_handle ( ) ,
804
816
Attributes : ATTRIBUTES . load ( Ordering :: Relaxed ) ,
805
817
..c:: OBJECT_ATTRIBUTES :: default ( )
806
818
} ;
807
819
let status = c:: NtCreateFile (
808
820
& mut handle,
809
821
access,
810
- & object,
822
+ & mut object,
811
823
& mut io_status,
812
824
crate :: ptr:: null_mut ( ) ,
813
825
0 ,
@@ -1368,7 +1380,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
1368
1380
_dwCallbackReason : c:: DWORD ,
1369
1381
_hSourceFile : c:: HANDLE ,
1370
1382
_hDestinationFile : c:: HANDLE ,
1371
- lpData : c:: LPVOID ,
1383
+ lpData : c:: LPCVOID ,
1372
1384
) -> c:: DWORD {
1373
1385
if dwStreamNumber == 1 {
1374
1386
* ( lpData as * mut i64 ) = StreamBytesTransferred ;
@@ -1415,9 +1427,10 @@ fn symlink_junction_inner(original: &Path, junction: &Path) -> io::Result<()> {
1415
1427
let f = File :: open ( junction, & opts) ?;
1416
1428
let h = f. as_inner ( ) . as_raw_handle ( ) ;
1417
1429
unsafe {
1418
- let mut data = Align8 ( [ MaybeUninit :: < u8 > :: uninit ( ) ; c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE ] ) ;
1430
+ let mut data =
1431
+ Align8 ( [ MaybeUninit :: < u8 > :: uninit ( ) ; c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize ] ) ;
1419
1432
let data_ptr = data. 0 . as_mut_ptr ( ) ;
1420
- let data_end = data_ptr. add ( c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE ) ;
1433
+ let data_end = data_ptr. add ( c:: MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize ) ;
1421
1434
let db = data_ptr. cast :: < c:: REPARSE_MOUNTPOINT_DATA_BUFFER > ( ) ;
1422
1435
// Zero the header to ensure it's fully initialized, including reserved parameters.
1423
1436
* db = mem:: zeroed ( ) ;
0 commit comments