parent
b80434b2e3
commit
e156e0212c
|
@ -445,6 +445,18 @@ C-STRUCT: WIN32_FIND_DATA
|
||||||
{ { "TCHAR" 260 } "cFileName" }
|
{ { "TCHAR" 260 } "cFileName" }
|
||||||
{ { "TCHAR" 14 } "cAlternateFileName" } ;
|
{ { "TCHAR" 14 } "cAlternateFileName" } ;
|
||||||
|
|
||||||
|
C-STRUCT: BY_HANDLE_FILE_INFORMATION
|
||||||
|
{ "DWORD" "dwFileAttributes" }
|
||||||
|
{ "FILETIME" "ftCreationTime" }
|
||||||
|
{ "FILETIME" "ftLastAccessTime" }
|
||||||
|
{ "FILETIME" "ftLastWriteTime" }
|
||||||
|
{ "DWORD" "dwVolumeSerialNumber" }
|
||||||
|
{ "DWORD" "nFileSizeHigh" }
|
||||||
|
{ "DWORD" "nFileSizeLow" }
|
||||||
|
{ "DWORD" "nNumberOfLinks" }
|
||||||
|
{ "DWORD" "nFileIndexHigh" }
|
||||||
|
{ "DWORD" "nFileIndexLow" } ;
|
||||||
|
|
||||||
TYPEDEF: WIN32_FIND_DATA* PWIN32_FIND_DATA
|
TYPEDEF: WIN32_FIND_DATA* PWIN32_FIND_DATA
|
||||||
TYPEDEF: WIN32_FIND_DATA* LPWIN32_FIND_DATA
|
TYPEDEF: WIN32_FIND_DATA* LPWIN32_FIND_DATA
|
||||||
TYPEDEF: void* POVERLAPPED
|
TYPEDEF: void* POVERLAPPED
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
! Copyright (C) 2007 Doug Coleman.
|
! Copyright (C) 2007 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien alien.c-types kernel math windows windows.kernel32
|
USING: alien alien.c-types kernel math windows windows.kernel32
|
||||||
namespaces calendar.backend ;
|
namespaces calendar calendar.backend ;
|
||||||
IN: windows.time
|
IN: windows.time
|
||||||
|
|
||||||
: >64bit ( lo hi -- n )
|
: >64bit ( lo hi -- n )
|
||||||
32 shift bitor ;
|
32 shift bitor ;
|
||||||
|
|
||||||
: windows-1601 ( -- timestamp )
|
: windows-1601 ( -- timestamp )
|
||||||
1601 1 1 0 0 0 0 <timestamp> ;
|
1601 1 1 0 0 0 0 <timestamp> ;
|
||||||
|
|
||||||
: FILETIME>windows-time ( FILETIME -- n )
|
: FILETIME>windows-time ( FILETIME -- n )
|
||||||
[ FILETIME-dwLowDateTime ] keep
|
[ FILETIME-dwLowDateTime ] keep
|
||||||
FILETIME-dwHighDateTime >64bit ;
|
FILETIME-dwHighDateTime >64bit ;
|
||||||
|
|
||||||
: windows-time>timestamp ( n -- timestamp )
|
: windows-time>timestamp ( n -- timestamp )
|
||||||
10000000 /i seconds windows-1601 swap time+ ;
|
10000000 /i seconds windows-1601 swap time+ ;
|
||||||
|
|
||||||
: windows-time ( -- n )
|
: windows-time ( -- n )
|
||||||
"FILETIME" <c-object> [ GetSystemTimeAsFileTime ] keep
|
"FILETIME" <c-object> [ GetSystemTimeAsFileTime ] keep
|
||||||
FILETIME>windows-time ;
|
FILETIME>windows-time ;
|
||||||
|
|
||||||
: timestamp>windows-time ( timestamp -- n )
|
: timestamp>windows-time ( timestamp -- n )
|
||||||
#! 64bit number representing # of nanoseconds since Jan 1, 1601 (UTC)
|
#! 64bit number representing # of nanoseconds since Jan 1, 1601 (UTC)
|
||||||
>gmt windows-1601 (time-) 10000000 * >integer ;
|
>gmt windows-1601 (time-) 10000000 * >integer ;
|
||||||
|
|
||||||
: windows-time>FILETIME ( n -- FILETIME )
|
: windows-time>FILETIME ( n -- FILETIME )
|
||||||
"FILETIME" <c-object>
|
"FILETIME" <c-object>
|
||||||
[
|
[
|
||||||
[ >r HEX: ffffffff bitand r> set-FILETIME-dwLowDateTime ] 2keep
|
[ >r HEX: ffffffff bitand r> set-FILETIME-dwLowDateTime ] 2keep
|
||||||
>r -32 shift r> set-FILETIME-dwHighDateTime
|
>r -32 shift r> set-FILETIME-dwHighDateTime
|
||||||
] keep ;
|
] keep ;
|
||||||
|
|
||||||
: timestamp>FILETIME ( timestamp -- FILETIME/f )
|
: timestamp>FILETIME ( timestamp -- FILETIME/f )
|
||||||
[ >gmt timestamp>windows-time windows-time>FILETIME ] [ f ] if* ;
|
[ >gmt timestamp>windows-time windows-time>FILETIME ] [ f ] if* ;
|
||||||
|
|
||||||
: FILETIME>timestamp ( FILETIME -- timestamp/f )
|
: FILETIME>timestamp ( FILETIME -- timestamp/f )
|
||||||
FILETIME>windows-time windows-time>timestamp ;
|
FILETIME>windows-time windows-time>timestamp ;
|
||||||
|
|
Loading…
Reference in New Issue