 
 HOOK: root-directory os ( string -- string' )
 
-: file-system-type ( normalized-path -- str )
-    MAX_PATH 1+ <byte-array>
-    MAX_PATH 1+
-    "DWORD" <c-object> "DWORD" <c-object> "DWORD" <c-object>
-    MAX_PATH 1+ <byte-array>
-    MAX_PATH 1+
-    [ GetVolumeInformation win32-error=0/f ] 2keep drop
+: volume-information ( normalized-path -- volume-name volume-serial max-component flags type )
+    MAX_PATH 1+ [ <byte-array> ] keep
+    "DWORD" <c-object>
+    "DWORD" <c-object>
+    "DWORD" <c-object>
+    MAX_PATH 1+ [ <byte-array> ] keep
+    [ GetVolumeInformation win32-error=0/f ] 7 nkeep
+    drop 5 nrot drop
+    [ utf16n alien>string ] 4 ndip
     utf16n alien>string ;
 
 : file-system-space ( normalized-path -- available-space total-space free-space )

        [ ]
    } cleave ;

M: winnt file-system-info ( path -- file-system-info )
    normalize-path root-directory
    dup [ file-system-type ] [ file-system-space ] bi
    \ file-system-info new
        swap *ulonglong >>free-space
        swap *ulonglong >>total-space
        swap *ulonglong >>available-space
        swap >>type
        swap >>mount-point
    calculate-file-system-info ;


    ] if ;

: find-first-volume ( -- string handle )
    MAX_PATH 1+ [ <byte-array> ] keep
    dupd
    FindFirstVolume dup win32-error=0/f
    [ utf16n alien>string ] dip ;

: find-next-volume ( handle -- string/f )
    MAX_PATH 1+ [ <byte-array> tuck ] keep
    FindNextVolume 0 = [
        GetLastError ERROR_NO_MORE_FILES =
        [ drop f ] [ win32-error-string throw ] if
    ] [
        utf16n alien>string
    ] if ;
