ocarina/libsaria/fs.cpp

37 lines
600 B
C++
Raw Normal View History

// 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 */