Merge branch 'master' of git://factorcode.org/git/factor
commit
da59346f71
|
|
@ -512,6 +512,12 @@ HELP: time-since-midnight
|
|||
{ $values { "timestamp" timestamp } { "duration" duration } }
|
||||
{ $description "Calculates a " { $snippet "duration" } " that represents the elapsed time since midnight of the input " { $snippet "timestamp" } "." } ;
|
||||
|
||||
HELP: since-1970
|
||||
{ $values
|
||||
{ "duration" duration }
|
||||
{ "timestamp" timestamp } }
|
||||
{ $description "Adds the duration to the beginning of Unix time and returns the result as a timestamp." } ;
|
||||
|
||||
ARTICLE: "calendar" "Calendar"
|
||||
"The two data types used throughout the calendar library:"
|
||||
{ $subsection timestamp }
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays kernel math math.functions namespaces sequences
|
||||
strings system vocabs.loader threads accessors combinators
|
||||
locals classes.tuple math.order summary structs
|
||||
combinators.short-circuit ;
|
||||
locals classes.tuple math.order summary combinators.short-circuit ;
|
||||
IN: calendar
|
||||
|
||||
HOOK: gmt-offset os ( -- hours minutes seconds )
|
||||
|
|
@ -402,17 +401,9 @@ PRIVATE>
|
|||
: time-since-midnight ( timestamp -- duration )
|
||||
dup midnight time- ;
|
||||
|
||||
: since-1970 ( time -- timestamp )
|
||||
: since-1970 ( duration -- timestamp )
|
||||
unix-1970 time+ >local-time ;
|
||||
|
||||
: timeval>unix-time ( timeval -- timestamp )
|
||||
[ timeval-sec seconds ] [ timeval-usec microseconds ] bi
|
||||
time+ since-1970 ;
|
||||
|
||||
: timespec>unix-time ( timeval -- timestamp )
|
||||
[ timespec-sec seconds ] [ timespec-nsec nanoseconds ] bi
|
||||
time+ since-1970 ;
|
||||
|
||||
M: timestamp sleep-until timestamp>millis sleep-until ;
|
||||
|
||||
M: duration sleep hence sleep-until ;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,17 @@
|
|||
USING: alien alien.c-types arrays calendar kernel structs
|
||||
math unix.time namespaces system ;
|
||||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.syntax arrays calendar
|
||||
kernel math unix unix.time namespaces system ;
|
||||
IN: calendar.unix
|
||||
|
||||
: timeval>unix-time ( timeval -- timestamp )
|
||||
[ timeval-sec seconds ] [ timeval-usec microseconds ] bi
|
||||
time+ since-1970 ;
|
||||
|
||||
: timespec>unix-time ( timeval -- timestamp )
|
||||
[ timespec-sec seconds ] [ timespec-nsec nanoseconds ] bi
|
||||
time+ since-1970 ;
|
||||
|
||||
: get-time ( -- alien )
|
||||
f time <uint> localtime ;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
||||
|
|
@ -0,0 +1 @@
|
|||
CoreFoundation run loop integration
|
||||
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
||||
|
|
@ -0,0 +1 @@
|
|||
Vocabulary with init hook for running CoreFoundation event loop
|
||||
|
|
@ -172,7 +172,7 @@ HELP: sql-row-typed
|
|||
HELP: with-db
|
||||
{ $values
|
||||
{ "db" db } { "quot" quotation } }
|
||||
{ $description "Calls the quotation with a database bound to the " { $link db } " symbol. The database called is based on the " { $snippet "class" } " with the " } ;
|
||||
{ $description "Calls the quotation with a database bound to the " { $link db } " symbol. See " { $link "db-custom-database-combinators" } " for help setting up database access." } ;
|
||||
|
||||
HELP: with-transaction
|
||||
{ $values
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types generic assocs kernel kernel.private
|
||||
math io.ports sequences strings structs sbufs threads unix
|
||||
math io.ports sequences strings sbufs threads unix
|
||||
vectors io.buffers io.backend io.encodings math.parser
|
||||
continuations system libc qualified namespaces make io.timeouts
|
||||
io.encodings.utf8 destructors accessors summary combinators
|
||||
locals ;
|
||||
locals unix.time ;
|
||||
QUALIFIED: io
|
||||
IN: io.unix.backend
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.c-types kernel io.ports io.unix.backend
|
||||
bit-arrays sequences assocs unix unix.linux.epoll math
|
||||
namespaces structs ;
|
||||
namespaces unix.time ;
|
||||
IN: io.unix.epoll
|
||||
|
||||
TUPLE: epoll-mx < mx events ;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel alien.syntax math io.unix.files system
|
||||
unix.stat accessors combinators calendar.unix ;
|
||||
IN: io.unix.files.bsd
|
||||
|
||||
TUPLE: bsd-file-info < unix-file-info birth-time flags gen ;
|
||||
|
||||
M: bsd new-file-info ( -- class ) bsd-file-info new ;
|
||||
|
||||
M: bsd stat>file-info ( stat -- file-info )
|
||||
[ call-next-method ] keep
|
||||
{
|
||||
[ stat-st_flags >>flags ]
|
||||
[ stat-st_gen >>gen ]
|
||||
[ stat-st_birthtimespec timespec>unix-time >>birth-time ]
|
||||
} cleave ;
|
||||
|
|
@ -4,7 +4,7 @@ USING: io.backend io.ports io.unix.backend io.files io
|
|||
unix unix.stat unix.time kernel math continuations
|
||||
math.bitwise byte-arrays alien combinators calendar
|
||||
io.encodings.binary accessors sequences strings system
|
||||
io.files.private destructors vocabs.loader ;
|
||||
io.files.private destructors vocabs.loader calendar.unix ;
|
||||
|
||||
IN: io.unix.files
|
||||
|
||||
|
|
@ -103,9 +103,9 @@ M: unix stat>file-info ( stat -- file-info )
|
|||
[ stat>type >>type ]
|
||||
[ stat-st_size >>size ]
|
||||
[ stat-st_mode >>permissions ]
|
||||
[ stat-st_ctim timespec>unix-time >>created ]
|
||||
[ stat-st_mtim timespec>unix-time >>modified ]
|
||||
[ stat-st_atim timespec>unix-time >>accessed ]
|
||||
[ stat-st_ctimespec timespec>unix-time >>created ]
|
||||
[ stat-st_mtimespec timespec>unix-time >>modified ]
|
||||
[ stat-st_atimespec timespec>unix-time >>accessed ]
|
||||
[ stat-st_uid >>uid ]
|
||||
[ stat-st_gid >>gid ]
|
||||
[ stat-st_dev >>dev ]
|
||||
|
|
@ -130,8 +130,9 @@ M: unix stat>type ( stat -- type )
|
|||
|
||||
! Linux has no extra fields in its stat struct
|
||||
os {
|
||||
{ macosx [ "io.unix.files.macosx" require ] }
|
||||
{ freebsd [ "io.unix.files.freebsd" require ] }
|
||||
{ netbsd [ "io.unix.files.netbsd" require ] }
|
||||
{ openbsd [ "io.unix.files.openbsd" require ] }
|
||||
{ macosx [ "io.unix.files.bsd" require ] }
|
||||
{ netbsd [ "io.unix.files.bsd" require ] }
|
||||
{ openbsd [ "io.unix.files.bsd" require ] }
|
||||
{ freebsd [ "io.unix.files.bsd" require ] }
|
||||
{ linux [ ] }
|
||||
} case
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel alien.syntax math io.unix.files system
|
||||
unix.stat accessors combinators calendar ;
|
||||
IN: io.unix.files.freebsd
|
||||
|
||||
TUPLE: freebsd-file-info < unix-file-info birth-time flags gen ;
|
||||
|
||||
M: freebsd new-file-info ( -- class ) freebsd-file-info new ;
|
||||
|
||||
M: freebsd stat>file-info ( stat -- file-info )
|
||||
[ call-next-method ] keep
|
||||
{
|
||||
[ stat-st_flags >>flags ]
|
||||
[ stat-st_gen >>gen ]
|
||||
[ stat-st_birthtimepsec timespec>timestamp >>birth-time ]
|
||||
} cleave ;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel alien.syntax math io.unix.files system
|
||||
unix.stat accessors combinators ;
|
||||
IN: io.unix.files.macosx
|
||||
|
||||
TUPLE: macosx-file-info < unix-file-info flags gen ;
|
||||
|
||||
M: macosx new-file-info ( -- class ) macosx-file-info new ;
|
||||
|
||||
M: macosx stat>file-info ( stat -- file-info )
|
||||
[ call-next-method ] keep
|
||||
{
|
||||
[ stat-st_flags >>flags ]
|
||||
[ stat-st_gen >>gen ]
|
||||
} cleave ;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel alien.syntax math io.unix.files system
|
||||
unix.stat accessors combinators calendar ;
|
||||
IN: io.unix.files.netbsd
|
||||
|
||||
TUPLE: netbsd-file-info < unix-file-info birth-time flags gen ;
|
||||
|
||||
M: netbsd new-file-info ( -- class ) netbsd-file-info new ;
|
||||
|
||||
M: netbsd stat>file-info ( stat -- file-info )
|
||||
[ call-next-method ] keep
|
||||
{
|
||||
[ stat-st_flags >>flags ]
|
||||
[ stat-st_gen >>gen ]
|
||||
[ stat-st_birthtim timespec>timestamp >>birth-time ]
|
||||
} cleave ;
|
||||
|
|
@ -1 +0,0 @@
|
|||
unportable
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel alien.syntax math io.unix.files system
|
||||
unix.stat accessors combinators calendar ;
|
||||
IN: io.unix.files.openbsd
|
||||
|
||||
TUPLE: openbsd-file-info < unix-file-info birth-time flags gen ;
|
||||
|
||||
M: openbsd new-file-info ( -- class ) openbsd-file-info new ;
|
||||
|
||||
M: openbsd stat>file-info ( stat -- file-info )
|
||||
[ call-next-method ] keep
|
||||
{
|
||||
[ stat-st_flags >>flags ]
|
||||
[ stat-st_gen >>gen ]
|
||||
[ stat-st_birthtim timespec>timestamp >>birth-time ]
|
||||
} cleave ;
|
||||
|
|
@ -1 +0,0 @@
|
|||
unportable
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.c-types kernel io.ports io.unix.backend
|
||||
bit-arrays sequences assocs unix math namespaces structs
|
||||
accessors math.order locals ;
|
||||
bit-arrays sequences assocs unix math namespaces
|
||||
accessors math.order locals unix.time ;
|
||||
IN: io.unix.select
|
||||
|
||||
TUPLE: select-mx < mx read-fdset write-fdset ;
|
||||
|
|
|
|||
|
|
@ -147,14 +147,14 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
|||
FILE_ATTRIBUTE_DIRECTORY mask? +directory+ +regular-file+ ? ;
|
||||
|
||||
: WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info )
|
||||
[ file-info new ] dip
|
||||
[ \ file-info new ] dip
|
||||
{
|
||||
[ WIN32_FIND_DATA-dwFileAttributes win32-file-type >>type ]
|
||||
[
|
||||
[ WIN32_FIND_DATA-nFileSizeLow ]
|
||||
[ WIN32_FIND_DATA-nFileSizeHigh ] bi >64bit >>size
|
||||
]
|
||||
[ WIN32_FIND_DATA-dwFileAttributes >>mode ]
|
||||
[ WIN32_FIND_DATA-dwFileAttributes >>permissions ]
|
||||
[ WIN32_FIND_DATA-ftCreationTime FILETIME>timestamp >>created ]
|
||||
[ WIN32_FIND_DATA-ftLastWriteTime FILETIME>timestamp >>modified ]
|
||||
[ WIN32_FIND_DATA-ftLastAccessTime FILETIME>timestamp >>accessed ]
|
||||
|
|
@ -168,14 +168,14 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
|||
] keep ;
|
||||
|
||||
: BY_HANDLE_FILE_INFORMATION>file-info ( HANDLE_FILE_INFORMATION -- file-info )
|
||||
[ file-info new ] dip
|
||||
[ \ file-info new ] dip
|
||||
{
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-type >>type ]
|
||||
[
|
||||
[ BY_HANDLE_FILE_INFORMATION-nFileSizeLow ]
|
||||
[ BY_HANDLE_FILE_INFORMATION-nFileSizeHigh ] bi >64bit >>size
|
||||
]
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>mode ]
|
||||
[ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>permissions ]
|
||||
[
|
||||
BY_HANDLE_FILE_INFORMATION-ftCreationTime
|
||||
FILETIME>timestamp >>created
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Doug Coleman
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
USING: alien.c-types alien.syntax kernel math unix.types ;
|
||||
IN: structs
|
||||
|
||||
C-STRUCT: timeval
|
||||
{ "long" "sec" }
|
||||
{ "long" "usec" } ;
|
||||
|
||||
: make-timeval ( ms -- timeval )
|
||||
1000 /mod 1000 *
|
||||
"timeval" <c-object>
|
||||
[ set-timeval-usec ] keep
|
||||
[ set-timeval-sec ] keep ;
|
||||
|
||||
C-STRUCT: timespec
|
||||
{ "time_t" "sec" }
|
||||
{ "long" "nsec" } ;
|
||||
|
||||
: make-timespec ( ms -- timespec )
|
||||
1000 /mod 1000000 *
|
||||
"timespec" <c-object>
|
||||
[ set-timespec-nsec ] keep
|
||||
[ set-timespec-sec ] keep ;
|
||||
|
|
@ -1 +0,0 @@
|
|||
Cross-platform C structs
|
||||
|
|
@ -12,9 +12,9 @@ C-STRUCT: stat
|
|||
{ "uid_t" "st_uid" }
|
||||
{ "gid_t" "st_gid" }
|
||||
{ "__dev_t" "st_rdev" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
|
|
@ -27,4 +27,4 @@ C-STRUCT: stat
|
|||
{ "__uint32_t" "pad1" } ;
|
||||
|
||||
FUNCTION: int stat ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ C-STRUCT: stat
|
|||
{ "uid_t" "st_uid" }
|
||||
{ "gid_t" "st_gid" }
|
||||
{ "__dev_t" "st_rdev" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ C-STRUCT: stat
|
|||
{ "off_t" "st_size" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "ulong" "unused4" }
|
||||
{ "ulong" "unused5" } ;
|
||||
|
||||
|
|
@ -30,4 +30,4 @@ FUNCTION: int __xstat ( int ver, char* pathname, stat* buf ) ;
|
|||
FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ;
|
||||
|
||||
: stat ( pathname buf -- int ) 3 -rot __xstat ;
|
||||
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
||||
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ C-STRUCT: stat
|
|||
{ "off_t" "st_size" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "long" "__unused0" }
|
||||
{ "long" "__unused1" }
|
||||
{ "long" "__unused2" } ;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
|
||||
USING: kernel alien.syntax math ;
|
||||
|
||||
IN: unix.stat
|
||||
|
||||
! Mac OS X ppc
|
||||
|
||||
! stat64 structure
|
||||
C-STRUCT: stat
|
||||
{ "dev_t" "st_dev" }
|
||||
{ "ino_t" "st_ino" }
|
||||
{ "mode_t" "st_mode" }
|
||||
{ "nlink_t" "st_nlink" }
|
||||
{ "ino64_t" "st_ino" }
|
||||
{ "uid_t" "st_uid" }
|
||||
{ "gid_t" "st_gid" }
|
||||
{ "dev_t" "st_rdev" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "timespec" "st_birthtimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
|
|
@ -25,9 +25,8 @@ C-STRUCT: stat
|
|||
{ "__int64_t" "st_qspare0" }
|
||||
{ "__int64_t" "st_qspare1" } ;
|
||||
|
||||
FUNCTION: int stat ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int stat64 ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int lstat64 ( char* pathname, stat* buf ) ;
|
||||
|
||||
: stat-st_atim ( stat -- timespec ) stat-st_atimespec ;
|
||||
: stat-st_mtim ( stat -- timespec ) stat-st_mtimespec ;
|
||||
: stat-st_ctim ( stat -- timespec ) stat-st_ctimespec ;
|
||||
: stat ( path buf -- n ) stat64 ;
|
||||
: lstat ( path buf -- n ) lstat64 ;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ C-STRUCT: stat
|
|||
{ "uid_t" "st_uid" }
|
||||
{ "gid_t" "st_gid" }
|
||||
{ "dev_t" "st_rdev" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_birthtim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "timespec" "st_birthtimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ C-STRUCT: stat
|
|||
{ "uid_t" "st_uid" }
|
||||
{ "gid_t" "st_gid" }
|
||||
{ "dev_t" "st_rdev" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "blkcnt_t" "st_blocks" }
|
||||
{ "blksize_t" "st_blksize" }
|
||||
{ "uint32_t" "st_flags" }
|
||||
{ "uint32_t" "st_gen" }
|
||||
{ "uint32_t" "st_spare0" }
|
||||
{ "timespec" "st_birthtim" } ;
|
||||
{ "timespec" "st_birthtimespec" } ;
|
||||
|
||||
FUNCTION: int __stat13 ( char* pathname, stat* buf ) ;
|
||||
FUNCTION: int __lstat13 ( char* pathname, stat* buf ) ;
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ C-STRUCT: stat
|
|||
{ "gid_t" "st_gid" }
|
||||
{ "dev_t" "st_rdev" }
|
||||
{ "int32_t" "st_lspare0" }
|
||||
{ "timespec" "st_atim" }
|
||||
{ "timespec" "st_mtim" }
|
||||
{ "timespec" "st_ctim" }
|
||||
{ "timespec" "st_atimespec" }
|
||||
{ "timespec" "st_mtimespec" }
|
||||
{ "timespec" "st_ctimespec" }
|
||||
{ "off_t" "st_size" }
|
||||
{ "int64_t" "st_blocks" }
|
||||
{ "u_int32_t" "st_blksize" }
|
||||
{ "u_int32_t" "st_flags" }
|
||||
{ "u_int32_t" "st_gen" }
|
||||
{ "int32_t" "st_lspare1" }
|
||||
{ "timespec" "st_birthtim" }
|
||||
{ "timespec" "st_birthtimespec" }
|
||||
{ { "int64_t" 2 } "st_qspare" } ;
|
||||
|
||||
FUNCTION: int stat ( char* pathname, stat* buf ) ;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
|
||||
USING: kernel system combinators alien.syntax alien.c-types
|
||||
math io.unix.backend vocabs.loader unix ;
|
||||
|
||||
math io.unix.backend vocabs.loader unix ;
|
||||
IN: unix.stat
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
! File Types
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: S_IFMT OCT: 170000 ; ! These bits determine file type.
|
||||
|
||||
|
|
@ -18,54 +14,38 @@ IN: unix.stat
|
|||
: S_IFLNK OCT: 120000 ; inline ! Symbolic link.
|
||||
: S_IFSOCK OCT: 140000 ; inline ! Socket.
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
! File Access Permissions
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
! Read, write, execute/search by owner
|
||||
: S_IRWXU OCT: 0000700 ; inline ! rwx mask owner
|
||||
: S_ISUID OCT: 0004000 ; inline
|
||||
: S_ISGID OCT: 0002000 ; inline
|
||||
: S_ISVTX OCT: 0001000 ; inline
|
||||
: S_IRUSR OCT: 0000400 ; inline ! r owner
|
||||
: S_IWUSR OCT: 0000200 ; inline ! w owner
|
||||
: S_IXUSR OCT: 0000100 ; inline ! x owner
|
||||
! Read, write, execute/search by group
|
||||
: S_IRWXG OCT: 0000070 ; inline ! rwx mask group
|
||||
: S_IRGRP OCT: 0000040 ; inline ! r group
|
||||
: S_IWGRP OCT: 0000020 ; inline ! w group
|
||||
: S_IXGRP OCT: 0000010 ; inline ! x group
|
||||
! Read, write, execute/search by others
|
||||
: S_IRWXO OCT: 0000007 ; inline ! rwx mask other
|
||||
: S_IROTH OCT: 0000004 ; inline ! r other
|
||||
: S_IWOTH OCT: 0000002 ; inline ! w other
|
||||
: S_IXOTH OCT: 0000001 ; inline ! x other
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
FUNCTION: int chmod ( char* path, mode_t mode ) ;
|
||||
|
||||
FUNCTION: int fchmod ( int fd, mode_t mode ) ;
|
||||
|
||||
FUNCTION: int mkdir ( char* path, mode_t mode ) ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
<<
|
||||
os
|
||||
{
|
||||
<< os {
|
||||
{ linux [ "unix.stat.linux" require ] }
|
||||
{ macosx [ "unix.stat.macosx" require ] }
|
||||
{ freebsd [ "unix.stat.freebsd" require ] }
|
||||
{ netbsd [ "unix.stat.netbsd" require ] }
|
||||
{ openbsd [ "unix.stat.openbsd" require ] }
|
||||
}
|
||||
case
|
||||
>>
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
} case >>
|
||||
|
||||
: file-status ( pathname -- stat )
|
||||
"stat" <c-object> dup >r
|
||||
[ stat ] unix-system-call drop
|
||||
r> ;
|
||||
"stat" <c-object> [
|
||||
[ stat ] unix-system-call drop
|
||||
] keep ;
|
||||
|
||||
: link-status ( pathname -- stat )
|
||||
"stat" <c-object> dup >r
|
||||
[ lstat ] unix-system-call drop
|
||||
r> ;
|
||||
"stat" <c-object> [
|
||||
[ lstat ] unix-system-call drop
|
||||
] keep ;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,26 @@
|
|||
USING: kernel alien.syntax alien.c-types math unix.types ;
|
||||
IN: unix.time
|
||||
|
||||
C-STRUCT: timeval
|
||||
{ "long" "sec" }
|
||||
{ "long" "usec" } ;
|
||||
|
||||
C-STRUCT: timespec
|
||||
{ "time_t" "sec" }
|
||||
{ "long" "nsec" } ;
|
||||
|
||||
: make-timeval ( ms -- timeval )
|
||||
1000 /mod 1000 *
|
||||
"timeval" <c-object>
|
||||
[ set-timeval-usec ] keep
|
||||
[ set-timeval-sec ] keep ;
|
||||
|
||||
: make-timespec ( ms -- timespec )
|
||||
1000 /mod 1000000 *
|
||||
"timespec" <c-object>
|
||||
[ set-timespec-nsec ] keep
|
||||
[ set-timespec-sec ] keep ;
|
||||
|
||||
C-STRUCT: tm
|
||||
{ "int" "sec" } ! Seconds: 0-59 (K&R says 0-61?)
|
||||
{ "int" "min" } ! Minutes: 0-59
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ TYPEDEF: __uint32_t uid_t
|
|||
TYPEDEF: __uint32_t gid_t
|
||||
TYPEDEF: __int64_t off_t
|
||||
TYPEDEF: __int64_t blkcnt_t
|
||||
TYPEDEF: __int64_t ino64_t
|
||||
TYPEDEF: __int32_t blksize_t
|
||||
TYPEDEF: long ssize_t
|
||||
TYPEDEF: __int32_t pid_t
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.syntax kernel libc structs
|
||||
USING: alien alien.c-types alien.syntax kernel libc
|
||||
sequences continuations byte-arrays strings math namespaces
|
||||
system combinators vocabs.loader qualified accessors
|
||||
stack-checker macros locals generalizations unix.types
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2006 Mackenzie Straight, Doug Coleman.
|
||||
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.strings alien.syntax arrays
|
||||
byte-arrays kernel math sequences windows.types windows.kernel32
|
||||
windows.errors structs windows math.bitwise alias ;
|
||||
windows.errors windows math.bitwise alias ;
|
||||
IN: windows.winsock
|
||||
|
||||
USE: libc
|
||||
|
|
@ -138,6 +138,10 @@ C-STRUCT: addrinfo
|
|||
{ "sockaddr*" "addr" }
|
||||
{ "addrinfo*" "next" } ;
|
||||
|
||||
C-STRUCT: timeval
|
||||
{ "long" "sec" }
|
||||
{ "long" "usec" } ;
|
||||
|
||||
: hostent-addr ( hostent -- addr ) hostent-addr-list *void* ; ! *uint ;
|
||||
|
||||
LIBRARY: winsock
|
||||
|
|
@ -440,4 +444,3 @@ FUNCTION: void GetAcceptExSockaddrs ( void* a, int b, int c, int d, void* e, voi
|
|||
|
||||
: init-winsock ( -- )
|
||||
HEX: 0202 <wsadata> WSAStartup winsock-return-check ;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue