Cthulhu  0.2.10
Cthulhu compiler collection
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
io.c File Reference
#include "io/io.h"
#include "io/impl.h"
#include "os/os.h"
#include "base/panic.h"
#include "std/str.h"
#include "arena/arena.h"
Include dependency graph for io.c:

Go to the source code of this file.

Functions

STA_DECL os_error_t io_free (io_t *io)
 
STA_DECL os_error_t io_close (io_t *io)
 
STA_DECL size_t io_read (io_t *io, void *dst, size_t size)
 
STA_DECL size_t io_write (io_t *io, const void *src, size_t size)
 
STA_DECL size_t io_printf (io_t *io, const char *fmt,...)
 
STA_DECL size_t io_vprintf (io_t *io, const char *fmt, va_list args)
 vprintf to an io object More...
 
STA_DECL size_t io_size (io_t *io)
 get the total size of an io objects contents More...
 
STA_DECL size_t io_seek (io_t *io, size_t offset)
 seek to an absolute offset in a file More...
 
STA_DECL const char * io_name (const io_t *io)
 get the name of an io object More...
 
STA_DECL void * io_map (io_t *io, os_protect_t protect)
 map an io object into memory maps an io objects entire contents into memory. More...
 
STA_DECL os_error_t io_error (const io_t *io)
 get the last error from the io object More...
 

Function Documentation

◆ io_close()

STA_DECL os_error_t io_close ( io_t io)

Definition at line 38 of file io.c.

◆ io_error()

STA_DECL os_error_t io_error ( const io_t io)

get the last error from the io object

Parameters
iothe io object
Returns
the last set error

Definition at line 144 of file io.c.

◆ io_free()

STA_DECL os_error_t io_free ( io_t io)

Definition at line 26 of file io.c.

◆ io_map()

STA_DECL void* io_map ( io_t io,
os_protect_t  protect 
)

map an io object into memory maps an io objects entire contents into memory.

Warning
while the return value is a mutable pointer, the writability of the memory is determined by protect as well as the access mode the io object was created with.
Parameters
iothe io object to map from
protectthe protection level of the memory
Returns
memory mapping to the contents

Definition at line 120 of file io.c.

◆ io_name()

STA_DECL const char* io_name ( const io_t io)

get the name of an io object

Parameters
iothe io object
Returns
the name of the object

Definition at line 112 of file io.c.

◆ io_printf()

STA_DECL size_t io_printf ( io_t io,
const char *  fmt,
  ... 
)

Definition at line 64 of file io.c.

◆ io_read()

STA_DECL size_t io_read ( io_t io,
void *  dst,
size_t  size 
)

Definition at line 44 of file io.c.

◆ io_seek()

STA_DECL size_t io_seek ( io_t io,
size_t  offset 
)

seek to an absolute offset in a file

Parameters
iothe io object
offsetthe offset to seek to
Returns
the offset after seeking

Definition at line 103 of file io.c.

◆ io_size()

STA_DECL size_t io_size ( io_t io)

get the total size of an io objects contents

Parameters
iothe io object
Returns
the total size in bytes of its contents

Definition at line 94 of file io.c.

◆ io_vprintf()

STA_DECL size_t io_vprintf ( io_t io,
const char *  fmt,
va_list  args 
)

vprintf to an io object

Precondition
the io object must have been created with the eOsAccessWrite flag
Parameters
iothe io object
fmtthe format string
argsthe format arguments
Returns
the number of bytes actually written

Definition at line 79 of file io.c.

◆ io_write()

STA_DECL size_t io_write ( io_t io,
const void *  src,
size_t  size 
)

Definition at line 54 of file io.c.