From c1fe3854d452fc0aaf63aec95f417cd9fc16c523 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 31 Aug 2009 09:58:04 -0500 Subject: [PATCH] update io.files.*.windows to use specialized arrays; also, io.files.info.windows was providing buffers that were too small, so fix that --- basis/io/files/info/windows/windows.factor | 13 +++++++------ basis/io/files/windows/nt/nt.factor | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor index 587747ac34..a806e19af1 100755 --- a/basis/io/files/info/windows/windows.factor +++ b/basis/io/files/info/windows/windows.factor @@ -5,7 +5,8 @@ io.files.windows io.files.windows.nt kernel windows.kernel32 windows.time windows accessors alien.c-types combinators generalizations system alien.strings io.encodings.utf16n sequences splitting windows.errors fry continuations destructors -calendar ascii combinators.short-circuit locals classes.struct ; +calendar ascii combinators.short-circuit locals classes.struct +specialized-arrays.ushort ; IN: io.files.info.windows :: round-up-to ( n multiple -- n' ) @@ -100,11 +101,11 @@ M: windows link-info ( path -- info ) file-info ; : volume-information ( normalized-path -- volume-name volume-serial max-component flags type ) - MAX_PATH 1 + [ ] keep + MAX_PATH 1 + [ ] keep "DWORD" "DWORD" "DWORD" - MAX_PATH 1 + [ ] keep + MAX_PATH 1 + [ ] keep [ GetVolumeInformation win32-error=0/f ] 7 nkeep drop 5 nrot drop [ utf16n alien>string ] 4 ndip @@ -147,7 +148,7 @@ M: winnt file-system-info ( path -- file-system-info ) calculate-file-system-info ; : volume>paths ( string -- array ) - 16384 "ushort" tuck dup length + 16384 tuck dup length 0 dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [ win32-error-string throw ] [ @@ -156,13 +157,13 @@ M: winnt file-system-info ( path -- file-system-info ) ] if ; : find-first-volume ( -- string handle ) - MAX_PATH 1 + [ ] keep + MAX_PATH 1 + [ ] keep dupd FindFirstVolume dup win32-error=0/f [ utf16n alien>string ] dip ; : find-next-volume ( handle -- string/f ) - MAX_PATH 1 + [ tuck ] keep + MAX_PATH 1 + [ tuck ] keep FindNextVolume 0 = [ GetLastError ERROR_NO_MORE_FILES = [ drop f ] [ win32-error-string throw ] if diff --git a/basis/io/files/windows/nt/nt.factor b/basis/io/files/windows/nt/nt.factor index 32424a37a3..06bbca6f0d 100755 --- a/basis/io/files/windows/nt/nt.factor +++ b/basis/io/files/windows/nt/nt.factor @@ -5,11 +5,11 @@ windows.kernel32 kernel libc math threads system environment alien.c-types alien.arrays alien.strings sequences combinators combinators.short-circuit ascii splitting alien strings assocs namespaces make accessors tr windows.time windows.shell32 -windows.errors ; +windows.errors specialized-arrays.ushort ; IN: io.files.windows.nt M: winnt cwd - MAX_UNICODE_PATH dup "ushort" + MAX_UNICODE_PATH dup [ GetCurrentDirectory win32-error=0/f ] keep utf16n alien>string ;