NAME
src/pmc/mappedbytearray.pmc - MappedByteArray PMC
DESCRIPTION
A memory mapped file or shared memory segment accessible as array of bytes.
Bare minimal functionality available, currently only for posix platforms with <sys/mman.h> available, or on mingw32.
Vtable Functions
init()
Initialize without doing any mapping.
init_pmc(PMC *init)
The argument must be a String PMC with a file name.
Maps the whole file.Other options still not available.
destroy()
Free all resources used.
get_bool()
Return true if active,
false otherwise.
elements()
Return the size of the mapped area.
get_integer_keyed_int(INTVAL pos)
Get the byte at pos.
set_integer_keyed_int(INTVAL pos, INTVAL value)
Set the byte at pos to value.
Methods
supported()
Return 0 if file mapping is not supported,
non zero otherwise.
open(STRING *filename, STRING *mode :optional)
Map a file by its name.
The mode argument can be "r",
"w" or "rw",
"r" is assumed if omitted.
close()
Close the mapping.
Return 0 if the mapping was opened aand the unmap operation does not fail,
non zero otherwise.
get_string(INTVAL pos, INTVAL bytelength, STRING *encodingname)
Get a string from the buffer content with the specified encoding.
get_chars(INTVAL pos, INTVAL length)
Get a string from the buffer content with the specified encoding and length in codepoints.
get_utf8(INTVAL pos, INTVAL length)
Get a utf8 string from the buffer content with the specified length in codepoints.
Helper functions
static void unavailable(PARROT_INTERP, const char *msg)
Throws appropriately for functionality not available in the current platform.
static void * mapfromfilehandle(PIOHANDLE handle, unsigned long size, int flag)
Maps a file by its OS handle.
static void * mapfromfilename(PARROT_INTERP, STRING *name, unsigned long *size, int flag)
Maps a file by its filename,
throw if the file can't be opened.
static STRING * build_string(PARROT_INTERP, const unsigned char *content, INTVAL size, const STR_VTABLE *encoding)
Build a string from the buffer content with the encoding specified.
static STRING * get_encoded_chars(PARROT_INTERP, PMC *self, INTVAL pos, INTVAL length, const STR_VTABLE *encoding)
Return the characters starting at pos in the specified encoding.