/usr/lib/s9fes/help/sys_open is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | S9 EXT (sys:close integer) ==> unspecific
(sys:creat string integer) ==> integer
(sys:creat string) ==> integer
(sys:open string integer) ==> integer
Open and close files on the Unix file system. SYS:OPEN opens
the file STRING in mode INTEGER. The file must exist. The
following modes are portable:
sys:read-only (0)
sys:write-only (1)
sys:read+write (2)
SYS:OPEN returns a file descriptor for accessing the given file.
SYS:CREAT creates a new file named STRING and assigns the
permission bits specified in INTEGER to it. (The permission
bits are also affected by SYS:UMASK; see there.) When the
file exists, it will be truncated to zero bytes. SYS:CREAT
returns a file descriptor for accessing the new file. When
no access bits are passed to SYS:CREAT, it defaults to #o644
(rw-r--r--).
SYS:CLOSE closes the file descriptor INTEGER.
Use SYS:MAKE-INPUT-PORT and SYS:MAKE-OUTPUT-PORT to convert
Unix file descriptors into I/O ports.
Note: There is no need to apply SYS:CLOSE to a descriptor that
has been assigned to an I/O port, because the file will be
closed automatically when the port is garbage-collected. The
file descriptor is also closed implicitly when the CLOSE-INPUT-PORT
or CLOSE-OUTPUT-PORT procedures are applied to a port created by
SYS:MAKE-INPUT-PORT or SYS:MAKE-OUTPUT-PORT.
; This example will overwrite "tmpfile"!
;
(let* ((ofd (sys:creat "tmpfile" #o644))
(out (sys:make-output-port ofd)))
(display "foo" out)
(newline out)
(sys:flush out)
(sys:close ofd)
(let* ((ifd (sys:open "tmpfile" sys:read-only))
(in (sys:make-input-port ifd))
(obj (read in)))
(sys:close ifd)
obj)) ==> foo
|