UNIX
(POSIX)
directory
OS:within-critical-section
, as well as reading and writing through TCP, uni- and bidirectional pipes.
A set of native Scheme procedures providing access to the common POSIX library facilities and UNIX system calls:
The source code documents the interfaces in full detail. | |
Version | |
---|---|
The current version is 3.3, Aug 11, 2003. | |
References | |
OS-spec.scm [24K]
vipc.scm [2K]
vext-io.scm [15K]
|
UNIX
(POSIX)
directory
-- procedure+: OS:for-each-file-in-directory DIR-NAME PROC
PROC
on each file
PROC
's results
PROC
:
file-info
"object" that describes the file being scanned
PROC
returns
#f
, the scanning of the directory is terminated
'()
, the scanning continues,OS:for-each-file-in-directory
accumulates
The file-info
object being given to the procedure PROC
is the result of
-- procedure+: OS:make-file-info FILE-PATH
The object accepts the following "messages"
'name
'link-count
'directory?
#t
if the file is a directory
'block-special?
#t
if the file is a block-special file, like those in /dev/dsk
'char-special?
#t
if the file is a char-special file, as /dev/tty
'regular-file?
#t
if the file is a plain regular file
'pipe?
#t
if the file is a communication (FIFO
) pipe
'mtime
BIGNUM
, generally, number, the number of seconds since Jan 1, 1970 (see man time(2)
)
'atime
'ctime
'size
'uid
uid
'gid
gid
(group id)
'perm
'owner
, 'group
, or 'others
) and operation ('read
, 'write
, or 'exec
), and tells if the file can be accessed by who with the operation
All i/o errors raise a ##SIGNAL.IO-ERROR
, which can be ##caught
.
Verification code vreaddir.scm is a good example of using these functions; note a test case that uses OS:for-each-file-in-directory
to fake a "ls -l .
" UNIX command
These function use Gambit's Scheme/C
foreign function interface.
Current version: Apr 7, 1997
Click to download readdir.scm, and the verification code vreaddir.scm
The following higher-level i/o procedures capture several frequently-occurring patterns of input and output. The procedures proved convenient in practice. They are also efficient: Each procedure has a slow and a fast path implementations. The slow path code works with any i/o port and on any R4RS+ Scheme system. The fast path is specific to Gambit and to stream ports. The procedures themselves chose the right (the most optimal) path of execution.
| |
Version | |
---|---|
The current version is 3.0, May 2, 2001. | |
References | |
OS-spec.scm [19K] vext-io.scm [15K]
|
Although there is no standard way of handling Unix/Posix signals in Scheme, many implementations, e.g., Gambit, let a user specify a thunk to execute whenever a signal, a timer interrupt or other external condition occurs. Incidentally this makes it possible to write thread scheduling systems and the like directly in Scheme. Indeed, when a signal handler returns the interrupted computation resumes. The signal handler can therefore use its own continuation for thread switching purposes. Listing 1 in the article below shows the example of this idea. It uses non-preemptive "interrupts" and thus should run on every Scheme system. However, if you happen to have a Gambit-C system, you can insert Listing 2 into Listing 1 where indicated. This buys you a preemptive re-scheduling upon arrival of a user-defined signal. You can do " | |
Version | |
---|---|
The current version is 1.1, Feb 26, 2000. | |
References | |
A USENET article with the complete code and transcripts [plain text file] | |
From other archives | |
|
Gambit-C
's foreign function interfaceFIXNUM
, the corresponding BIGNUM
is created. Conversely, both BIGNUM
and FIXNUM
can be converted to C's unsigned int
(if they fit, of course).
oleg-at-okmij.org