@@ -89,6 +89,12 @@ pub struct FileTimes {
8989 accessed : Option < c:: FILETIME > ,
9090 modified : Option < c:: FILETIME > ,
9191}
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+ }
9298
9399#[ derive( Debug ) ]
94100pub struct DirBuilder ;
@@ -290,6 +296,7 @@ impl File {
290296 ptr:: null_mut ( ) ,
291297 )
292298 } ;
299+ let handle = unsafe { HandleOrInvalid :: from_raw_handle ( handle) } ;
293300 if let Ok ( handle) = handle. try_into ( ) {
294301 Ok ( File { handle : Handle :: from_inner ( handle) } )
295302 } else {
@@ -501,7 +508,8 @@ impl File {
501508 }
502509
503510 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 ] ) ;
505513 let ( _bytes, buf) = self . reparse_point ( & mut space) ?;
506514 unsafe {
507515 let ( path_buffer, subst_off, subst_len, relative) = match ( * buf) . ReparseTag {
@@ -589,7 +597,11 @@ impl File {
589597 ) ) ;
590598 }
591599 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)
593605 } ) ?;
594606 Ok ( ( ) )
595607 }
@@ -618,9 +630,9 @@ impl File {
618630 /// then errors will be `ERROR_NOT_SUPPORTED` or `ERROR_INVALID_PARAMETER`.
619631 fn posix_delete ( & self ) -> io:: Result < ( ) > {
620632 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 ,
624636 } ;
625637 let size = mem:: size_of_val ( & info) ;
626638 cvt ( unsafe {
@@ -791,23 +803,23 @@ fn open_link_no_reparse(parent: &File, name: &[u16], access: u32) -> io::Result<
791803 // See https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile
792804 unsafe {
793805 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) ;
796808 use crate :: sync:: atomic:: { AtomicU32 , Ordering } ;
797809 // The `OBJ_DONT_REPARSE` attribute ensures that we haven't been
798810 // tricked into following a symlink. However, it may not be available in
799811 // earlier versions of Windows.
800812 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,
803815 RootDirectory : parent. as_raw_handle ( ) ,
804816 Attributes : ATTRIBUTES . load ( Ordering :: Relaxed ) ,
805817 ..c:: OBJECT_ATTRIBUTES :: default ( )
806818 } ;
807819 let status = c:: NtCreateFile (
808820 & mut handle,
809821 access,
810- & object,
822+ & mut object,
811823 & mut io_status,
812824 crate :: ptr:: null_mut ( ) ,
813825 0 ,
@@ -1368,7 +1380,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
13681380 _dwCallbackReason : c:: DWORD ,
13691381 _hSourceFile : c:: HANDLE ,
13701382 _hDestinationFile : c:: HANDLE ,
1371- lpData : c:: LPVOID ,
1383+ lpData : c:: LPCVOID ,
13721384 ) -> c:: DWORD {
13731385 if dwStreamNumber == 1 {
13741386 * ( lpData as * mut i64 ) = StreamBytesTransferred ;
@@ -1415,9 +1427,10 @@ fn symlink_junction_inner(original: &Path, junction: &Path) -> io::Result<()> {
14151427 let f = File :: open ( junction, & opts) ?;
14161428 let h = f. as_inner ( ) . as_raw_handle ( ) ;
14171429 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 ] ) ;
14191432 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 ) ;
14211434 let db = data_ptr. cast :: < c:: REPARSE_MOUNTPOINT_DATA_BUFFER > ( ) ;
14221435 // Zero the header to ensure it's fully initialized, including reserved parameters.
14231436 * db = mem:: zeroed ( ) ;
0 commit comments