use structs in a few places in windows backend
parent
847cd797bb
commit
3507616f3b
|
@ -3,7 +3,7 @@ destructors io io.backend io.ports io.timeouts io.backend.windows
|
|||
io.files.windows io.files.windows.nt io.files io.pathnames io.buffers
|
||||
io.streams.c io.streams.null libc kernel math namespaces sequences
|
||||
threads windows windows.errors windows.kernel32 strings splitting
|
||||
ascii system accessors locals ;
|
||||
ascii system accessors locals classes.struct ;
|
||||
QUALIFIED: windows.winsock
|
||||
IN: io.backend.windows.nt
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ USING: alien alien.c-types arrays destructors io io.backend
|
|||
io.buffers io.files io.ports io.binary io.timeouts system
|
||||
strings kernel math namespaces sequences windows.errors
|
||||
windows.kernel32 windows.shell32 windows.types windows.winsock
|
||||
splitting continuations math.bitwise accessors init sets assocs ;
|
||||
splitting continuations math.bitwise accessors init sets assocs
|
||||
classes.struct classes ;
|
||||
IN: io.backend.windows
|
||||
|
||||
TUPLE: win32-handle < disposable handle ;
|
||||
|
@ -50,6 +51,5 @@ HOOK: add-completion io-backend ( port -- )
|
|||
} flags ; foldable
|
||||
|
||||
: default-security-attributes ( -- obj )
|
||||
"SECURITY_ATTRIBUTES" <c-object>
|
||||
"SECURITY_ATTRIBUTES" heap-size
|
||||
over set-SECURITY_ATTRIBUTES-nLength ;
|
||||
SECURITY_ATTRIBUTES <struct>
|
||||
dup class heap-size >>nLength ;
|
||||
|
|
|
@ -5,7 +5,7 @@ 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 ;
|
||||
calendar ascii combinators.short-circuit locals classes.struct ;
|
||||
IN: io.files.info.windows
|
||||
|
||||
:: round-up-to ( n multiple -- n' )
|
||||
|
@ -57,35 +57,26 @@ TUPLE: windows-file-info < file-info attributes ;
|
|||
: BY_HANDLE_FILE_INFORMATION>file-info ( HANDLE_FILE_INFORMATION -- file-info )
|
||||
[ \ windows-file-info new ] dip
|
||||
{
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-type >>type ]
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-attributes >>attributes ]
|
||||
[ dwFileAttributes>> win32-file-type >>type ]
|
||||
[ dwFileAttributes>> win32-file-attributes >>attributes ]
|
||||
[
|
||||
[ BY_HANDLE_FILE_INFORMATION-nFileSizeLow ]
|
||||
[ BY_HANDLE_FILE_INFORMATION-nFileSizeHigh ] bi >64bit >>size
|
||||
[ nFileSizeLow>> ]
|
||||
[ nFileSizeHigh>> ] bi >64bit >>size
|
||||
]
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>permissions ]
|
||||
[
|
||||
BY_HANDLE_FILE_INFORMATION-ftCreationTime
|
||||
FILETIME>timestamp >>created
|
||||
]
|
||||
[
|
||||
BY_HANDLE_FILE_INFORMATION-ftLastWriteTime
|
||||
FILETIME>timestamp >>modified
|
||||
]
|
||||
[
|
||||
BY_HANDLE_FILE_INFORMATION-ftLastAccessTime
|
||||
FILETIME>timestamp >>accessed
|
||||
]
|
||||
! [ BY_HANDLE_FILE_INFORMATION-nNumberOfLinks ]
|
||||
[ dwFileAttributes>> >>permissions ]
|
||||
[ ftCreationTime>> FILETIME>timestamp >>created ]
|
||||
[ ftLastWriteTime>> FILETIME>timestamp >>modified ]
|
||||
[ ftLastAccessTime>> FILETIME>timestamp >>accessed ]
|
||||
! [ nNumberOfLinks>> ]
|
||||
! [
|
||||
! [ BY_HANDLE_FILE_INFORMATION-nFileIndexLow ]
|
||||
! [ BY_HANDLE_FILE_INFORMATION-nFileIndexHigh ] bi >64bit
|
||||
! [ nFileIndexLow>> ]
|
||||
! [ nFileIndexHigh>> ] bi >64bit
|
||||
! ]
|
||||
} cleave ;
|
||||
|
||||
: get-file-information ( handle -- BY_HANDLE_FILE_INFORMATION )
|
||||
[
|
||||
"BY_HANDLE_FILE_INFORMATION" <c-object>
|
||||
BY_HANDLE_FILE_INFORMATION <struct>
|
||||
[ GetFileInformationByHandle win32-error=0/f ] keep
|
||||
] keep CloseHandle win32-error=0/f ;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
! Copyright (C) 2005, 2006 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.syntax kernel windows.types multiline ;
|
||||
USING: alien alien.syntax kernel windows.types multiline
|
||||
classes.struct ;
|
||||
IN: windows.kernel32
|
||||
|
||||
CONSTANT: MAX_PATH 260
|
||||
|
@ -707,17 +708,17 @@ C-STRUCT: WIN32_FIND_DATA
|
|||
{ { "TCHAR" 260 } "cFileName" }
|
||||
{ { "TCHAR" 14 } "cAlternateFileName" } ;
|
||||
|
||||
C-STRUCT: BY_HANDLE_FILE_INFORMATION
|
||||
{ "DWORD" "dwFileAttributes" }
|
||||
{ "FILETIME" "ftCreationTime" }
|
||||
{ "FILETIME" "ftLastAccessTime" }
|
||||
{ "FILETIME" "ftLastWriteTime" }
|
||||
{ "DWORD" "dwVolumeSerialNumber" }
|
||||
{ "DWORD" "nFileSizeHigh" }
|
||||
{ "DWORD" "nFileSizeLow" }
|
||||
{ "DWORD" "nNumberOfLinks" }
|
||||
{ "DWORD" "nFileIndexHigh" }
|
||||
{ "DWORD" "nFileIndexLow" } ;
|
||||
STRUCT: BY_HANDLE_FILE_INFORMATION
|
||||
{ dwFileAttributes DWORD }
|
||||
{ ftCreationTime FILETIME }
|
||||
{ ftLastAccessTime FILETIME }
|
||||
{ ftLastWriteTime FILETIME }
|
||||
{ dwVolumeSerialNumber DWORD }
|
||||
{ nFileSizeHigh DWORD }
|
||||
{ nFileSizeLow DWORD }
|
||||
{ nNumberOfLinks DWORD }
|
||||
{ nFileIndexHigh DWORD }
|
||||
{ nFileIndexLow DWORD } ;
|
||||
|
||||
TYPEDEF: WIN32_FIND_DATA* PWIN32_FIND_DATA
|
||||
TYPEDEF: WIN32_FIND_DATA* LPWIN32_FIND_DATA
|
||||
|
@ -737,10 +738,10 @@ TYPEDEF: PFILETIME LPFILETIME
|
|||
|
||||
TYPEDEF: int GET_FILEEX_INFO_LEVELS
|
||||
|
||||
C-STRUCT: SECURITY_ATTRIBUTES
|
||||
{ "DWORD" "nLength" }
|
||||
{ "LPVOID" "lpSecurityDescriptor" }
|
||||
{ "BOOL" "bInheritHandle" } ;
|
||||
STRUCT: SECURITY_ATTRIBUTES
|
||||
{ nLength DWORD }
|
||||
{ lpSecurityDescriptor LPVOID }
|
||||
{ bInheritHandle BOOL } ;
|
||||
|
||||
CONSTANT: HANDLE_FLAG_INHERIT 1
|
||||
CONSTANT: HANDLE_FLAG_PROTECT_FROM_CLOSE 2
|
||||
|
|
Loading…
Reference in New Issue