Cleanup #ifdef mess in RsAccountsDetail::PathDataDirectory()

This commit is contained in:
Gioacchino Mazzurco 2016-12-22 13:47:08 +01:00
parent 06a1020724
commit 3de3becb9b

View File

@ -743,9 +743,6 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
{ {
std::string dataDirectory; std::string dataDirectory;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
#ifdef __APPLE__ #ifdef __APPLE__
/* NOTE: OSX also qualifies as BSD... so this #ifdef must be before the BSD check. */ /* NOTE: OSX also qualifies as BSD... so this #ifdef must be before the BSD check. */
@ -775,17 +772,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
*/ */
dataDirectory = "/usr/local/share/retroshare"; dataDirectory = "/usr/local/share/retroshare";
std::cerr << "getRetroshareDataDirectory() BSD: " << dataDirectory; std::cerr << "getRetroshareDataDirectory() BSD: " << dataDirectory;
#elif defined(WINDOWS_SYS)
#else
/* For Linux, the data directory is set in libretroshare.pro */
#ifndef DATA_DIR
#error DATA_DIR variable not set. Cannot compile.
#endif
dataDirectory = DATA_DIR;
std::cerr << "getRetroshareDataDirectory() Linux: " << dataDirectory << std::endl;
#endif
#else
// if (RsInitConfig::portable) // if (RsInitConfig::portable)
// { // {
// /* For Windows Portable, files must be in the data directory */ // /* For Windows Portable, files must be in the data directory */
@ -805,21 +792,29 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
/* Use RetroShare's exe dir */ /* Use RetroShare's exe dir */
dataDirectory = "."; dataDirectory = ".";
#elif defined(DATA_DIR)
dataDirectory = DATA_DIR;
// For all other OS the data directory must be set in libretroshare.pro
#else
# error "For your target OS automatic data dir discovery is not supported, cannot compile if DATA_DIR variable not set."
#endif #endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
if (!check) if (!check)
{
std::cerr << "getRetroshareDataDirectory() unckecked: " << dataDirectory << std::endl;
return dataDirectory; return dataDirectory;
}
/* Make sure the directory exists, else return emptyString */ /* Make sure the directory exists, else return emptyString */
if (!RsDirUtil::checkDirectory(dataDirectory)) if (!RsDirUtil::checkDirectory(dataDirectory))
{ {
std::cerr << "Data Directory not Found: " << dataDirectory << std::endl; std::cerr << "getRetroshareDataDirectory() not found: " << dataDirectory << std::endl;
dataDirectory = ""; dataDirectory = "";
} }
else else
{ {
std::cerr << "Data Directory Found: " << dataDirectory << std::endl; std::cerr << "getRetroshareDataDirectory() found: " << dataDirectory << std::endl;
} }
return dataDirectory; return dataDirectory;