naev 0.12.5
nfile.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include "SDL.h" // IWYU pragma: keep
8#include "naev.h" // IWYU pragma: keep
9#include <stdint.h>
10#include <stdlib.h>
12
13#include "attributes.h"
14
15SENTINEL( 0 )
16int _nfile_concatPaths( char buf[static 1], int maxLength,
17 const char path[static 1], ... );
28#define nfile_concatPaths( buf, maxLength, path, ... ) \
29 _nfile_concatPaths( buf, maxLength, path, ##__VA_ARGS__, NULL )
30
31const char *nfile_configPath( void );
32const char *nfile_cachePath( void );
33
34int nfile_dirMakeExist( const char *path );
35int nfile_dirExists( const char *path );
36int nfile_fileExists( const char *path ); /* Returns 1 on exists */
37int nfile_backupIfExists( const char *path );
38int nfile_copyIfExists( const char *path1, const char *path2 );
39char *nfile_readFile( size_t *filesize, const char *path );
40int nfile_touch( const char *path );
41int nfile_writeFile( const char *data, size_t len, const char *path );
42int nfile_isSeparator( uint32_t c );
43int nfile_simplifyPath( char path[static 1] );
44
45#if !SDL_VERSION_ATLEAST( 3, 0, 0 )
46typedef struct SDL_DialogFileFilter {
47 const char *name;
48 const char *pattern;
50
51typedef void( SDLCALL *SDL_DialogFileCallback )( void *userdata,
52 const char *const *filelist,
53 int filter );
54
55void SDL_ShowOpenFileDialog( SDL_DialogFileCallback callback, void *userdata,
56 SDL_Window *window,
57 const SDL_DialogFileFilter *filters,
58 const char *default_location,
59 SDL_bool allow_many );
60void SDL_ShowOpenFolderDialog( SDL_DialogFileCallback callback, void *userdata,
61 SDL_Window *window, const char *default_location,
62 SDL_bool allow_many );
63void SDL_ShowSaveFileDialog( SDL_DialogFileCallback callback, void *userdata,
64 SDL_Window *window,
65 const SDL_DialogFileFilter *filters,
66 const char *default_location );
67#endif /* !SDL_VERSION_ATLEAST( 3, 0, 0 ) */
Header file with generic functions and naev-specifics.
int nfile_simplifyPath(char path[static 1])
Simplifies the path removing things like ".." or consecutive "/".
Definition nfile.c:676
int nfile_copyIfExists(const char *file1, const char *file2)
Copy a file, if it exists.
Definition nfile.c:378
const char * nfile_configPath(void)
Gets Naev's config path (for user preferences such as conf.lua)
Definition nfile.c:113
int nfile_writeFile(const char *data, size_t len, const char *path)
Tries to write a file.
Definition nfile.c:559
char * nfile_readFile(size_t *filesize, const char *path)
Tries to read a file.
Definition nfile.c:442
int nfile_dirMakeExist(const char *path)
Creates a directory if it doesn't exist.
Definition nfile.c:277
int nfile_backupIfExists(const char *path)
Backup a file, if it exists.
Definition nfile.c:356
const char * nfile_cachePath(void)
Gets Naev's cache path (for cached data such as generated textures)
Definition nfile.c:162
int nfile_fileExists(const char *path)
Checks to see if a file exists.
Definition nfile.c:329
int nfile_touch(const char *path)
Tries to create the file if it doesn't exist.
Definition nfile.c:533
int nfile_isSeparator(uint32_t c)
Checks to see if a character is used to separate files in a path.
Definition nfile.c:605
int nfile_dirExists(const char *path)
Checks to see if a directory exists.
Definition nfile.c:309
static const double c[]
Definition rng.c:256