File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,15 @@ compat_fn_with_fallback! {
341
341
pub fn GetTempPath2W ( bufferlength: u32 , buffer: PWSTR ) -> u32 {
342
342
GetTempPathW ( bufferlength, buffer)
343
343
}
344
+
345
+ // >= 95 / NT 3.5
346
+ // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
347
+ pub fn GetSystemTimeAsFileTime ( lpSystemTimeAsFileTime: * mut FILETIME ) -> ( ) {
348
+ // implementation based on old MSDN docs
349
+ let mut st: SYSTEMTIME = crate :: mem:: zeroed( ) ;
350
+ GetSystemTime ( & mut st) ;
351
+ crate :: sys:: cvt( SystemTimeToFileTime ( & st, lpSystemTimeAsFileTime) ) . unwrap( ) ;
352
+ }
344
353
}
345
354
346
355
compat_fn_optional ! {
Original file line number Diff line number Diff line change @@ -2608,3 +2608,7 @@ Windows.Win32.System.Threading.LeaveCriticalSection
2608
2608
Windows.Win32.System.Threading.DeleteCriticalSection
2609
2609
Windows.Win32.System.Threading.SRWLOCK
2610
2610
Windows.Win32.System.Threading.CONDITION_VARIABLE
2611
+
2612
+ // system time fallback
2613
+ Windows.Win32.System.SystemInformation.GetSystemTime
2614
+ Windows.Win32.System.Time.SystemTimeToFileTime
Original file line number Diff line number Diff line change @@ -381,6 +381,10 @@ extern "system" {
381
381
pub fn GetSystemInfo ( lpsysteminfo : * mut SYSTEM_INFO ) -> ( ) ;
382
382
}
383
383
#[ link( name = "kernel32" ) ]
384
+ extern "system" {
385
+ pub fn GetSystemTime ( lpsystemtime : * mut SYSTEMTIME ) -> ( ) ;
386
+ }
387
+ #[ link( name = "kernel32" ) ]
384
388
extern "system" {
385
389
pub fn GetSystemTimeAsFileTime ( lpsystemtimeasfiletime : * mut FILETIME ) -> ( ) ;
386
390
}
@@ -594,6 +598,11 @@ extern "system" {
594
598
pub fn SwitchToThread ( ) -> BOOL ;
595
599
}
596
600
#[ link( name = "kernel32" ) ]
601
+ extern "system" {
602
+ pub fn SystemTimeToFileTime ( lpsystemtime : * const SYSTEMTIME , lpfiletime : * mut FILETIME )
603
+ -> BOOL ;
604
+ }
605
+ #[ link( name = "kernel32" ) ]
597
606
extern "system" {
598
607
pub fn TerminateProcess ( hprocess : HANDLE , uexitcode : u32 ) -> BOOL ;
599
608
}
@@ -4063,6 +4072,23 @@ pub const SYMLINK_FLAG_RELATIVE: u32 = 1u32;
4063
4072
pub type SYNCHRONIZATION_ACCESS_RIGHTS = u32 ;
4064
4073
pub const SYNCHRONIZE : FILE_ACCESS_RIGHTS = 1048576u32 ;
4065
4074
#[ repr( C ) ]
4075
+ pub struct SYSTEMTIME {
4076
+ pub wYear : u16 ,
4077
+ pub wMonth : u16 ,
4078
+ pub wDayOfWeek : u16 ,
4079
+ pub wDay : u16 ,
4080
+ pub wHour : u16 ,
4081
+ pub wMinute : u16 ,
4082
+ pub wSecond : u16 ,
4083
+ pub wMilliseconds : u16 ,
4084
+ }
4085
+ impl :: core:: marker:: Copy for SYSTEMTIME { }
4086
+ impl :: core:: clone:: Clone for SYSTEMTIME {
4087
+ fn clone ( & self ) -> Self {
4088
+ * self
4089
+ }
4090
+ }
4091
+ #[ repr( C ) ]
4066
4092
pub struct SYSTEM_INFO {
4067
4093
pub Anonymous : SYSTEM_INFO_0 ,
4068
4094
pub dwPageSize : u32 ,
You can’t perform that action at this time.
0 commit comments