Functions for file operations and error handling. More...
Functions | |
int | osio_save_file (char *path, char *relativePath, char *filter) |
Saves a file to the specified path with a given filter. | |
int | osio_open_file (char *path, char *relativePath, char *filter) |
Opens a file from the specified path with a given filter. | |
int | osio_print_error (char *msg) |
Prints an error message to the standard error output. | |
int | update_cwd () |
Updates the current working directory. | |
int | absolute_path_to_relative (char *path) |
Converts an absolute file path to a relative path. | |
int | osio_find (dirent_t ***namelist, const char *path, int(*filter)(const dirent_t *entry)) |
Finds files in a directory that match a given filter. | |
Functions for file operations and error handling.
int osio_save_file | ( | char * | path, |
char * | relativePath, | ||
char * | filter | ||
) |
Saves a file to the specified path with a given filter.
This function attempts to save a file to the location specified by the path
parameter, applying the filter specified by the filter
parameter. The filter can be used to specify file types or other criteria.
path | The path where the file should be saved. |
filter | The filter to apply when saving the file. |
int osio_open_file | ( | char * | path, |
char * | relativePath, | ||
char * | filter | ||
) |
Opens a file from the specified path with a given filter.
This function attempts to open a file from the location specified by the path
parameter, applying the filter specified by the filter
parameter. The filter can be used to specify file types or other criteria.
path | The path from where the file should be opened. |
relativePath | The relative path to the file. |
filter | The filter to apply when opening the file. |
int osio_print_error | ( | char * | msg | ) |
Prints an error message to the standard error output.
This function prints the error message specified by the msg
parameter to the standard error output (stderr). It can be used for logging errors or debugging purposes.
msg | The error message to be printed. |
int update_cwd | ( | ) |
Updates the current working directory.
This function updates the current working directory to the latest state. It can be used to ensure that the program is operating in the correct directory context.
int absolute_path_to_relative | ( | char * | path | ) |
Converts an absolute file path to a relative path.
This function converts the absolute file path specified by the path
parameter to a relative path. It can be useful for creating paths that are relative to the current working directory or another base directory.
path | The absolute path to be converted to a relative path. |
Finds files in a directory that match a given filter.
This function searches for files in the directory specified by the path
parameter that match the filter function provided by the filter
parameter. The filter function should return 1 for files that match the criteria, and 0 for files that do not.
namelist | A pointer to the list of directory entries. |
path | The path to the directory where files should be searched. |
filter | The filter function to apply to the directory entries. |