Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_stream_filesys.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <vl/vl_memory.h>
#include <vl/vl_stream_filesys.h>
+ Include dependency graph for vl_stream_filesys.c:

Data Structures

struct  vl_stream_ctx_file
 

Functions

vl_streamvlStreamOpenFile (const vl_filesys_path *path, const char *mode)
 Opens a file stream using a vl_filesys_path object.
 
vl_streamvlStreamOpenFileStr (vl_filesys *sys, const char *pathStr, const char *mode)
 Opens a file stream using a raw UTF-8 string path.
 

Data Structure Documentation

◆ vl_stream_ctx_file

struct vl_stream_ctx_file
+ Collaboration diagram for vl_stream_ctx_file:
Data Fields
FILE * handle
vl_bool_t ownsHandle

Function Documentation

◆ vlStreamOpenFile()

vl_stream * vlStreamOpenFile ( const vl_filesys_path path,
const char *  mode 
)

Opens a file stream using a vl_filesys_path object.

██ ██ ██ █████ ███████ █████ ██████ ███ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ███████ ███████ ███████ ██ ███ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ███████ ██ ██ ███████ ██ ██ ██████ ██ ████ ██ ██ ====—: A Data Structure and Algorithms library for C11. :—====

Copyright 2026 Jesse Walker, released under the MIT license. Git Repository: https://github.com/walkerje/veritable_lasagna

Contract

  • Ownership: The caller owns the returned vl_stream pointer and is responsible for calling vlStreamDelete. The stream manages the internal FILE* and closes it on deletion.
  • Lifetime: The stream is valid until its reference count reaches zero.
  • Thread Safety: Thread-safe (the returned stream has an internal mutex).
  • Nullability: Returns NULL if path or mode is NULL, or if the file cannot be opened.
  • Error Conditions: Returns NULL if fopen (or platform equivalent) fails or if heap allocation fails.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: Allocates memory for the vl_stream struct, an internal context struct, and synchronization primitives.
  • Return-value Semantics: Returns a pointer to the new stream, or NULL if the file could not be opened.
Parameters
pathThe path object containing the UTF-8 path.
modeThe standard C fopen mode string (e.g., "rb", "wb", "r+").
Returns
A new stream object, or NULL if the file could not be opened.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlStreamOpenFileStr()

vl_stream * vlStreamOpenFileStr ( vl_filesys sys,
const char *  pathStr,
const char *  mode 
)

Opens a file stream using a raw UTF-8 string path.

This is a convenience wrapper that creates a temporary path object if needed to handle platform-specific encoding conversion.

Contract

  • Ownership: The caller owns the returned vl_stream pointer.
  • Lifetime: The stream is valid until its reference count reaches zero.
  • Thread Safety: Thread-safe.
  • Nullability: Returns NULL if pathStr or mode is NULL. sys can be NULL.
  • Error Conditions: Same as vlStreamOpenFile.
  • Undefined Behavior: None.
  • Memory Allocation Expectations: Same as vlStreamOpenFile.
  • Return-value Semantics: Returns a pointer to the new stream, or NULL if failure.
Parameters
sysThe filesystem context (can be NULL if not using arena/pool features for this op).
pathStrThe UTF-8 path string.
modeThe standard C fopen mode string.
Returns
A new stream object, or NULL if failure.
+ Here is the call graph for this function: