File Handles¶
File handles are the entities through which we perform input and output to the file system. They are one underlying implementation of handles.
Ordinarily you would create input or output file handles with
open-input-file filename
and open-output-file
filename
respectively but you can also open-file filename
mode
for some choice of mode
.
File Handle Predicates¶
- function file-handle? o¶
test if o is a file handle
- Param o:
object to test
- Return:
#t
if o is a file handle,#f
otherwise
- function input-file-handle? o¶
test if o is an input file handle
- Param o:
object to test
- Return:
#t
if o is an input file handle,#f
otherwise
- function output-file-handle? o¶
test if o is an output file handle
- Param o:
object to test
- Return:
#t
if o is an output file handle,#f
otherwise
File Handle Constructors¶
- function open-input-file name¶
open input file name
- Param name:
file name
- Type name:
string
- Return:
file handle
- Rtype:
handle
- function open-output-file name¶
open output file name
- Param name:
file name
- Type name:
string
- Return:
file handle
- Rtype:
handle
- function open-file name mode¶
open input file name using mode mode
- Param name:
file name
- Type name:
string
- Param mode:
open mode
- Type mode:
string
- Return:
file handle
- Rtype:
handle
mode can be one of the usual fopen(3) mode characters but must start with r, w or a:
flag
open(2)
r
O_RDONLY
w
O_WRONLY
|O_CREAT
|O_TRUNC
a
O_WRONLY
|O_CREAT
|O_APPEND
+
O_RDWR
in place ofO_RDONLY
orO_WRONLY
b
ignored
e
O_CLOEXEC
x
O_EXCL
- function open-file-from-fd fd [name [mode]]¶
construct an input file handle from fd using the name name and mode mode
- Param fd:
file descriptor
- Type fd:
C/int
- Param name:
file name for display, defaults to
/dev/fd/fd
- Type name:
string, optional
- Param mode:
file mode for opening, defaults to
"r"
- Type mode:
string, optional
- Return:
file handle
- Rtype:
handle
Use
#n
for name if you only want to set modeSee open-file for mode values.
- function open-input-file-from-fd fd [name [mode]]¶
construct an input file handle from fd using the name name and mode mode
- Param fd:
file descriptor
- Type fd:
C/int
- Param name:
file name for display, defaults to
/dev/fd/fd
- Type name:
string, optional
- Param mode:
file mode for opening, defaults to
"r"
- Type mode:
string, optional
- Return:
file handle
- Rtype:
handle
Use
#n
for name if you only want to set modeSee open-file for mode values.
- function open-output-file-from-fd fd [name [mode]]¶
construct an output file handle from fd using the name name and mode mode
- Param fd:
file descriptor
- Type fd:
C/int
- Param name:
file name for display, defaults to
/dev/fd/fd
- Type name:
string, optional
- Param mode:
file mode for opening, defaults to
"w"
- Type mode:
string, optional
- Return:
file handle
- Rtype:
handle
Use
#n
for name if you only want to set modeSee open-file for mode values.
File Handle Attributes¶
- function file-handle-fd fh¶
return the file descriptor associated with file handle fh
- Param fh:
file handle to query
- Type fh:
file handle
- Return:
file descriptor
- Rtype:
C/int
Last built at 2025-02-05T07:10:41Z+0000 from 62cca4c (dev) for Idio 0.3.b.6