From d2accedf8d9c4786b7a1531264d6fa8cec125b57 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 29 Aug 2009 13:45:25 -0500 Subject: [PATCH] more structs --- basis/io/files/info/windows/windows.factor | 19 +++++------- basis/io/monitors/windows/nt/nt.factor | 12 +++----- basis/windows/kernel32/kernel32.factor | 35 +++++++++++----------- 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor index 587747ac34..684df6191e 100755 --- a/basis/io/files/info/windows/windows.factor +++ b/basis/io/files/info/windows/windows.factor @@ -35,20 +35,17 @@ TUPLE: windows-file-info < file-info attributes ; : WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info ) [ \ windows-file-info new ] dip { - [ WIN32_FIND_DATA-dwFileAttributes win32-file-type >>type ] - [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes >>attributes ] - [ - [ WIN32_FIND_DATA-nFileSizeLow ] - [ WIN32_FIND_DATA-nFileSizeHigh ] bi >64bit >>size - ] - [ WIN32_FIND_DATA-dwFileAttributes >>permissions ] - [ WIN32_FIND_DATA-ftCreationTime FILETIME>timestamp >>created ] - [ WIN32_FIND_DATA-ftLastWriteTime FILETIME>timestamp >>modified ] - [ WIN32_FIND_DATA-ftLastAccessTime FILETIME>timestamp >>accessed ] + [ dwFileAttributes>> win32-file-type >>type ] + [ dwFileAttributes>> win32-file-attributes >>attributes ] + [ [ nFileSizeLow>> ] [ nFileSizeHigh>> ] bi >64bit >>size ] + [ dwFileAttributes>> >>permissions ] + [ ftCreationTime>> FILETIME>timestamp >>created ] + [ ftLastWriteTime>> FILETIME>timestamp >>modified ] + [ ftLastAccessTime>> FILETIME>timestamp >>accessed ] } cleave ; : find-first-file-stat ( path -- WIN32_FIND_DATA ) - "WIN32_FIND_DATA" [ + WIN32_FIND_DATA [ FindFirstFile [ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep FindClose win32-error=0/f diff --git a/basis/io/monitors/windows/nt/nt.factor b/basis/io/monitors/windows/nt/nt.factor index bec249c04c..cd497b1c87 100755 --- a/basis/io/monitors/windows/nt/nt.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -55,17 +55,13 @@ TUPLE: win32-monitor < monitor port ; memory>byte-array utf16n decode ; : parse-notify-record ( buffer -- path changed ) - [ - [ FILE_NOTIFY_INFORMATION-FileName ] - [ FILE_NOTIFY_INFORMATION-FileNameLength ] - bi memory>u16-string - ] - [ FILE_NOTIFY_INFORMATION-Action parse-action ] bi ; + [ [ FileName>> ] [ FileNameLength>> ] bi memory>u16-string ] + [ Action>> parse-action ] bi ; : (file-notify-records) ( buffer -- buffer ) dup , - dup FILE_NOTIFY_INFORMATION-NextEntryOffset zero? [ - [ FILE_NOTIFY_INFORMATION-NextEntryOffset ] keep + dup NextEntryOffset>> zero? [ + [ NextEntryOffset>> ] [ ] bi (file-notify-records) ] unless ; diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 30007bb5a0..1adb07cf1e 100755 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -90,11 +90,12 @@ CONSTANT: FILE_ACTION_MODIFIED 3 CONSTANT: FILE_ACTION_RENAMED_OLD_NAME 4 CONSTANT: FILE_ACTION_RENAMED_NEW_NAME 5 -C-STRUCT: FILE_NOTIFY_INFORMATION - { "DWORD" "NextEntryOffset" } - { "DWORD" "Action" } - { "DWORD" "FileNameLength" } - { "WCHAR[1]" "FileName" } ; +STRUCT: FILE_NOTIFY_INFORMATION + { NextEntryOffset DWORD } + { Action DWORD } + { FileNameLength DWORD } + { FileName WCHAR[1] } ; + TYPEDEF: FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION CONSTANT: STD_INPUT_HANDLE -10 @@ -694,19 +695,17 @@ C-STRUCT: OFSTRUCT TYPEDEF: OFSTRUCT* LPOFSTRUCT -! MAX_PATH = 260 -C-STRUCT: WIN32_FIND_DATA - { "DWORD" "dwFileAttributes" } - { "FILETIME" "ftCreationTime" } - { "FILETIME" "ftLastAccessTime" } - { "FILETIME" "ftLastWriteTime" } - { "DWORD" "nFileSizeHigh" } - { "DWORD" "nFileSizeLow" } - { "DWORD" "dwReserved0" } - { "DWORD" "dwReserved1" } - ! { { "TCHAR" MAX_PATH } "cFileName" } - { { "TCHAR" 260 } "cFileName" } - { { "TCHAR" 14 } "cAlternateFileName" } ; +STRUCT: WIN32_FIND_DATA + { dwFileAttributes DWORD } + { ftCreationTime FILETIME } + { ftLastAccessTime FILETIME } + { ftLastWriteTime FILETIME } + { nFileSizeHigh DWORD } + { nFileSizeLow DWORD } + { dwReserved0 DWORD } + { dwReserved1 DWORD } + { cFileName { "TCHAR" MAX_PATH } } + { cAlternateFileName TCHAR[14] } ; STRUCT: BY_HANDLE_FILE_INFORMATION { dwFileAttributes DWORD } -- 2.34.1