|
void | fs_listdir (const char *dir, FS_LISTDIR_CALLBACK cb, int type, void *user) |
|
void | fs_listdir_fileinfo (const char *dir, FS_LISTDIR_CALLBACK_FILEINFO cb, int type, void *user) |
|
int | fs_makedir (const char *path) |
|
int | fs_removedir (const char *path) |
|
int | fs_makedir_rec_for (const char *path) |
|
int | fs_storage_path (const char *appname, char *path, int max) |
|
int | fs_is_file (const char *path) |
|
int | fs_is_dir (const char *path) |
|
int | fs_is_relative_path (const char *path) |
|
int | fs_chdir (const char *path) |
|
char * | fs_getcwd (char *buffer, int buffer_size) |
|
const char * | fs_filename (const char *path) |
|
void | fs_split_file_extension (const char *filename, char *name, size_t name_size, char *extension=nullptr, size_t extension_size=0) |
|
int | fs_parent_dir (char *path) |
|
int | fs_remove (const char *filename) |
|
int | fs_rename (const char *oldname, const char *newname) |
|
int | fs_file_time (const char *name, time_t *created, time_t *modified) |
|
Utilities for accessing the file system.
◆ fs_chdir()
int fs_chdir |
( |
const char * |
path | ) |
|
Changes the current working directory.
- Parameters
-
path | New working directory path. |
- Returns
- 0 on success, 1 on failure.
◆ fs_file_time()
int fs_file_time |
( |
const char * |
name, |
|
|
time_t * |
created, |
|
|
time_t * |
modified |
|
) |
| |
Gets the creation and the last modification date of a file or directory.
- Parameters
-
name | Path of a file or directory. |
created | Pointer where the creation time will be stored. |
modified | Pointer where the modification time will be stored. |
- Returns
- 0 on success, non-zero on failure.
◆ fs_filename()
const char * fs_filename |
( |
const char * |
path | ) |
|
Gets the name of a file or folder specified by a path, i.e. the last segment of the path.
- Parameters
-
path | Path from which to retrieve the filename. |
- Returns
- Filename of the path.
◆ fs_getcwd()
char * fs_getcwd |
( |
char * |
buffer, |
|
|
int |
buffer_size |
|
) |
| |
Gets the current working directory.
- Parameters
-
buffer | Buffer that will receive the current working directory. |
buffer_size | Size of the buffer. |
- Returns
- Pointer to the buffer on success, nullptr on failure.
◆ fs_is_dir()
int fs_is_dir |
( |
const char * |
path | ) |
|
Checks if a folder exists.
- Parameters
-
- Returns
- 1 if a folder with the given path exists, 0 on failure or if the folder does not exist.
◆ fs_is_file()
int fs_is_file |
( |
const char * |
path | ) |
|
Checks if a file exists.
- Parameters
-
- Returns
- 1 if a file with the given path exists, 0 on failure or if the file does not exist.
◆ fs_is_relative_path()
int fs_is_relative_path |
( |
const char * |
path | ) |
|
Checks whether a given path is relative or absolute.
- Parameters
-
- Returns
- 1 if relative, 0 if absolute.
◆ fs_listdir()
Lists the files and folders in a directory.
- Parameters
-
dir | Directory to list. |
cb | Callback function to call for each entry. |
type | Type of the directory. |
user | Pointer to give to the callback. |
◆ fs_listdir_fileinfo()
Lists the files and folders in a directory and gets additional file information.
- Parameters
-
dir | Directory to list. |
cb | Callback function to call for each entry. |
type | Type of the directory. |
user | Pointer to give to the callback. |
◆ fs_makedir()
int fs_makedir |
( |
const char * |
path | ) |
|
Creates a directory.
- Parameters
-
- Returns
- 0 on success. Negative value on failure.
◆ fs_makedir_rec_for()
int fs_makedir_rec_for |
( |
const char * |
path | ) |
|
Recursively creates parent directories for a file or directory.
- Parameters
-
path | File or directory for which to create parent directories. |
- Returns
- 0 on success. Negative value on failure.
◆ fs_parent_dir()
int fs_parent_dir |
( |
char * |
path | ) |
|
Get the parent directory of a directory.
- Parameters
-
path | Path of the directory. The parent will be store in this buffer as well. |
- Returns
- 0 on success, 1 on failure.
◆ fs_remove()
int fs_remove |
( |
const char * |
filename | ) |
|
Deletes a file.
- Parameters
-
filename | Path of the file to delete. |
- Returns
- 0 on success, 1 on failure.
◆ fs_removedir()
int fs_removedir |
( |
const char * |
path | ) |
|
Removes a directory.
- Parameters
-
- Returns
- 0 on success. Negative value on failure.
◆ fs_rename()
int fs_rename |
( |
const char * |
oldname, |
|
|
const char * |
newname |
|
) |
| |
Renames the file or directory. If the paths differ the file will be moved.
- Parameters
-
oldname | The current path of a file or directory. |
newname | The new path for the file or directory. |
- Returns
- 0 on success, 1 on failure.
◆ fs_split_file_extension()
void fs_split_file_extension |
( |
const char * |
filename, |
|
|
char * |
name, |
|
|
size_t |
name_size, |
|
|
char * |
extension = nullptr , |
|
|
size_t |
extension_size = 0 |
|
) |
| |
Splits a filename into name (without extension) and file extension.
- Parameters
-
filename | The filename to split. |
name | Buffer that will receive the name without extension, may be nullptr. |
name_size | Size of the name buffer (ignored if name is nullptr). |
extension | Buffer that will receive the extension, may be nullptr. |
extension_size | Size of the extension buffer (ignored if extension is nullptr). |
◆ fs_storage_path()
int fs_storage_path |
( |
const char * |
appname, |
|
|
char * |
path, |
|
|
int |
max |
|
) |
| |
Fetches per user configuration directory.
- Parameters
-
appname | Name of the application. |
path | Buffer that will receive the storage path. |
max | Size of the buffer. |
- Returns
- 0 on success. Negative value on failure.