Cthulhu  0.2.10
Cthulhu compiler collection
file.c File Reference
#include "os/os.h"
#include "os_common.h"
#include "base/panic.h"
#include "core/macros.h"
#include <limits.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
Include dependency graph for file.c:

Go to the source code of this file.

Functions

STA_DECL os_error_t os_file_exists (const char *path)
 check if a file exists More...
 
CT_LOCAL os_file_impl_t impl_file_open (const char *path, os_access_t access)
 
STA_DECL os_error_t os_tmpfile_open (os_file_t *file)
 
CT_LOCAL bool impl_file_close (os_file_impl_t file)
 
STA_DECL os_error_t os_file_read (os_file_t *file, void *buffer, size_t size, size_t *actual)
 
STA_DECL os_error_t os_file_write (os_file_t *file, const void *buffer, size_t size, size_t *actual)
 
STA_DECL os_error_t os_file_size (os_file_t *file, size_t *actual)
 
STA_DECL os_error_t os_file_resize (os_file_t *file, size_t size)
 truncate/expand a file to a specific size More...
 
STA_DECL os_error_t os_file_seek (os_file_t *file, size_t offset, size_t *actual)
 
STA_DECL os_error_t os_file_tell (os_file_t *file, size_t *actual)
 
CT_LOCAL void * impl_file_map (os_file_t *file, os_protect_t protect, size_t size, os_mapping_t *mapping)
 
CT_LOCAL os_error_t impl_unmap (os_mapping_t *map)
 

Function Documentation

◆ impl_file_close()

CT_LOCAL bool impl_file_close ( os_file_impl_t  file)

Definition at line 76 of file file.c.

◆ impl_file_map()

CT_LOCAL void* impl_file_map ( os_file_t *  file,
os_protect_t  protect,
size_t  size,
os_mapping_t *  mapping 
)

Definition at line 220 of file file.c.

◆ impl_file_open()

CT_LOCAL os_file_impl_t impl_file_open ( const char *  path,
os_access_t  access 
)

Definition at line 50 of file file.c.

◆ impl_unmap()

CT_LOCAL os_error_t impl_unmap ( os_mapping_t *  map)

Definition at line 230 of file file.c.

◆ os_file_exists()

STA_DECL os_error_t os_file_exists ( const char *  path)

check if a file exists

Parameters
paththe path to the file to check
Returns
error if the file could not be checked
Return values
eOsExistsif the file exists
eOsNotFoundif the file does not exist

Definition at line 38 of file file.c.

◆ os_file_read()

STA_DECL os_error_t os_file_read ( os_file_t *  file,
void *  buffer,
size_t  size,
size_t *  actual 
)

Definition at line 82 of file file.c.

◆ os_file_resize()

STA_DECL os_error_t os_file_resize ( os_file_t *  file,
size_t  size 
)

truncate/expand a file to a specific size

Parameters
filethe file to truncate/expand
sizethe size to truncate/expand the file to
Returns
an error if the operation could not be performed

Definition at line 143 of file file.c.

◆ os_file_seek()

STA_DECL os_error_t os_file_seek ( os_file_t *  file,
size_t  offset,
size_t *  actual 
)

Definition at line 165 of file file.c.

◆ os_file_size()

STA_DECL os_error_t os_file_size ( os_file_t *  file,
size_t *  actual 
)

Definition at line 126 of file file.c.

◆ os_file_tell()

STA_DECL os_error_t os_file_tell ( os_file_t *  file,
size_t *  actual 
)

Definition at line 182 of file file.c.

◆ os_file_write()

STA_DECL os_error_t os_file_write ( os_file_t *  file,
const void *  buffer,
size_t  size,
size_t *  actual 
)

Definition at line 104 of file file.c.

◆ os_tmpfile_open()

STA_DECL os_error_t os_tmpfile_open ( os_file_t *  file)

Definition at line 56 of file file.c.