Pharos
0.7.23
Modern Web Framework & Web App Hosting Service.
Toggle main menu visibility
Loading...
Searching...
No Matches
native_fs.h
Go to the documentation of this file.
1
/**
2
* @file
3
* @brief Declares native filesystem helper routines.
4
*/
5
6
#ifndef PHAROS_NATIVE_FS_H
7
#define PHAROS_NATIVE_FS_H
8
9
#include <stddef.h>
10
#include <stdlib.h>
11
12
/** @name Filesystem helpers
13
* @{
14
*/
15
/**
16
* @brief Creates a directory path and any missing parent directories.
17
* @param path Directory path to ensure exists.
18
* @return 0 on success, or a non-zero status code on failure.
19
*/
20
int
ensure_directory
(
const
char
*path);
21
/**
22
* @brief Copies one file as binary data.
23
* @param source_path Path to the source file.
24
* @param target_path Path to the destination file.
25
* @return 0 on success, or a non-zero status code on failure.
26
*/
27
int
copy_file_binary
(
const
char
*source_path,
const
char
*target_path);
28
/**
29
* @brief Recursively copies one directory tree into another location.
30
* @param source_dir Source directory to copy.
31
* @param target_dir Destination directory to populate.
32
* @return 0 on success, or a non-zero status code on failure.
33
*/
34
int
copy_directory_recursive
(
const
char
*source_dir,
const
char
*target_dir);
35
/**
36
* @brief Recursively removes a directory tree.
37
* @param target_dir Directory tree to remove.
38
* @return 0 on success, or a non-zero status code on failure.
39
*/
40
int
remove_directory_recursive
(
const
char
*target_dir);
41
/**
42
* @brief Writes a text buffer to a file path.
43
* @param path Destination file path.
44
* @param content Text content to write.
45
* @return 0 on success, or a non-zero status code on failure.
46
*/
47
int
write_text_file
(
const
char
*path,
const
char
*content);
48
49
/**
50
* @brief Reads the full content of a binary file into a heap-allocated buffer.
51
* @param path File path to read.
52
* @param out_size Receives the byte count (may be NULL).
53
* @return Newly allocated buffer with NUL terminator, or NULL on failure.
54
*/
55
unsigned
char
*
read_file_bytes_dup_runtime
(
const
char
*path,
size_t
*out_size);
56
57
/**
58
* @brief Writes a binary byte range to a file, creating parent directories as needed.
59
* @param path Destination file path.
60
* @param data Bytes to write.
61
* @param length Number of bytes to write.
62
* @return 0 on success, non-zero on failure.
63
*/
64
int
write_binary_file_runtime
(
const
char
*path,
const
unsigned
char
*data,
size_t
length);
65
66
/** @} */
67
#endif
ensure_directory
int ensure_directory(const char *path)
Creates a directory path and any missing parent directories.
Definition
native_fs.c:31
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.
Definition
native_json_runtime_ops.c:410
write_text_file
int write_text_file(const char *path, const char *content)
Writes a text buffer to a file path.
Definition
native_fs.c:66
remove_directory_recursive
int remove_directory_recursive(const char *target_dir)
Recursively removes a directory tree.
Definition
native_fs.c:179
copy_directory_recursive
int copy_directory_recursive(const char *source_dir, const char *target_dir)
Recursively copies one directory tree into another location.
Definition
native_fs.c:132
copy_file_binary
int copy_file_binary(const char *source_path, const char *target_path)
Copies one file as binary data.
Definition
native_fs.c:93
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.
Definition
native_json_runtime_ops.c:462
src
native_runtime
c
native_fs.h
Generated by
1.17.0