@@ -23,14 +23,16 @@ pub(crate) mod module {
2323 } ,
2424 PyResult , TryFromObject , VirtualMachine ,
2525 } ;
26+ use libc:: intptr_t;
2627 use std:: {
2728 env, fs, io,
2829 mem:: MaybeUninit ,
2930 os:: windows:: ffi:: { OsStrExt , OsStringExt } ,
3031 } ;
31- use winapi:: { um , vc :: vcruntime :: intptr_t } ;
32+ use winapi:: um ;
3233 use windows_sys:: Win32 :: {
3334 Foundation :: { CloseHandle , INVALID_HANDLE_VALUE } ,
35+ Storage :: FileSystem ,
3436 System :: { Console , Threading } ,
3537 } ;
3638
@@ -39,9 +41,9 @@ pub(crate) mod module {
3941
4042 #[ pyfunction]
4143 pub ( super ) fn access ( path : OsPath , mode : u8 , vm : & VirtualMachine ) -> PyResult < bool > {
42- use um:: { fileapi , winnt} ;
43- let attr = unsafe { fileapi :: GetFileAttributesW ( path. to_widecstring ( vm) ?. as_ptr ( ) ) } ;
44- Ok ( attr != fileapi :: INVALID_FILE_ATTRIBUTES
44+ use um:: winnt;
45+ let attr = unsafe { FileSystem :: GetFileAttributesW ( path. to_widecstring ( vm) ?. as_ptr ( ) ) } ;
46+ Ok ( attr != FileSystem :: INVALID_FILE_ATTRIBUTES
4547 && ( mode & 2 == 0
4648 || attr & winnt:: FILE_ATTRIBUTE_READONLY == 0
4749 || attr & winnt:: FILE_ATTRIBUTE_DIRECTORY != 0 ) )
@@ -252,7 +254,7 @@ pub(crate) mod module {
252254 let wpath = path. to_widecstring ( vm) ?;
253255 let mut buffer = vec ! [ 0u16 ; winapi:: shared:: minwindef:: MAX_PATH ] ;
254256 let ret = unsafe {
255- um :: fileapi :: GetFullPathNameW (
257+ FileSystem :: GetFullPathNameW (
256258 wpath. as_ptr ( ) ,
257259 buffer. len ( ) as _ ,
258260 buffer. as_mut_ptr ( ) ,
@@ -265,7 +267,7 @@ pub(crate) mod module {
265267 if ret as usize > buffer. len ( ) {
266268 buffer. resize ( ret as usize , 0 ) ;
267269 let ret = unsafe {
268- um :: fileapi :: GetFullPathNameW (
270+ FileSystem :: GetFullPathNameW (
269271 wpath. as_ptr ( ) ,
270272 buffer. len ( ) as _ ,
271273 buffer. as_mut_ptr ( ) ,
@@ -286,7 +288,7 @@ pub(crate) mod module {
286288 let buflen = std:: cmp:: max ( wide. len ( ) , winapi:: shared:: minwindef:: MAX_PATH ) ;
287289 let mut buffer = vec ! [ 0u16 ; buflen] ;
288290 let ret = unsafe {
289- um :: fileapi :: GetVolumePathNameW ( wide. as_ptr ( ) , buffer. as_mut_ptr ( ) , buflen as _ )
291+ FileSystem :: GetVolumePathNameW ( wide. as_ptr ( ) , buffer. as_mut_ptr ( ) , buflen as _ )
290292 } ;
291293 if ret == 0 {
292294 return Err ( errno_err ( vm) ) ;
@@ -335,17 +337,17 @@ pub(crate) mod module {
335337
336338 #[ pyfunction]
337339 fn _getdiskusage ( path : OsPath , vm : & VirtualMachine ) -> PyResult < ( u64 , u64 ) > {
338- use um :: fileapi :: GetDiskFreeSpaceExW ;
339- use winapi :: shared :: { ntdef :: ULARGE_INTEGER , winerror } ;
340+ use winapi :: shared :: winerror ;
341+ use FileSystem :: GetDiskFreeSpaceExW ;
340342
341343 let wpath = path. to_widecstring ( vm) ?;
342- let mut _free_to_me = ULARGE_INTEGER :: default ( ) ;
343- let mut total = ULARGE_INTEGER :: default ( ) ;
344- let mut free = ULARGE_INTEGER :: default ( ) ;
344+ let mut _free_to_me: u64 = 0 ;
345+ let mut total: u64 = 0 ;
346+ let mut free: u64 = 0 ;
345347 let ret =
346348 unsafe { GetDiskFreeSpaceExW ( wpath. as_ptr ( ) , & mut _free_to_me, & mut total, & mut free) } ;
347349 if ret != 0 {
348- return Ok ( unsafe { ( * total. QuadPart ( ) , * free. QuadPart ( ) ) } ) ;
350+ return Ok ( ( total, free) ) ;
349351 }
350352 let err = io:: Error :: last_os_error ( ) ;
351353 if err. raw_os_error ( ) == Some ( winerror:: ERROR_DIRECTORY as i32 ) {
@@ -359,15 +361,15 @@ pub(crate) mod module {
359361 return if ret == 0 {
360362 Err ( errno_err ( vm) )
361363 } else {
362- Ok ( unsafe { ( * total. QuadPart ( ) , * free. QuadPart ( ) ) } )
364+ Ok ( ( total, free) )
363365 } ;
364366 }
365367 }
366368 Err ( err. to_pyexception ( vm) )
367369 }
368370
369371 #[ pyfunction]
370- fn get_handle_inheritable ( handle : intptr_t , vm : & VirtualMachine ) -> PyResult < bool > {
372+ fn get_handle_inheritable ( handle : isize , vm : & VirtualMachine ) -> PyResult < bool > {
371373 let mut flags = 0 ;
372374 if unsafe { um:: handleapi:: GetHandleInformation ( handle as _ , & mut flags) } == 0 {
373375 Err ( errno_err ( vm) )
@@ -376,7 +378,7 @@ pub(crate) mod module {
376378 }
377379 }
378380
379- pub fn raw_set_handle_inheritable ( handle : intptr_t , inheritable : bool ) -> io:: Result < ( ) > {
381+ pub fn raw_set_handle_inheritable ( handle : isize , inheritable : bool ) -> io:: Result < ( ) > {
380382 use um:: winbase:: HANDLE_FLAG_INHERIT ;
381383 let flags = if inheritable { HANDLE_FLAG_INHERIT } else { 0 } ;
382384 let res =
0 commit comments