squareball
0.2.0.29-1f41
A general-purpose library for C99
|
File utilities. More...
Go to the source code of this file.
Functions | |
char * | sb_file_get_contents (const char *path, size_t *len, sb_error_t **err) |
char * | sb_file_get_contents_utf8 (const char *path, size_t *len, sb_error_t **err) |
void | sb_file_put_contents (const char *path, const char *contents, size_t len, sb_error_t **err) |
void | sb_mkdir_recursive (const char *path, sb_error_t **err) |
File utilities.
char* sb_file_get_contents | ( | const char * | path, |
size_t * | len, | ||
sb_error_t ** | err | ||
) |
Function that reads the content of a file.
This function can generate errors with the following codes:
SB_ERROR_FILE_OPEN
SB_ERROR_FILE_READ
path | File path. |
len | Location to store length of file, in bytes, or NULL . |
err | Return location for a sb_error_t, or NULL. |
NULL
if some error happened. 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.
This function can generate errors with the following codes:
SB_ERROR_FILE_OPEN
SB_ERROR_FILE_READ
path | File path. |
len | Location to store length of file, in bytes, or NULL . |
err | Return location for a sb_error_t, or NULL. |
NULL
if some error happened. 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.
This function can generate errors with the following codes:
SB_ERROR_FILE_OPEN
SB_ERROR_FILE_WRITE
path | File path. |
contents | Content. |
len | Content length. |
err | Return location for a sb_error_t, or NULL. |
void sb_mkdir_recursive | ( | const char * | path, |
sb_error_t ** | err | ||
) |
Function that creates directories recursively. It respects umask when creating directories.
This function can generate errors with the following codes:
SB_ERROR_DIR_CREATE
path | Directory path. |
err | Return location for a sb_error_t, or NULL. |