parrotcode: Parrot I/O API | |
Contents | C |
src/io/api.c - Parrot I/O API
The Parrot I/O subsystem provides the core I/O functionality for all parts of Parrot. This file implements the public interface to the I/O subsystem. Common utility functions that aren't part of the public interface are defined in src/io/common.c and utility functions for a specific platform are in src/io/unix.c, src/io/win32.c, or src/io/portable.c. The platform is selected in include/parrot/io.h, based on #defines from the configuration process.
The FileHandle
PMC provides the class-based interface for filehandles that is used in Parrot ops.
PMC *Parrot_io_new_pmc
flags
is set in the returned PMC.
PMC *Parrot_io_open
PMC *Parrot_io_fdopen
FileHandle
PMC for a given set of flags on an existing,
open file descriptor.This is used particularly to initialize the STD*
IO handles onto the OS IO handles (0,
1,
2).
INTVAL Parrot_io_close
INTVAL Parrot_io_is_closed
void Parrot_io_flush
ParrotIO
PMC *pmc
.
STRING *Parrot_io_reads
STRING*
holding up to len
bytes.
STRING *Parrot_io_readline
STRING*
holding the next line read from the file.
INTVAL Parrot_io_write
len
bytes from *buffer
to *pmc
.
PIOOFF_T Parrot_io_seek
*pmc
to offset bytes
from the position indicated by w
.
Typically w
will be 0
for the start of the file,
1
for the current position,
and 2
for the end.
PIOOFF_T Parrot_io_tell
*pmc
.
INTVAL Parrot_io_peek
INTVAL Parrot_io_eof
*pmc
's current read/write position is EOF
.
INTVAL Parrot_io_puts
*s
tp *pmc
.
C string version.
INTVAL Parrot_io_putps
*s
to *pmc
.
Parrot string version.
INTVAL Parrot_io_fprintf
*pmc
.
INTVAL Parrot_io_printf
stdout
.
INTVAL Parrot_io_eprintf
stderr
.
PIOHANDLE Parrot_io_getfd
*pmc
's file descriptor,
or 0
if it is not defined.
INTVAL Parrot_io_is_tty
*pmc
is a console/tty.Parrot_io_STD*
Functions PMC *Parrot_io_STDIN
FileHandle
PMC for stdin
.
PMC *Parrot_io_STDOUT
FileHandle
PMC for stdout
.
PMC *Parrot_io_STDERR
FileHandle
PMC for stderr
.These are used to create offsets for the seek
op.
PIOOFF_T Parrot_io_make_offset
offset
.
PIOOFF_T Parrot_io_make_offset32
hi
is shifted 32 bytes to the left and or
ed together with lo
.
This allows 64-bit seeks with only 32-bit INTVALS
.
PIOOFF_T Parrot_io_make_offset_pmc
get_integer
vtable method on *pmc
.io/unix.c, io/win32.c, io/portable.c, io/io_private.h.
|