update dirent for structs
parent
d5a7dde7ee
commit
14973eacb5
|
@ -4,7 +4,7 @@ USING: accessors alien.c-types alien.strings combinators
|
||||||
continuations destructors fry io io.backend io.backend.unix
|
continuations destructors fry io io.backend io.backend.unix
|
||||||
io.directories io.encodings.binary io.encodings.utf8 io.files
|
io.directories io.encodings.binary io.encodings.utf8 io.files
|
||||||
io.pathnames io.files.types kernel math.bitwise sequences system
|
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
|
IN: io.directories.unix
|
||||||
|
|
||||||
: touch-mode ( -- n )
|
: touch-mode ( -- n )
|
||||||
|
@ -37,7 +37,7 @@ M: unix copy-file ( from to -- )
|
||||||
HOOK: find-next-file os ( DIR* -- byte-array )
|
HOOK: find-next-file os ( DIR* -- byte-array )
|
||||||
|
|
||||||
M: unix find-next-file ( DIR* -- byte-array )
|
M: unix find-next-file ( DIR* -- byte-array )
|
||||||
"dirent" <c-object>
|
dirent <struct>
|
||||||
f <void*>
|
f <void*>
|
||||||
[ readdir_r 0 = [ (io-error) ] unless ] 2keep
|
[ readdir_r 0 = [ (io-error) ] unless ] 2keep
|
||||||
*void* [ drop f ] unless ;
|
*void* [ drop f ] unless ;
|
||||||
|
@ -57,8 +57,8 @@ M: unix find-next-file ( DIR* -- byte-array )
|
||||||
|
|
||||||
M: unix >directory-entry ( byte-array -- directory-entry )
|
M: unix >directory-entry ( byte-array -- directory-entry )
|
||||||
{
|
{
|
||||||
[ dirent-d_name underlying>> utf8 alien>string ]
|
[ d_name>> underlying>> utf8 alien>string ]
|
||||||
[ dirent-d_type dirent-type>file-type ]
|
[ d_type>> dirent-type>file-type ]
|
||||||
} cleave directory-entry boa ;
|
} cleave directory-entry boa ;
|
||||||
|
|
||||||
M: unix (directory-entries) ( path -- seq )
|
M: unix (directory-entries) ( path -- seq )
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: alien.syntax ;
|
USING: alien.syntax classes.struct ;
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
CONSTANT: FD_SETSIZE 1024
|
CONSTANT: FD_SETSIZE 1024
|
||||||
|
@ -13,12 +13,12 @@ C-STRUCT: addrinfo
|
||||||
{ "void*" "addr" }
|
{ "void*" "addr" }
|
||||||
{ "addrinfo*" "next" } ;
|
{ "addrinfo*" "next" } ;
|
||||||
|
|
||||||
C-STRUCT: dirent
|
STRUCT: dirent
|
||||||
{ "u_int32_t" "d_fileno" }
|
{ d_fileno u_int32_t }
|
||||||
{ "u_int16_t" "d_reclen" }
|
{ d_reclen u_int16_t }
|
||||||
{ "u_int8_t" "d_type" }
|
{ d_type u_int8_t }
|
||||||
{ "u_int8_t" "d_namlen" }
|
{ d_namlen u_int8_t }
|
||||||
{ { "char" 256 } "d_name" } ;
|
{ d_name char[256] } ;
|
||||||
|
|
||||||
CONSTANT: EPERM 1
|
CONSTANT: EPERM 1
|
||||||
CONSTANT: ENOENT 2
|
CONSTANT: ENOENT 2
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: alien.syntax unix.time ;
|
USING: alien.syntax unix.time classes.struct ;
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
CONSTANT: FD_SETSIZE 1024
|
CONSTANT: FD_SETSIZE 1024
|
||||||
|
@ -32,12 +32,12 @@ CONSTANT: __DARWIN_MAXPATHLEN 1024
|
||||||
CONSTANT: __DARWIN_MAXNAMELEN 255
|
CONSTANT: __DARWIN_MAXNAMELEN 255
|
||||||
CONSTANT: __DARWIN_MAXNAMELEN+1 255
|
CONSTANT: __DARWIN_MAXNAMELEN+1 255
|
||||||
|
|
||||||
C-STRUCT: dirent
|
STRUCT: dirent
|
||||||
{ "ino_t" "d_ino" }
|
{ d_ino ino_t }
|
||||||
{ "__uint16_t" "d_reclen" }
|
{ d_reclen __uint16_t }
|
||||||
{ "__uint8_t" "d_type" }
|
{ d_type __uint8_t }
|
||||||
{ "__uint8_t" "d_namlen" }
|
{ d_namlen __uint8_t }
|
||||||
{ { "char" __DARWIN_MAXNAMELEN+1 } "d_name" } ;
|
{ d_name { "char" __DARWIN_MAXNAMELEN+1 } } ;
|
||||||
|
|
||||||
CONSTANT: EPERM 1
|
CONSTANT: EPERM 1
|
||||||
CONSTANT: ENOENT 2
|
CONSTANT: ENOENT 2
|
||||||
|
|
|
@ -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
|
IN: unix
|
||||||
|
|
||||||
CONSTANT: FD_SETSIZE 256
|
CONSTANT: FD_SETSIZE 256
|
||||||
|
@ -13,12 +14,12 @@ C-STRUCT: addrinfo
|
||||||
{ "void*" "addr" }
|
{ "void*" "addr" }
|
||||||
{ "addrinfo*" "next" } ;
|
{ "addrinfo*" "next" } ;
|
||||||
|
|
||||||
C-STRUCT: dirent
|
STRUCT: dirent
|
||||||
{ "__uint32_t" "d_fileno" }
|
{ d_fileno __uint32_t }
|
||||||
{ "__uint16_t" "d_reclen" }
|
{ d_reclen __uint16_t }
|
||||||
{ "__uint8_t" "d_type" }
|
{ d_type __uint8_t }
|
||||||
{ "__uint8_t" "d_namlen" }
|
{ d_namlen __uint8_t }
|
||||||
{ { "char" 256 } "d_name" } ;
|
{ d_name char[256] } ;
|
||||||
|
|
||||||
CONSTANT: EPERM 1
|
CONSTANT: EPERM 1
|
||||||
CONSTANT: ENOENT 2
|
CONSTANT: ENOENT 2
|
||||||
|
@ -126,8 +127,7 @@ CONSTANT: _UTX_LINESIZE 32
|
||||||
CONSTANT: _UTX_IDSIZE 4
|
CONSTANT: _UTX_IDSIZE 4
|
||||||
CONSTANT: _UTX_HOSTSIZE 256
|
CONSTANT: _UTX_HOSTSIZE 256
|
||||||
|
|
||||||
: _SS_MAXSIZE ( -- n )
|
CONSTANT: _SS_MAXSIZE 128
|
||||||
128 ; inline
|
|
||||||
|
|
||||||
: _SS_ALIGNSIZE ( -- n )
|
: _SS_ALIGNSIZE ( -- n )
|
||||||
"__int64_t" heap-size ; inline
|
"__int64_t" heap-size ; inline
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: alien.syntax ;
|
USING: alien.syntax classes.struct ;
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
CONSTANT: FD_SETSIZE 1024
|
CONSTANT: FD_SETSIZE 1024
|
||||||
|
@ -13,12 +13,12 @@ C-STRUCT: addrinfo
|
||||||
{ "char*" "canonname" }
|
{ "char*" "canonname" }
|
||||||
{ "addrinfo*" "next" } ;
|
{ "addrinfo*" "next" } ;
|
||||||
|
|
||||||
C-STRUCT: dirent
|
STRUCT: dirent
|
||||||
{ "__uint32_t" "d_fileno" }
|
{ d_fileno __uint32_t }
|
||||||
{ "__uint16_t" "d_reclen" }
|
{ d_reclen __uint16_t }
|
||||||
{ "__uint8_t" "d_type" }
|
{ d_type __uint8_t }
|
||||||
{ "__uint8_t" "d_namlen" }
|
{ d_namlen __uint8_t }
|
||||||
{ { "char" 256 } "d_name" } ;
|
{ d_name char[256] } ;
|
||||||
|
|
||||||
CONSTANT: EPERM 1
|
CONSTANT: EPERM 1
|
||||||
CONSTANT: ENOENT 2
|
CONSTANT: ENOENT 2
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2005, 2008 Slava Pestov.
|
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.syntax alien system ;
|
USING: alien.syntax alien system classes.struct ;
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
! Linux.
|
! Linux.
|
||||||
|
@ -94,12 +94,12 @@ C-STRUCT: passwd
|
||||||
{ "char*" "pw_shell" } ;
|
{ "char*" "pw_shell" } ;
|
||||||
|
|
||||||
! dirent64
|
! dirent64
|
||||||
C-STRUCT: dirent
|
STRUCT: dirent
|
||||||
{ "ulonglong" "d_ino" }
|
{ d_ino ulonglong }
|
||||||
{ "longlong" "d_off" }
|
{ d_off longlong }
|
||||||
{ "ushort" "d_reclen" }
|
{ d_reclen ushort }
|
||||||
{ "uchar" "d_type" }
|
{ d_type uchar }
|
||||||
{ { "char" 256 } "d_name" } ;
|
{ d_name char[256] } ;
|
||||||
|
|
||||||
FUNCTION: int open64 ( char* path, int flags, int prot ) ;
|
FUNCTION: int open64 ( char* path, int flags, int prot ) ;
|
||||||
FUNCTION: dirent64* readdir64 ( DIR* dirp ) ;
|
FUNCTION: dirent64* readdir64 ( DIR* dirp ) ;
|
||||||
|
|
Loading…
Reference in New Issue