diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor index a107a46275..06ba73bb46 100644 --- a/basis/io/directories/unix/unix.factor +++ b/basis/io/directories/unix/unix.factor @@ -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" + dirent f [ 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 ) diff --git a/basis/unix/bsd/freebsd/freebsd.factor b/basis/unix/bsd/freebsd/freebsd.factor index 05642b5065..58af91271d 100644 --- a/basis/unix/bsd/freebsd/freebsd.factor +++ b/basis/unix/bsd/freebsd/freebsd.factor @@ -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 diff --git a/basis/unix/bsd/macosx/macosx.factor b/basis/unix/bsd/macosx/macosx.factor index 32dd4d80d8..d4a57f47c2 100644 --- a/basis/unix/bsd/macosx/macosx.factor +++ b/basis/unix/bsd/macosx/macosx.factor @@ -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 diff --git a/basis/unix/bsd/netbsd/netbsd.factor b/basis/unix/bsd/netbsd/netbsd.factor index f124e7f998..8cd4d4f484 100644 --- a/basis/unix/bsd/netbsd/netbsd.factor +++ b/basis/unix/bsd/netbsd/netbsd.factor @@ -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 diff --git a/basis/unix/bsd/openbsd/openbsd.factor b/basis/unix/bsd/openbsd/openbsd.factor index e915b6ffcd..c77b043723 100644 --- a/basis/unix/bsd/openbsd/openbsd.factor +++ b/basis/unix/bsd/openbsd/openbsd.factor @@ -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 diff --git a/basis/unix/linux/linux.factor b/basis/unix/linux/linux.factor index 43a66f2dbe..31789baf1c 100644 --- a/basis/unix/linux/linux.factor +++ b/basis/unix/linux/linux.factor @@ -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 ) ;