default data dir's Backward compatibility

pull/8202/head
mj-xmr 2 years ago
parent 90b02ebabb
commit 668f32f557
No known key found for this signature in database
GPG Key ID: C101BF94093451E0

@ -597,6 +597,32 @@ std::string get_nix_version_display_string()
}
#endif
std::string DEPRECATED_get_default_data_dir()
{
// Kept for backward compatibility
/* Please for the love of god refactor the ifdefs out of this */
// namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\CRYPTONOTE_NAME
// Windows >= Vista: C:\Users\Username\AppData\Roaming\CRYPTONOTE_NAME
// Unix & Mac: ~/.CRYPTONOTE_NAME
std::string config_folder;
#ifdef WIN32
config_folder = get_special_folder_path(CSIDL_COMMON_APPDATA, true) + "\\" + CRYPTONOTE_NAME;
#else
std::string pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
pathRet = "/";
else
pathRet = pszHome;
config_folder = (pathRet + "/." + CRYPTONOTE_NAME);
#endif
return config_folder;
}
std::string get_default_data_dir()
{
/* Please for the love of god refactor the ifdefs out of this */
@ -606,10 +632,10 @@ std::string get_nix_version_display_string()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\CRYPTONOTE_NAME
// Linux: XDG_DATA_HOME or ~/.local/share/CRYPTONOTE_NAME
// Mac: ~/Library/Application Support/CRYPTONOTE_NAME
std::string config_folder;
std::string data_folder;
#ifdef WIN32
config_folder = get_special_folder_path(CSIDL_COMMON_APPDATA, true) + "\\" + CRYPTONOTE_NAME;
data_folder = get_special_folder_path(CSIDL_COMMON_APPDATA, true) + "\\" + CRYPTONOTE_NAME;
#else // Posix
std::string pathRet;
const std::string dirSep = "/";
@ -635,10 +661,22 @@ std::string get_nix_version_display_string()
{
pathRet = pszFallback;
}
config_folder = (pathRet + dirSep + CRYPTONOTE_NAME);
data_folder = (pathRet + dirSep + CRYPTONOTE_NAME);
#endif
return config_folder;
const std::string & data_folder_deprecated = DEPRECATED_get_default_data_dir();
if (boost::filesystem::exists(data_folder_deprecated))
{
MWARNING("Your data are still located in the deprecated folder: '" << data_folder_deprecated << "'. "
<< "Please consider moving the data to the new folder: '" << data_folder << "'. "
<< "Until then, the deprecated folder shall be used."
);
return data_folder_deprecated;
}
else
{
return data_folder;
}
}
bool create_directories_if_necessary(const std::string& path)

Loading…
Cancel
Save