]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/time/time.factor
less aggressive open-file for file-times, use FILETIME struct now
[factor.git] / basis / windows / time / time.factor
index 71726a554a8fadb123bc988239e2fbf275a4ca84..1fe3ad065cb881eefd316f1e16f8d0d5443ba889 100644 (file)
@@ -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 <timestamp> ;
 
 : 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" <c-object> [ GetSystemTimeAsFileTime ] keep
+    FILETIME <struct> [ 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" <c-object>
-    [
-        [ [ 32 bits ] dip set-FILETIME-dwLowDateTime ]
-        [ [ -32 shift ] dip set-FILETIME-dwHighDateTime ] 2bi
-    ] keep ;
+    [ FILETIME <struct> ] dip
+    [ 32 bits >>dwLowDateTime ] [ -32 shift >>dwHighDateTime ] bi ;
 
 : timestamp>FILETIME ( timestamp -- FILETIME/f )
     dup [ >gmt timestamp>windows-time windows-time>FILETIME ] when ;