Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_fs.h File Reference

Declares native filesystem helper routines. More...

#include <stddef.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

Filesystem helpers
int ensure_directory (const char *path)
 Creates a directory path and any missing parent directories.
int copy_file_binary (const char *source_path, const char *target_path)
 Copies one file as binary data.
int copy_directory_recursive (const char *source_dir, const char *target_dir)
 Recursively copies one directory tree into another location.
int remove_directory_recursive (const char *target_dir)
 Recursively removes a directory tree.
int write_text_file (const char *path, const char *content)
 Writes a text buffer to a file path.
unsigned char * read_file_bytes_dup_runtime (const char *path, size_t *out_size)
 Reads the full content of a binary file into a heap-allocated buffer.
int write_binary_file_runtime (const char *path, const unsigned char *data, size_t length)
 Writes a binary byte range to a file, creating parent directories as needed.

Detailed Description

Declares native filesystem helper routines.

Definition in file native_fs.h.

Function Documentation

◆ copy_directory_recursive()

int copy_directory_recursive ( const char * source_dir,
const char * target_dir )

Recursively copies one directory tree into another location.

Parameters
source_dirSource directory to copy.
target_dirDestination directory to populate.
Returns
0 on success, or a non-zero status code on failure.

Definition at line 132 of file native_fs.c.

References copy_directory_recursive(), copy_file_binary(), ensure_directory(), path_is_directory(), path_join(), and streq().

Referenced by build_app_from_root_native(), build_dev_docs_directory_native(), and copy_directory_recursive().

◆ copy_file_binary()

int copy_file_binary ( const char * source_path,
const char * target_path )

Copies one file as binary data.

Parameters
source_pathPath to the source file.
target_pathPath to the destination file.
Returns
0 on success, or a non-zero status code on failure.

Definition at line 93 of file native_fs.c.

References ensure_directory(), and path_dirname().

Referenced by build_app_from_root_native(), build_native_backup_report_local_json(), build_native_restore_report_local_json(), copy_directory_recursive(), and native_write_backup_state_snapshot().

◆ ensure_directory()

◆ read_file_bytes_dup_runtime()

unsigned char * read_file_bytes_dup_runtime ( const char * path,
size_t * out_size )

Reads the full content of a binary file into a heap-allocated buffer.

Reads one file into an owned binary buffer and appends a trailing NUL byte for text helpers.

Parameters
pathFile path to read.
out_sizeReceives the byte count (may be NULL).
Returns
Newly allocated buffer with NUL terminator, or NULL on failure.

Reads the full content of a binary file into a heap-allocated buffer.

Parameters
pathFile path to load.
out_sizeReceives the byte count excluding the trailing NUL.
Returns
Newly allocated buffer, or NULL on failure.

Definition at line 410 of file native_json_runtime_ops.c.

Referenced by handle_dynamic_file_signature_command(), handle_dynamic_multipart_extract_file_command(), handle_dynamic_multipart_extract_text_command(), handle_dynamic_multipart_filename_command(), native_dynamic_relational_file_signature_dup(), request_body_bytes_dup_runtime(), request_form_field_value_dup_runtime(), and store_uploaded_media().

◆ remove_directory_recursive()

int remove_directory_recursive ( const char * target_dir)

Recursively removes a directory tree.

Parameters
target_dirDirectory tree to remove.
Returns
0 on success, or a non-zero status code on failure.

Definition at line 179 of file native_fs.c.

References path_exists(), path_is_directory(), path_join(), pharos_fs_unlink, remove_directory_recursive(), and streq().

Referenced by build_app_from_root_native(), build_dev_docs_directory_native(), and remove_directory_recursive().

◆ write_binary_file_runtime()

int write_binary_file_runtime ( const char * path,
const unsigned char * data,
size_t length )

Writes a binary byte range to a file, creating parent directories as needed.

Writes one binary byte range to a file path, creating parent directories as needed.

Parameters
pathDestination file path.
dataBytes to write.
lengthNumber of bytes to write.
Returns
0 on success, non-zero on failure.

Writes a binary byte range to a file, creating parent directories as needed.

Parameters
pathDestination path.
dataBytes to write.
lengthNumber of bytes to write.
Returns
0 on success, or a non-zero status code on failure.

Definition at line 462 of file native_json_runtime_ops.c.

References ensure_directory(), and path_dirname().

Referenced by store_uploaded_media().

◆ write_text_file()

int write_text_file ( const char * path,
const char * content )