$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
io.c File Reference
#include "io.h"
#include "log.h"
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for io.c:

Enumerations

enum  { DEFAULT_MAX_FILE_SIZE = 16 * 1024 * 1024 }
 

Functions

char * io_read_file (const char *path, size_t max_size, size_t *out_size)
 Reads an entire file into a null-terminated string. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEFAULT_MAX_FILE_SIZE 

Function Documentation

◆ io_read_file()

char* io_read_file ( const char *  path,
size_t  max_size,
size_t *  out_size 
)

Reads an entire file into a null-terminated string.

Performs security checks to prevent path traversal and applies size limits. The returned buffer must be freed by the caller.

Parameters
pathThe path to the file to read.
max_sizeMaximum allowed file size (0 for default MAX_SHADER_SOURCE_SIZE).
out_sizeOptional pointer to store the actual file size.
Returns
A null-terminated string containing file content, or NULL on error.
Here is the call graph for this function: