From c50eaf1c29a0b40ec330e3b33716a00bca5ef8ff Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 25 Aug 2009 17:34:06 -0500 Subject: [PATCH] less aggressive open-file for file-times, use FILETIME struct now --- .../files/info/windows/windows-tests.factor | 6 +++++ basis/io/files/info/windows/windows.factor | 8 +++---- basis/windows/kernel32/kernel32.factor | 24 +++++++++---------- basis/windows/time/time.factor | 16 +++++-------- 4 files changed, 28 insertions(+), 26 deletions(-) create mode 100755 basis/io/files/info/windows/windows-tests.factor diff --git a/basis/io/files/info/windows/windows-tests.factor b/basis/io/files/info/windows/windows-tests.factor new file mode 100755 index 0000000000..8728c2c31c --- /dev/null +++ b/basis/io/files/info/windows/windows-tests.factor @@ -0,0 +1,6 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test io.files.info.windows system kernel ; +IN: io.files.info.windows.tests + +[ ] [ vm file-times 3drop ] unit-test diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor index 248eacf571..587747ac34 100755 --- a/basis/io/files/info/windows/windows.factor +++ b/basis/io/files/info/windows/windows.factor @@ -188,10 +188,10 @@ M: winnt file-systems ( -- array ) : file-times ( path -- timestamp timestamp timestamp ) [ - normalize-path open-existing &dispose handle>> - "FILETIME" - "FILETIME" - "FILETIME" + normalize-path open-read &dispose handle>> + FILETIME + FILETIME + FILETIME [ GetFileTime win32-error=0/f ] 3keep [ FILETIME>timestamp >local-time ] tri@ ] with-destructors ; diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index d1fee4c388..65425c2685 100755 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -216,15 +216,15 @@ C-STRUCT: OVERLAPPED { "DWORD" "offset-high" } { "HANDLE" "event" } ; -C-STRUCT: SYSTEMTIME - { "WORD" "wYear" } - { "WORD" "wMonth" } - { "WORD" "wDayOfWeek" } - { "WORD" "wDay" } - { "WORD" "wHour" } - { "WORD" "wMinute" } - { "WORD" "wSecond" } - { "WORD" "wMilliseconds" } ; +STRUCT: SYSTEMTIME + { wYear WORD } + { wMonth WORD } + { wDayOfWeek WORD } + { wDay WORD } + { wHour WORD } + { wMinute WORD } + { wSecond WORD } + { wMilliseconds WORD } ; C-STRUCT: TIME_ZONE_INFORMATION { "LONG" "Bias" } @@ -235,9 +235,9 @@ C-STRUCT: TIME_ZONE_INFORMATION { "SYSTEMTIME" "DaylightDate" } { "LONG" "DaylightBias" } ; -C-STRUCT: FILETIME - { "DWORD" "dwLowDateTime" } - { "DWORD" "dwHighDateTime" } ; +STRUCT: FILETIME + { dwLowDateTime DWORD } + { dwHighDateTime DWORD } ; C-STRUCT: STARTUPINFO { "DWORD" "cb" } diff --git a/basis/windows/time/time.factor b/basis/windows/time/time.factor index 71726a554a..1fe3ad065c 100644 --- a/basis/windows/time/time.factor +++ b/basis/windows/time/time.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types kernel math windows.errors -windows.kernel32 namespaces calendar math.bitwise ; +windows.kernel32 namespaces calendar math.bitwise accessors +classes.struct ; IN: windows.time : >64bit ( lo hi -- n ) @@ -11,15 +12,13 @@ IN: windows.time 1601 1 1 0 0 0 instant ; : FILETIME>windows-time ( FILETIME -- n ) - [ FILETIME-dwLowDateTime ] - [ FILETIME-dwHighDateTime ] - bi >64bit ; + [ dwLowDateTime>> ] [ dwHighDateTime>> ] bi >64bit ; : windows-time>timestamp ( n -- timestamp ) 10000000 /i seconds windows-1601 swap time+ ; : windows-time ( -- n ) - "FILETIME" [ GetSystemTimeAsFileTime ] keep + FILETIME [ GetSystemTimeAsFileTime ] keep FILETIME>windows-time ; : timestamp>windows-time ( timestamp -- n ) @@ -27,11 +26,8 @@ IN: windows.time >gmt windows-1601 (time-) 10000000 * >integer ; : windows-time>FILETIME ( n -- FILETIME ) - "FILETIME" - [ - [ [ 32 bits ] dip set-FILETIME-dwLowDateTime ] - [ [ -32 shift ] dip set-FILETIME-dwHighDateTime ] 2bi - ] keep ; + [ FILETIME ] dip + [ 32 bits >>dwLowDateTime ] [ -32 shift >>dwHighDateTime ] bi ; : timestamp>FILETIME ( timestamp -- FILETIME/f ) dup [ >gmt timestamp>windows-time windows-time>FILETIME ] when ; -- 2.34.1