Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-05-12 04:26:17 -05:00
commit 5ddca1d0f2
10 changed files with 89 additions and 60 deletions

View File

@ -0,0 +1,10 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types io.directories.unix kernel system unix ;
IN: io.directories.unix.linux
M: unix find-next-file ( DIR* -- byte-array )
"dirent" <c-object>
f <void*>
[ readdir64_r 0 = [ (io-error) ] unless ] 2keep
*void* [ drop f ] unless ;

View File

@ -0,0 +1 @@
unportable

View File

@ -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 ; unix unix.stat vocabs.loader ;
IN: io.directories.unix IN: io.directories.unix
: touch-mode ( -- n ) : touch-mode ( -- n )
@ -34,7 +34,9 @@ M: unix copy-file ( from to -- )
[ opendir dup [ (io-error) ] unless ] dip [ opendir dup [ (io-error) ] unless ] dip
dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline
: find-next-file ( DIR* -- byte-array ) HOOK: find-next-file os ( DIR* -- byte-array )
M: unix find-next-file ( DIR* -- byte-array )
"dirent" <c-object> "dirent" <c-object>
f <void*> f <void*>
[ readdir_r 0 = [ (io-error) ] unless ] 2keep [ readdir_r 0 = [ (io-error) ] unless ] 2keep
@ -54,8 +56,10 @@ M: unix copy-file ( from to -- )
} case ; } case ;
M: unix >directory-entry ( byte-array -- directory-entry ) M: unix >directory-entry ( byte-array -- directory-entry )
[ dirent-d_name utf8 alien>string ] {
[ dirent-d_type dirent-type>file-type ] bi directory-entry boa ; [ dirent-d_name utf8 alien>string ]
[ dirent-d_type dirent-type>file-type ]
} cleave directory-entry boa ;
M: unix (directory-entries) ( path -- seq ) M: unix (directory-entries) ( path -- seq )
[ [
@ -63,3 +67,5 @@ M: unix (directory-entries) ( path -- seq )
[ >directory-entry ] [ >directory-entry ]
produce nip produce nip
] with-unix-directory ; ] with-unix-directory ;
os linux? [ "io.directories.unix.linux" require ] when

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos. ! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel system sequences combinators USING: accessors kernel system sequences combinators
vocabs.loader io.files.types ; vocabs.loader io.files.types math ;
IN: io.files.info IN: io.files.info
! File info ! File info
@ -14,6 +14,9 @@ HOOK: link-info os ( path -- info )
: directory? ( file-info -- ? ) type>> +directory+ = ; : directory? ( file-info -- ? ) type>> +directory+ = ;
: sparse-file? ( file-info -- ? )
[ size-on-disk>> ] [ size>> ] bi < ;
! File systems ! File systems
HOOK: file-systems os ( -- array ) HOOK: file-systems os ( -- array )

View File

@ -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 ; USING: alien.syntax alien system ;
IN: unix IN: unix
! Linux. ! Linux.
@ -93,13 +93,20 @@ C-STRUCT: passwd
{ "char*" "pw_dir" } { "char*" "pw_dir" }
{ "char*" "pw_shell" } ; { "char*" "pw_shell" } ;
! dirent64
C-STRUCT: dirent C-STRUCT: dirent
{ "__ino_t" "d_ino" } { "ulonglong" "d_ino" }
{ "__off_t" "d_off" } { "longlong" "d_off" }
{ "ushort" "d_reclen" } { "ushort" "d_reclen" }
{ "uchar" "d_type" } { "uchar" "d_type" }
{ { "char" 256 } "d_name" } ; { { "char" 256 } "d_name" } ;
FUNCTION: int open64 ( char* path, int flags, int prot ) ;
FUNCTION: dirent64* readdir64 ( DIR* dirp ) ;
FUNCTION: int readdir64_r ( void* dirp, dirent* entry, dirent** result ) ;
M: linux open-file [ open64 ] unix-system-call ;
CONSTANT: EPERM 1 CONSTANT: EPERM 1
CONSTANT: ENOENT 2 CONSTANT: ENOENT 2
CONSTANT: ESRCH 3 CONSTANT: ESRCH 3

View File

@ -1,29 +1,28 @@
USING: kernel alien.syntax math ; USING: kernel alien.syntax math sequences unix
alien.c-types arrays accessors combinators ;
IN: unix.stat IN: unix.stat
! Ubuntu 8.04 32-bit ! stat64
C-STRUCT: stat C-STRUCT: stat
{ "dev_t" "st_dev" } { "dev_t" "st_dev" }
{ "ushort" "__pad1" } { "ushort" "__pad1" }
{ "ino_t" "st_ino" } { "__ino_t" "__st_ino" }
{ "mode_t" "st_mode" } { "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" } { "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" } { "uid_t" "st_uid" }
{ "gid_t" "st_gid" } { "gid_t" "st_gid" }
{ "dev_t" "st_rdev" } { "dev_t" "st_rdev" }
{ "ushort" "__pad2" } { { "ushort" 2 } "__pad2" }
{ "off_t" "st_size" } { "off64_t" "st_size" }
{ "blksize_t" "st_blksize" } { "blksize_t" "st_blksize" }
{ "blkcnt_t" "st_blocks" } { "blkcnt64_t" "st_blocks" }
{ "timespec" "st_atimespec" } { "timespec" "st_atimespec" }
{ "timespec" "st_mtimespec" } { "timespec" "st_mtimespec" }
{ "timespec" "st_ctimespec" } { "timespec" "st_ctimespec" }
{ "ulong" "unused4" } { "ulonglong" "st_ino" } ;
{ "ulong" "unused5" } ;
FUNCTION: int __xstat ( int ver, char* pathname, stat* buf ) ; FUNCTION: int __xstat64 ( int ver, char* pathname, stat* buf ) ;
FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ; FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ;
: stat ( pathname buf -- int ) [ 3 ] 2dip __xstat ; : stat ( pathname buf -- int ) [ 1 ] 2dip __xstat64 ;
: lstat ( pathname buf -- int ) [ 3 ] 2dip __lxstat ; : lstat ( pathname buf -- int ) [ 1 ] 2dip __lxstat64 ;

