NAME
src/io/filehandle.c - FileHandle utility functions
DESCRIPTION
This file defines a set of utility functions for the FileHandle PMC used by all operating systems. For the primary public I/O API, see src/io/api.c.
Functions
INTVAL Parrot_io_parse_open_flags
Parses a Parrot string for file open mode flags (STRING *Parrot_io_make_string
Creates a STRING* suitable for returning results from IO read functions.
The passed in - Point to a NULL STRING
- Point to a real STRING
- Point to a fake STRING with (strstart, bufused) holding the *buffer information.
void Parrot_io_set_os_handle
Sets the PIOHANDLE Parrot_io_get_os_handle
Retrieve the void Parrot_io_set_flags
Set the INTVAL Parrot_io_get_flags
Set the void Parrot_io_set_file_size
Set the PIOOFF_T Parrot_io_get_file_size
Get the void Parrot_io_set_buffer_start
Set the unsigned char *Parrot_io_get_buffer_start
Get the unsigned char *Parrot_io_get_buffer_next
Get the void Parrot_io_set_buffer_next
Set the unsigned char *Parrot_io_get_buffer_end
Get the void Parrot_io_set_buffer_end
Set the INTVAL Parrot_io_get_buffer_flags
Get the void Parrot_io_set_buffer_flags
Set the size_t Parrot_io_get_buffer_size
Get the void Parrot_io_set_buffer_size
Set the void Parrot_io_clear_buffer
Clear the filehandle buffer and free the associated memory.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
PIOOFF_T Parrot_io_get_file_position
Get the PIOOFF_T Parrot_io_get_last_file_position
Get the void Parrot_io_set_file_position
Get the INTVAL Parrot_io_is_encoding
Check whether the encoding attribute of the filehandle matches a passed in string.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
INTVAL Parrot_io_close_filehandle
Flushes and closes the INTVAL Parrot_io_is_closed_filehandle
Test whether a filehandle is closed.
void Parrot_io_flush_filehandle
Flushes the
r
for read,
w
for write,
a
for append,
and p
for pipe) and returns the combined generic bit flags.
buf
parameter can:
strstart
tells this function to allocate the STRING memory.
os_handle
attribute of the FileHandle object,
which stores the low-level filehandle for the OS.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.Possibly,
this function should reset some characteristics of the object (like buffer and file positions) to their default values.
os_handle
attribute of the FileHandle object,
which stores the low-level filehandle for the OS.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
flags
attribute of the FileHandle object,
which stores bitwise flags marking filehandle characteristics.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
flags
attribute of the FileHandle object,
which stores bitwise flags marking filehandle characteristics.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
file_size
attribute of the FileHandle object,
which stores the current file size.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
file_size
attribute of the FileHandle object,
which stores the current file size.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_start
attribute of the FileHandle object,
which stores the position of the start of the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_start
attribute of the FileHandle object,
which stores the position of the start of the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_next
attribute of the FileHandle object,
which stores the current position within the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_next
attribute of the FileHandle object,
which stores the current position within the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_end
attribute of the FileHandle object,
which stores the position of the end of the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_end
attribute of the FileHandle object,
which stores the position of the end of the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_flags
attribute of the FileHandle object,
which stores a collection of flags specific to the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_flags
attribute of the FileHandle object,
which stores a collection of flags specific to the buffer.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_size
attribute of the FileHandle object,
which stores the size of the buffer (in bytes).Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
buffer_size
attribute of the FileHandle object,
which stores the size of the buffer (in bytes).Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
file_pos
attribute of the FileHandle object,
which stores the current file position of the filehandle.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
file_pos
attribute of the FileHandle object,
which stores the current file position of the filehandle.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
file_pos
attribute of the FileHandle object,
which stores the current file position of the filehandle.
Also set the last_pos
attribute to the previous value of file_pos
.Currently,
this pokes directly into the C struct of the FileHandle PMC.
This needs to change to a general interface that can be used by all subclasses and polymorphic equivalents of FileHandle.
For now,
hiding it behind a function,
so it can be cleanly changed later.
FileHandle
PMC *pmc
,
but leaves the object intact to be reused or collected.
FileHandle
PMC *pmc
.SEE ALSO
src/io/unix.c, src/io/win32.c, src/io/stdio.c, src/io/io_private.h.