50 lines
814 B
C++
50 lines
814 B
C++
|
/*
|
||
|
* Copyright 2013 (c) Bryan Schumaker.
|
||
|
*/
|
||
|
#include <file.h>
|
||
|
|
||
|
#include <glib.h>
|
||
|
|
||
|
#ifdef CONFIG_TEST
|
||
|
#define OCARINA_DIR "ocarina-test"
|
||
|
#elif CONFIG_DEBUG
|
||
|
#define OCARINA_DIR "ocarina-debug"
|
||
|
#else
|
||
|
#define OCARINA_DIR "ocarina"
|
||
|
#endif
|
||
|
|
||
|
File :: File(std::string path, FileLocHint file_hint)
|
||
|
: hint(file_hint)
|
||
|
{
|
||
|
std::string dir;
|
||
|
|
||
|
switch (file_hint) {
|
||
|
case FILE_TYPE_CONFIG:
|
||
|
dir = g_get_user_config_dir();
|
||
|
break;
|
||
|
case FILE_TYPE_DATA:
|
||
|
dir = g_get_user_data_dir();
|
||
|
break;
|
||
|
case FILE_TYPE_LEGACY:
|
||
|
dir = g_get_home_dir();
|
||
|
}
|
||
|
|
||
|
dir += "/";
|
||
|
switch (file_hint) {
|
||
|
case FILE_TYPE_CONFIG:
|
||
|
case FILE_TYPE_DATA:
|
||
|
dir += OCARINA_DIR;
|
||
|
break;
|
||
|
case FILE_TYPE_LEGACY:
|
||
|
dir += ".";
|
||
|
dir += OCARINA_DIR;
|
||
|
}
|
||
|
|
||
|
filepath = dir + "/" + path;
|
||
|
}
|
||
|
|
||
|
const char *File :: get_filepath()
|
||
|
{
|
||
|
return filepath.c_str();
|
||
|
}
|