Handles read/write abstractions to the users directory.
More...
#include "nfile.h"
#include "array.h"
#include "conf.h"
#include "log.h"
#include "nstring.h"
Go to the source code of this file.
Handles read/write abstractions to the users directory.
- Todo:
- Add support for Windows and macOS.
Definition in file nfile.c.
◆ _nfile_concatPaths()
| int _nfile_concatPaths |
( |
char |
buf[static 1], |
|
|
int |
maxLength, |
|
|
const char |
path[static 1], |
|
|
|
... |
|
) |
| |
◆ for() [1/2]
◆ for() [2/2]
| for |
( |
;p ! |
[0] = '\0'; p++ | ) |
|
◆ if() [1/2]
| if |
( |
! |
nfile_dirExistsopath | ) |
|
◆ if() [2/2]
| if |
( |
strncpy( |
path = = NULL | ) |
|
◆ nfile_backupIfExists()
| int nfile_backupIfExists |
( |
const char * |
path | ) |
|
Backup a file, if it exists.
- Parameters
-
| path | printf formatted string pointing to the file to backup. |
- Returns
- 0 on success, or if file does not exist, -1 on error.
Definition at line 343 of file nfile.c.
◆ nfile_cachePath()
| const char * nfile_cachePath |
( |
void |
| ) |
|
Gets Naev's cache path (for cached data such as generated textures)
- Returns
- The xdg cache path.
Definition at line 159 of file nfile.c.
◆ nfile_configPath()
| const char * nfile_configPath |
( |
void |
| ) |
|
Gets Naev's config path (for user preferences such as conf.lua)
- Returns
- The xdg config path.
Definition at line 116 of file nfile.c.
◆ nfile_copyIfExists()
| int nfile_copyIfExists |
( |
const char * |
file1, |
|
|
const char * |
file2 |
|
) |
| |
Copy a file, if it exists.
- Parameters
-
| file1 | Filename to copy from. |
| file2 | Filename to copy to. |
- Returns
- 0 on success, or if file1 does not exist, -1 on error.
Definition at line 365 of file nfile.c.
◆ nfile_dirExists()
| int nfile_dirExists |
( |
const char * |
path | ) |
|
Checks to see if a directory exists.
- Parameters
-
- Returns
- 1 on exists, 0 otherwise
Definition at line 296 of file nfile.c.
◆ nfile_dirMakeExist()
| int nfile_dirMakeExist |
( |
const char * |
path | ) |
|
Creates a directory if it doesn't exist.
- Parameters
-
| path | Path to create directory if it doesn't exist. |
- Returns
- 0 on success.
Definition at line 267 of file nfile.c.
◆ nfile_fileExists()
| int nfile_fileExists |
( |
const char * |
path | ) |
|
Checks to see if a file exists.
- Parameters
-
| path | string pointing to the file to check for existence. |
- Returns
- 1 if file exists, 0 if it doesn't or -1 on error.
Definition at line 316 of file nfile.c.
◆ nfile_isSeparator()
| int nfile_isSeparator |
( |
uint32_t |
c | ) |
|
Checks to see if a character is used to separate files in a path.
- Parameters
-
- Returns
- 1 if is a separator, 0 otherwise.
Definition at line 581 of file nfile.c.
◆ nfile_readFile()
| char * nfile_readFile |
( |
size_t * |
filesize, |
|
|
const char * |
path |
|
) |
| |
Tries to read a file.
- Parameters
-
| filesize | Stores the size of the file. |
| path | Path of the file. |
- Returns
- The file data.
Definition at line 427 of file nfile.c.
◆ nfile_touch()
| int nfile_touch |
( |
const char * |
path | ) |
|
Tries to create the file if it doesn't exist.
- Parameters
-
| path | Path of the file to create. |
Definition at line 512 of file nfile.c.
◆ nfile_writeFile()
| int nfile_writeFile |
( |
const char * |
data, |
|
|
size_t |
len, |
|
|
const char * |
path |
|
) |
| |
Tries to write a file.
- Parameters
-
| data | Pointer to the data to write. |
| len | The size of data. |
| path | Path of the file. |
- Returns
- 0 on success, -1 on error.
Definition at line 538 of file nfile.c.
◆ len
◆ naev_cachePath
Store Naev's cache path.
Definition at line 153 of file nfile.c.
◆ naev_configPath
Store Naev's config path.
Definition at line 110 of file nfile.c.
Initial value:
Definition at line 207 of file nfile.c.
◆ ret
◆ return