kiba-engine
Data Structures | Typedefs | Enumerations | Functions
filesystem.h File Reference

Interface to access the platform's filesystem. More...

#include <kiba/defines.h>
Include dependency graph for filesystem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  file_handle
 Handle for a file. More...
 

Typedefs

typedef enum file_modes file_modes
 The modes a file can be opened in. More...
 
typedef struct file_handle file_handle
 Handle for a file.
 

Enumerations

enum  file_modes { FILE_MODE_READ = 1 , FILE_MODE_WRITE = 2 , FILE_MODE_APPEND = 4 }
 The modes a file can be opened in. More...
 

Functions

KB_API b8 filesystem_exists (const char *path)
 Check if a given path exists. More...
 
KB_API b8 filesystem_open (file_handle *file, const char *path, b8 binary, file_modes modes)
 
KB_API void filesystem_close (file_handle *file)
 
KB_API b8 filesystem_size (file_handle *file, usize *size)
 
KB_API b8 filesystem_read (file_handle *file, usize size, void *out, usize *bytes_read)
 
KB_API b8 filesystem_read_line (file_handle *file, usize max_size, char *out, usize *chars_read)
 
KB_API b8 filesystem_read_all (file_handle *file, usize max_size, void *out, usize *bytes_read)
 
KB_API b8 filesystem_read_all_text (file_handle *file, usize max_size, char *out, usize *chars_read)
 
KB_API b8 filesystem_write (file_handle *file, usize size, const void *data, usize *bytes_written)
 
KB_API b8 filesystem_write_line (file_handle *file, usize size, const char *data, usize *chars_written)
 

Detailed Description

Interface to access the platform's filesystem.

Definition in file filesystem.h.

Typedef Documentation

◆ file_modes

typedef enum file_modes file_modes

The modes a file can be opened in.

Any combination of them are valid.

Enumeration Type Documentation

◆ file_modes

enum file_modes

The modes a file can be opened in.

Any combination of them are valid.

Enumerator
FILE_MODE_READ 

Needed to be able to read from a file.

FILE_MODE_WRITE 

Needed to be able to write to a file.

FILE_MODE_APPEND 

Needed if the file should not be truncated when opened for writing.

Definition at line 15 of file filesystem.h.

Function Documentation

◆ filesystem_exists()

KB_API b8 filesystem_exists ( const char *  path)

Check if a given path exists.

Path can point to a file or directory.

Parameters
paththe path to the file
Returns
true if the path exists, false otherwise

Definition at line 16 of file filesystem.c.