update dirent for structs

db4
Doug Coleman 2009-08-30 22:11:42 -05:00
parent d5a7dde7ee
commit 14973eacb5
6 changed files with 41 additions and 41 deletions

View File

@ -4,7 +4,7 @@ USING: accessors alien.c-types alien.strings combinators
continuations destructors fry io io.backend io.backend.unix
io.directories io.encodings.binary io.encodings.utf8 io.files
io.pathnames io.files.types kernel math.bitwise sequences system
unix unix.stat vocabs.loader ;
unix unix.stat vocabs.loader classes.struct ;
IN: io.directories.unix
: touch-mode ( -- n )
@ -37,7 +37,7 @@ M: unix copy-file ( from to -- )
HOOK: find-next-file os ( DIR* -- byte-array )
M: unix find-next-file ( DIR* -- byte-array )
"dirent" <c-object>
dirent <struct>
f <void*>
[ readdir_r 0 = [ (io-error) ] unless ] 2keep
*void* [ drop f ] unless ;
@ -57,8 +57,8 @@ M: unix find-next-file ( DIR* -- byte-array )
M: unix >directory-entry ( byte-array -- directory-entry )
{
[ dirent-d_name underlying>> utf8 alien>string ]
[ dirent-d_type dirent-type>file-type ]
[ d_name>> underlying>> utf8 alien>string ]
[ d_type>> dirent-type>file-type ]
} cleave directory-entry boa ;
M: unix (directory-entries) ( path -- seq )

View File

@ -1,4 +1,4 @@
USING: alien.syntax ;
USING: alien.syntax classes.struct ;
IN: unix
CONSTANT: FD_SETSIZE 1024
@ -13,12 +13,12 @@ C-STRUCT: addrinfo
{ "void*" "addr" }
{ "addrinfo*" "next" } ;
C-STRUCT: dirent
{ "u_int32_t" "d_fileno" }
{ "u_int16_t" "d_reclen" }
{ "u_int8_t" "d_type" }
{ "u_int8_t" "d_namlen" }
{ { "char" 256 } "d_name" } ;
STRUCT: dirent
{ d_fileno u_int32_t }
{ d_reclen u_int16_t }
{ d_type u_int8_t }
{ d_namlen u_int8_t }
{ d_name char[256] } ;
CONSTANT: EPERM 1
CONSTANT: ENOENT 2

View File

@ -1,4 +1,4 @@
USING: alien.syntax unix.time ;
USING: alien.syntax unix.time classes.struct ;
IN: unix
CONSTANT: FD_SETSIZE 1024
@ -32,12 +32,12 @@ CONSTANT: __DARWIN_MAXPATHLEN 1024
CONSTANT: __DARWIN_MAXNAMELEN 255
CONSTANT: __DARWIN_MAXNAMELEN+1 255
C-STRUCT: dirent
{ "ino_t" "d_ino" }
{ "__uint16_t" "d_reclen" }
{ "__uint8_t" "d_type" }
{ "__uint8_t" "d_namlen" }
{ { "char" __DARWIN_MAXNAMELEN+1 } "d_name" } ;
STRUCT: dirent
{ d_ino ino_t }
{ d_reclen __uint16_t }
{ d_type __uint8_t }
{ d_namlen __uint8_t }
{ d_name { "char" __DARWIN_MAXNAMELEN+1 } } ;
CONSTANT: EPERM 1
CONSTANT: ENOENT 2

View File

@ -1,4 +1,5 @@
USING: alien.syntax alien.c-types math vocabs.loader ;
USING: alien.syntax alien.c-types math vocabs.loader
classes.struct ;
IN: unix
CONSTANT: FD_SETSIZE 256
@ -13,12 +14,12 @@ C-STRUCT: addrinfo
{ "void*" "addr" }
{ "addrinfo*" "next" } ;
C-STRUCT: dirent
{ "__uint32_t" "d_fileno" }
{ "__uint16_t" "d_reclen" }
{ "__uint8_t" "d_type" }
{ "__uint8_t" "d_namlen" }
{ { "char" 256 } "d_name" } ;
STRUCT: dirent
{ d_fileno __uint32_t }
{ d_reclen __uint16_t }
{ d_type __uint8_t }
{ d_namlen __uint8_t }
{ d_name char[256] } ;
CONSTANT: EPERM 1
CONSTANT: ENOENT 2
@ -126,8 +127,7 @@ CONSTANT: _UTX_LINESIZE 32
CONSTANT: _UTX_IDSIZE 4
CONSTANT: _UTX_HOSTSIZE 256
: _SS_MAXSIZE ( -- n )
128 ; inline
CONSTANT: _SS_MAXSIZE 128
: _SS_ALIGNSIZE ( -- n )
"__int64_t" heap-size ; inline

View File

@ -1,4 +1,4 @@
USING: alien.syntax ;
USING: alien.syntax classes.struct ;
IN: unix
CONSTANT: FD_SETSIZE 1024
@ -13,12 +13,12 @@ C-STRUCT: addrinfo
{ "char*" "canonname" }
{ "addrinfo*" "next" } ;
C-STRUCT: dirent
{ "__uint32_t" "d_fileno" }
{ "__uint16_t" "d_reclen" }
{ "__uint8_t" "d_type" }
{ "__uint8_t" "d_namlen" }
{ { "char" 256 } "d_name" } ;
STRUCT: dirent
{ d_fileno __uint32_t }
{ d_reclen __uint16_t }
{ d_type __uint8_t }
{ d_namlen __uint8_t }
{ d_name char[256] } ;
CONSTANT: EPERM 1
CONSTANT: ENOENT 2

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax alien system ;
USING: alien.syntax alien system classes.struct ;
IN: unix
! Linux.
@ -94,12 +94,12 @@ C-STRUCT: passwd
{ "char*" "pw_shell" } ;
! dirent64
C-STRUCT: dirent
{ "ulonglong" "d_ino" }
{ "longlong" "d_off" }
{ "ushort" "d_reclen" }
{ "uchar" "d_type" }
{ { "char" 256 } "d_name" } ;
STRUCT: dirent
{ d_ino ulonglong }
{ d_off longlong }
{ d_reclen ushort }
{ d_type uchar }
{ d_name char[256] } ;
FUNCTION: int open64 ( char* path, int flags, int prot ) ;
FUNCTION: dirent64* readdir64 ( DIR* dirp ) ;