From 9060e1c92abcf9904de87e9df840523e11b65271 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Tue, 22 Nov 2022 12:38:09 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adida=20carpeta=20de=20sistema=20para=20?= =?UTF-8?q?el=20modo=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/director.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 03f2f94..caf1c37 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -351,16 +351,22 @@ bool Director::saveConfig() // Crea la carpeta del sistema donde guardar datos void Director::createSystemFolder() { +#ifdef DEBUG + const std::string folderName = "jaildoctors_dilemma_debug"; +#else + const std::string folderName = "jaildoctors_dilemma"; +#endif + #ifdef _WIN32 - systemFolder = std::string(getenv("APPDATA")) + "/jaildoctors_dilemma"; + systemFolder = std::string(getenv("APPDATA")) + "/" + folderName; #elif __APPLE__ - struct passwd *pw = getpwuid(getuid()); + struct passwd *pw = getpwuid(getuid()); 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__ struct passwd *pw = getpwuid(getuid()); const char *homedir = pw->pw_dir; - systemFolder = std::string(homedir) + "/.jaildoctors_dilemma"; + systemFolder = std::string(homedir) + "/." + folderName; #endif struct stat st = {0}; @@ -380,12 +386,15 @@ void Director::createSystemFolder() case EACCES: printf("the parent directory does not allow write"); exit(EXIT_FAILURE); + case EEXIST: printf("pathname already exists"); exit(EXIT_FAILURE); + case ENAMETOOLONG: printf("pathname is too long"); exit(EXIT_FAILURE); + default: perror("mkdir"); exit(EXIT_FAILURE);