libsaria: Begin appdir code
I'm going to replace my old path lookup code with something designed around accessing files in a pre-set directory. I'm also moving back to putting files in the home diretory, rather than the XDG_CONFIG directory. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
02740d1feb
commit
95cc9d272f
|
@ -0,0 +1,20 @@
|
|||
#ifndef LIBSARIA_FS_H
|
||||
#define LIBSARIA_FS_H
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
namespace app
|
||||
{
|
||||
|
||||
void init(string);
|
||||
void mkdir();
|
||||
|
||||
} /* Namespace: app */
|
||||
|
||||
} /* Namespace: libsaria */
|
||||
|
||||
#endif /* LIBSARIA_FS_H */
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
|
||||
#include <libsaria/fs.h>
|
||||
#include <libsaria/print.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static string appdir;
|
||||
static mode_t dirmode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
|
||||
static void make_dir(string path)
|
||||
{
|
||||
println("Making directory: " + path);
|
||||
mkdir(path.c_str(), dirmode);
|
||||
}
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
void app::mkdir()
|
||||
{
|
||||
make_dir(appdir.c_str());
|
||||
}
|
||||
|
||||
void app::init(string name)
|
||||
{
|
||||
string home = getenv("HOME");
|
||||
appdir = home + "/." + name;
|
||||
#ifdef DEBUG
|
||||
appdir += "-debug";
|
||||
#endif
|
||||
mkdir();
|
||||
}
|
||||
|
||||
} /* Namespace: libsaria */
|
|
@ -2,7 +2,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <libsaria/libsaria.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/fs.h>
|
||||
/*#include <libsaria/audio.h>
|
||||
#include <libsaria/path.h>
|
||||
#include <libsaria/prefs.h>
|
||||
#include <libsaria/print.h>
|
||||
|
@ -10,15 +11,18 @@
|
|||
#include <libsaria/format.h>
|
||||
#include <libsaria/index.h>
|
||||
#include <libsaria/stack.h>
|
||||
*/
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
void init(string app, int argc, char **argv)
|
||||
void init(string name, int argc, char **argv)
|
||||
{
|
||||
srand( time(NULL) );
|
||||
println("Initializing libsaria");
|
||||
|
||||
app::init(name);
|
||||
|
||||
/*libsaria::prefs::load();
|
||||
audio::init(argc, argv);
|
||||
|
||||
|
@ -31,11 +35,11 @@ namespace libsaria
|
|||
|
||||
void quit()
|
||||
{
|
||||
println("Quitting libsaria");
|
||||
/*println("Quitting libsaria");
|
||||
audio::quit();
|
||||
print_format_stats();
|
||||
index::print_stats();
|
||||
close_pipes();
|
||||
close_pipes();*/
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue