forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadida carpeta de sistema para el modo debug
This commit is contained in:
@@ -351,16 +351,22 @@ bool Director::saveConfig()
|
|||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void Director::createSystemFolder()
|
void Director::createSystemFolder()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
const std::string folderName = "jaildoctors_dilemma_debug";
|
||||||
|
#else
|
||||||
|
const std::string folderName = "jaildoctors_dilemma";
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
systemFolder = std::string(getenv("APPDATA")) + "/jaildoctors_dilemma";
|
systemFolder = std::string(getenv("APPDATA")) + "/" + folderName;
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/Library/Application Support/jaildoctors_dilemma";
|
systemFolder = std::string(homedir) + "/Library/Application Support/" + folderName;
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/.jaildoctors_dilemma";
|
systemFolder = std::string(homedir) + "/." + folderName;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct stat st = {0};
|
struct stat st = {0};
|
||||||
@@ -380,12 +386,15 @@ void Director::createSystemFolder()
|
|||||||
case EACCES:
|
case EACCES:
|
||||||
printf("the parent directory does not allow write");
|
printf("the parent directory does not allow write");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
case EEXIST:
|
case EEXIST:
|
||||||
printf("pathname already exists");
|
printf("pathname already exists");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
case ENAMETOOLONG:
|
case ENAMETOOLONG:
|
||||||
printf("pathname is too long");
|
printf("pathname is too long");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
perror("mkdir");
|
perror("mkdir");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|||||||
Reference in New Issue
Block a user