]> gitweb.factorcode.org Git - factor.git/commitdiff
io.directories.windows: fix truncate-file
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 May 2023 19:09:42 +0000 (12:09 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 May 2023 19:09:42 +0000 (12:09 -0700)
basis/io/directories/windows/windows.factor

index 421fc61bf492804b51dfb012d4cf27e13e0d51b7..e51bda8433ebbac517c5422b7cd6164da399d3c1 100644 (file)
@@ -12,9 +12,12 @@ M: windows touch-file
         _ [ drop ] [ handle>> f now dup (set-file-times) ] if
     ] with-disposal ;
 
+: open-truncate ( path -- win32-file )
+    GENERIC_WRITE OPEN_EXISTING 0 open-file 0 >>ptr ;
+
 M: windows truncate-file
-    [ normalize-path open-file ] dip '[
-        [ _ FILE_END set-file-pointer ] [ set-end-of-file ] bi
+    [ normalize-path open-truncate ] dip '[
+        [ _ FILE_BEGIN set-file-pointer ] [ set-end-of-file ] bi
     ] with-disposal ;
 
 M: windows move-file