File utilities.
More...
Go to the source code of this file.
char* sb_file_get_contents |
( |
const char * |
path, |
|
|
size_t * |
len, |
|
|
sb_error_t ** |
err |
|
) |
| |
Function that reads the content of a file.
- Parameters
-
path | File path. |
len | Location to store length of file, in bytes, or NULL . |
err | Return location for a sb_error_t, or NULL. |
- Returns
- A string with the content of the file, or
NULL
if some error happened.
- Examples:
- hello_file_read.c.
char* sb_file_get_contents_utf8 |
( |
const char * |
path, |
|
|
size_t * |
len, |
|
|
sb_error_t ** |
err |
|
) |
| |
Function that reads the content of a file, checking if it is encoded in UTF-8 and removing UTF-8 BOM, if needed.
- Parameters
-
path | File path. |
len | Location to store length of file, in bytes, or NULL . |
err | Return location for a sb_error_t, or NULL. |
- Returns
- A string with the content of the file, or
NULL
if some error happened.
- Examples:
- hello_configparser.c.
void sb_file_put_contents |
( |
const char * |
path, |
|
|
const char * |
contents, |
|
|
size_t |
len, |
|
|
sb_error_t ** |
err |
|
) |
| |
Function that writes content to a file.
- Parameters
-
path | File path. |
contents | Content. |
len | Content length. |
err | Return location for a sb_error_t, or NULL. |
- Examples:
- hello_file_write.c.
void sb_mkdir_recursive |
( |
const char * |
path, |
|
|
sb_error_t ** |
err |
|
) |
| |
Function that creates directories recursively. It respects umask when creating directories.
- Parameters
-
path | Directory path. |
err | Return location for a sb_error_t, or NULL. |
- Examples:
- hello_dir_create.c.