@@ -29,9 +29,8 @@ pub(crate) mod module {
2929 mem:: MaybeUninit ,
3030 os:: windows:: ffi:: { OsStrExt , OsStringExt } ,
3131 } ;
32- use winapi:: um;
3332 use windows_sys:: Win32 :: {
34- Foundation :: { CloseHandle , INVALID_HANDLE_VALUE } ,
33+ Foundation :: { self , INVALID_HANDLE_VALUE } ,
3534 Storage :: FileSystem ,
3635 System :: { Console , Threading } ,
3736 } ;
@@ -41,12 +40,11 @@ pub(crate) mod module {
4140
4241 #[ pyfunction]
4342 pub ( super ) fn access ( path : OsPath , mode : u8 , vm : & VirtualMachine ) -> PyResult < bool > {
44- use um:: winnt;
4543 let attr = unsafe { FileSystem :: GetFileAttributesW ( path. to_widecstring ( vm) ?. as_ptr ( ) ) } ;
4644 Ok ( attr != FileSystem :: INVALID_FILE_ATTRIBUTES
4745 && ( mode & 2 == 0
48- || attr & winnt :: FILE_ATTRIBUTE_READONLY == 0
49- || attr & winnt :: FILE_ATTRIBUTE_DIRECTORY != 0 ) )
46+ || attr & FileSystem :: FILE_ATTRIBUTE_READONLY == 0
47+ || attr & FileSystem :: FILE_ATTRIBUTE_DIRECTORY != 0 ) )
5048 }
5149
5250 #[ derive( FromArgs ) ]
@@ -155,7 +153,7 @@ pub(crate) mod module {
155153 }
156154 let ret = unsafe { Threading :: TerminateProcess ( h, sig) } ;
157155 let res = if ret == 0 { Err ( errno_err ( vm) ) } else { Ok ( ( ) ) } ;
158- unsafe { CloseHandle ( h) } ;
156+ unsafe { Foundation :: CloseHandle ( h) } ;
159157 res
160158 }
161159
@@ -369,20 +367,24 @@ pub(crate) mod module {
369367 }
370368
371369 #[ pyfunction]
372- fn get_handle_inheritable ( handle : isize , vm : & VirtualMachine ) -> PyResult < bool > {
370+ fn get_handle_inheritable ( handle : intptr_t , vm : & VirtualMachine ) -> PyResult < bool > {
373371 let mut flags = 0 ;
374- if unsafe { um :: handleapi :: GetHandleInformation ( handle as _ , & mut flags) } == 0 {
372+ if unsafe { Foundation :: GetHandleInformation ( handle as _ , & mut flags) } == 0 {
375373 Err ( errno_err ( vm) )
376374 } else {
377- Ok ( flags & um :: winbase :: HANDLE_FLAG_INHERIT != 0 )
375+ Ok ( flags & Foundation :: HANDLE_FLAG_INHERIT != 0 )
378376 }
379377 }
380378
381- pub fn raw_set_handle_inheritable ( handle : isize , inheritable : bool ) -> io:: Result < ( ) > {
382- use um:: winbase:: HANDLE_FLAG_INHERIT ;
383- let flags = if inheritable { HANDLE_FLAG_INHERIT } else { 0 } ;
384- let res =
385- unsafe { um:: handleapi:: SetHandleInformation ( handle as _ , HANDLE_FLAG_INHERIT , flags) } ;
379+ pub fn raw_set_handle_inheritable ( handle : intptr_t , inheritable : bool ) -> io:: Result < ( ) > {
380+ let flags = if inheritable {
381+ Foundation :: HANDLE_FLAG_INHERIT
382+ } else {
383+ 0
384+ } ;
385+ let res = unsafe {
386+ Foundation :: SetHandleInformation ( handle as _ , Foundation :: HANDLE_FLAG_INHERIT , flags)
387+ } ;
386388 if res == 0 {
387389 Err ( errno ( ) )
388390 } else {
@@ -410,7 +412,7 @@ pub(crate) mod module {
410412 let [ ] = dir_fd. 0 ;
411413 let _ = mode;
412414 let wide = path. to_widecstring ( vm) ?;
413- let res = unsafe { um :: fileapi :: CreateDirectoryW ( wide. as_ptr ( ) , std:: ptr:: null_mut ( ) ) } ;
415+ let res = unsafe { FileSystem :: CreateDirectoryW ( wide. as_ptr ( ) , std:: ptr:: null_mut ( ) ) } ;
414416 if res == 0 {
415417 return Err ( errno_err ( vm) ) ;
416418 }
0 commit comments