View File

@ -2,29 +2,27 @@ USING: kernel alien.syntax math sequences unix
alien.c-types arrays accessors combinators ; alien.c-types arrays accessors combinators ;
IN: unix.stat IN: unix.stat
! Ubuntu 7.10 64-bit ! stat64
C-STRUCT: stat C-STRUCT: stat
{ "dev_t" "st_dev" } { "dev_t" "st_dev" }
{ "ino_t" "st_ino" } { "ushort" "__pad1" }
{ "nlink_t" "st_nlink" } { "__ino_t" "__st_ino" }
{ "mode_t" "st_mode" } { "mode_t" "st_mode" }
{ "uid_t" "st_uid" } { "nlink_t" "st_nlink" }
{ "gid_t" "st_gid" } { "uid_t" "st_uid" }
{ "int" "pad0" } { "gid_t" "st_gid" }
{ "dev_t" "st_rdev" } { "dev_t" "st_rdev" }
{ "off_t" "st_size" } { { "ushort" 2 } "__pad2" }
{ "blksize_t" "st_blksize" } { "off64_t" "st_size" }
{ "blkcnt_t" "st_blocks" } { "blksize_t" "st_blksize" }
{ "timespec" "st_atimespec" } { "blkcnt64_t" "st_blocks" }
{ "timespec" "st_mtimespec" } { "timespec" "st_atimespec" }
{ "timespec" "st_ctimespec" } { "timespec" "st_mtimespec" }
{ "long" "__unused0" } { "timespec" "st_ctimespec" }
{ "long" "__unused1" } { "ulonglong" "st_ino" } ;
{ "long" "__unused2" } ;
FUNCTION: int __xstat ( int ver, char* pathname, stat* buf ) ; FUNCTION: int __xstat64 ( int ver, char* pathname, stat* buf ) ;
FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ; FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ;
: stat ( pathname buf -- int ) [ 1 ] 2dip __xstat ; : stat ( pathname buf -- int ) [ 1 ] 2dip __xstat64 ;
: lstat ( pathname buf -- int ) [ 1 ] 2dip __lxstat ; : lstat ( pathname buf -- int ) [ 1 ] 2dip __lxstat64 ;

View File

@ -23,7 +23,11 @@ TYPEDEF: __slongword_type blkcnt_t
TYPEDEF: __sword_type ssize_t TYPEDEF: __sword_type ssize_t
TYPEDEF: __s32_type pid_t TYPEDEF: __s32_type pid_t
TYPEDEF: __slongword_type time_t TYPEDEF: __slongword_type time_t
TYPEDEF: __slongword_type __time_t
TYPEDEF: ssize_t __SWORD_TYPE TYPEDEF: ssize_t __SWORD_TYPE
TYPEDEF: ulonglong blkcnt64_t
TYPEDEF: ulonglong __fsblkcnt64_t TYPEDEF: ulonglong __fsblkcnt64_t
TYPEDEF: ulonglong __fsfilcnt64_t TYPEDEF: ulonglong __fsfilcnt64_t
TYPEDEF: ulonglong ino64_t
TYPEDEF: ulonglong off64_t

View File

@ -140,9 +140,11 @@ FUNCTION: int shutdown ( int fd, int how ) ;
FUNCTION: int open ( char* path, int flags, int prot ) ; FUNCTION: int open ( char* path, int flags, int prot ) ;
FUNCTION: DIR* opendir ( char* path ) ; HOOK: open-file os ( path flags mode -- fd )
: open-file ( path flags mode -- fd ) [ open ] unix-system-call ; M: unix open-file [ open ] unix-system-call ;
FUNCTION: DIR* opendir ( char* path ) ;
C-STRUCT: utimbuf C-STRUCT: utimbuf
{ "time_t" "actime" } { "time_t" "actime" }
@ -165,7 +167,6 @@ FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ;
FUNCTION: dirent* readdir ( DIR* dirp ) ; FUNCTION: dirent* readdir ( DIR* dirp ) ;
FUNCTION: int readdir_r ( void* dirp, dirent* entry, dirent** result ) ; FUNCTION: int readdir_r ( void* dirp, dirent* entry, dirent** result ) ;
FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ; FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ;
CONSTANT: PATH_MAX 1024 CONSTANT: PATH_MAX 1024

View File

@ -16,8 +16,8 @@ IN: mason.notify
] { } make prepend ] { } make prepend
[ 5 ] 2dip '[ [ 5 ] 2dip '[
<process> <process>
_ >>command
_ [ +closed+ ] unless* >>stdin _ [ +closed+ ] unless* >>stdin
_ >>command
try-output-process try-output-process
] retry ] retry
] [ 2drop ] if ; ] [ 2drop ] if ;
@ -47,4 +47,4 @@ IN: mason.notify
] bi ; ] bi ;
: notify-release ( archive-name -- ) : notify-release ( archive-name -- )
"Uploaded " prepend [ print flush ] [ mason-tweet ] bi ; "Uploaded " prepend [ print flush ] [ mason-tweet ] bi ;