 
 ERROR: invalid-file-size n ;
 
-: handle>file-size ( handle -- n )
+: (handle>file-size) ( handle -- n )
     0 ulonglong <ref> [ GetFileSizeEx win32-error=0/f ] keep ulonglong deref ;
+
+! Returns T{ windows-error f 1 "Incorrect function." } if stream is not seekable
+: handle>file-size ( handle -- n/f )
+    '[ _ (handle>file-size) ]
+     [ dup n>> 1 = [ drop f ] [ rethrow ] if ] recover ;
 
 ERROR: seek-before-start n ;
 

    } case ;

M: windows can-seek-handle? ( handle -- ? )
    handle>> handle>file-size zero? not ;

M: windows handle-length ( handle -- n/f )
    handle>> handle>file-size [ f ] when-zero ;

: file-error? ( n -- eof? )
    zero? [

locals make math math.bitwise namespaces sequences
specialized-arrays system threads tr windows windows.errors
windows.handles windows.kernel32 windows.shell32 windows.time
windows.types fry ;
SPECIALIZED-ARRAY: ushort
IN: io.files.windows

