parrotcode: FileHandle utility functions | |
Contents | C |
src/io/filehandle.c - FileHandle utility functions
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.
INTVAL Parrot_io_parse_open_flags
r
for read,
w
for write,
a
for append,
and p
for pipe) and returns the combined generic bit flags.
STRING *Parrot_io_make_string
buf
parameter can:
strstart
tells this function to allocate the STRING memory.
void Parrot_io_set_os_handle
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.
PIOHANDLE Parrot_io_get_os_handle
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.
void Parrot_io_set_flags
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.
INTVAL Parrot_io_get_flags
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.
void Parrot_io_set_file_size
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.
PIOOFF_T Parrot_io_get_file_size
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.
void Parrot_io_set_buffer_start
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.
unsigned char *Parrot_io_get_buffer_start
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.
unsigned char *Parrot_io_get_buffer_next
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.
void Parrot_io_set_buffer_next
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.
unsigned char *Parrot_io_get_buffer_end
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.
void Parrot_io_set_buffer_end
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.
INTVAL Parrot_io_get_buffer_flags
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.
void Parrot_io_set_buffer_flags
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.
size_t Parrot_io_get_buffer_size
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.
void Parrot_io_set_buffer_size
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.
void Parrot_io_clear_buffer
PIOOFF_T Parrot_io_get_file_position
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.
PIOOFF_T Parrot_io_get_last_file_position
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.
void Parrot_io_set_file_position
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.
INTVAL Parrot_io_is_encoding
INTVAL Parrot_io_close_filehandle
FileHandle
PMC *pmc
,
but leaves the object intact to be reused or collected.
INTVAL Parrot_io_is_closed_filehandle
void Parrot_io_flush_filehandle
FileHandle
PMC *pmc
.src/io/unix.c, src/io/win32.c, src/io/stdio.c, src/io/io_private.h.
|