libsaria: Create the saria dir on startup
This is either ~/.saria or ~/.saria-debug, depending on if we're running a debug build or not.
This commit is contained in:
parent
250964a351
commit
a97da1dd05
|
@ -14,5 +14,7 @@ struct file
|
|||
};
|
||||
|
||||
void readdir(string, vector<file> &, vector<file> &);
|
||||
string get_saria_dir();
|
||||
void make_saria_dir();
|
||||
|
||||
#endif /* LIBSARIA_PATH_H */
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
|
||||
#include <libsaria/libsaria.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/path.h>
|
||||
#include <libsaria/print.h>
|
||||
|
||||
void libsaria_init(int argc, char **argv)
|
||||
{
|
||||
println("Initializing libsaria");
|
||||
audio_init(argc, argv);
|
||||
print("saria dir: ");
|
||||
println(get_saria_dir());
|
||||
make_saria_dir();
|
||||
}
|
||||
|
||||
void libsaria_quit()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <libsaria/path.h>
|
||||
|
||||
#include <iostream>
|
||||
|
@ -50,3 +51,22 @@ void readdir(string dir, vector<file> &files, vector<file> &dirs)
|
|||
|
||||
closedir(dp);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static string SARIA_DIR = "/.saria-debug";
|
||||
#else /* DEBUG */
|
||||
static string SARIA_DIR = "/.saria";
|
||||
#endif /* DEBUG */
|
||||
|
||||
string get_saria_dir()
|
||||
{
|
||||
string saria = getenv("HOME");
|
||||
return saria += SARIA_DIR;
|
||||
}
|
||||
|
||||
void make_saria_dir()
|
||||
{
|
||||
string saria = get_saria_dir();
|
||||
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
mkdir(saria.c_str(), mode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue