Soletta™ Framework
|
Useful general file routines. More...
#include <sol-macros.h>
#include <sol-buffer.h>
#include <dirent.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdbool.h>
#include <strings.h>
Go to the source code of this file.
Macros | |
#define | SOL_UTIL_MAX_READ_ATTEMPTS 10 |
Max number of read attempts. More... | |
Enumerations | |
enum | sol_util_iterate_dir_reason { SOL_UTIL_ITERATE_DIR_STOP = 0, SOL_UTIL_ITERATE_DIR_CONTINUE = 1 } |
Return values (for non-error paths) expected from sol_util_iterate_dir() callbacks. More... | |
Functions | |
bool | sol_util_busy_wait_file (const char *path, uint64_t nanoseconds) |
Wait for some file to become available. More... | |
int | sol_util_create_recursive_dirs (const struct sol_str_slice path, mode_t mode) |
Create directories recursively. More... | |
int | sol_util_fd_set_flag (int fd, int flag) |
Set a flag into a file descriptor. More... | |
int | sol_util_file_encode_filename (struct sol_buffer *buf, const struct sol_str_slice value) |
Encode string to be used as a file name. More... | |
struct sol_str_slice | sol_util_file_get_basename (struct sol_str_slice path) |
Get the basename of a path. More... | |
ssize_t | sol_util_fill_buffer (int fd, struct sol_buffer *buffer, size_t size) |
Fills buffer with data read from file fd. More... | |
static int | sol_util_fill_buffer_exactly (int fd, struct sol_buffer *buffer, size_t size) |
Fills buffer with data read from file fd with an exact amount of bytes. More... | |
int | sol_util_get_rootdir (char *out, size_t size) |
Gets the root directory. More... | |
int | sol_util_get_user_config_dir (struct sol_buffer *buffer) |
Get the user context config directory for current app. More... | |
int | sol_util_iterate_dir (const char *path, enum sol_util_iterate_dir_reason(*iterate_dir_cb)(void *data, const char *dir_path, struct dirent *ent), const void *data) |
Iterate over a directory. More... | |
int | sol_util_load_file_buffer (const char *filename, struct sol_buffer *buf) |
Reads the contents of a file and append to a buffer. More... | |
int | sol_util_load_file_fd_buffer (int fd, struct sol_buffer *buf) |
Reads the contents of a file and append to a buffer. More... | |
int int struct sol_buffer * | sol_util_load_file_fd_raw (int fd) |
Reads the contents of a file. More... | |
char * | sol_util_load_file_fd_string (int fd, size_t *size) |
Reads the contents of a file. More... | |
char * | sol_util_load_file_string (const char *filename, size_t *size) |
Reads the contents of a file. More... | |
int | sol_util_move_file (const char *old_path, const char *new_path, mode_t mode) |
Moves file on filesystem. More... | |
int | sol_util_read_file (const char *path, const char *fmt,...) SOL_ATTR_SCANF(2 |
Reads from a file the contents according with the formatted string. More... | |
int int | sol_util_vread_file (const char *path, const char *fmt, va_list args) SOL_ATTR_SCANF(2 |
Reads from a file the contents according with the formatted string. More... | |
int int | sol_util_vwrite_file (const char *path, const char *fmt, va_list args) SOL_ATTR_PRINTF(2 |
Write the formatted string in the file pointed by path. More... | |
int | sol_util_write_file (const char *path, const char *fmt,...) SOL_ATTR_PRINTF(2 |
Write the formatted string in the file pointed by path. More... | |
int int ssize_t | sol_util_write_file_slice (const char *path, struct sol_str_slice slice) |
Write the slice content the file pointed by path. More... | |
Useful general file routines.