| 859 | } |
| 860 | |
| 861 | fs::path GetDefaultDataDir() |
| 862 | { |
| 863 | // Windows: |
| 864 | // old: C:\Users\Username\AppData\Roaming\Bitcoin |
| 865 | // new: C:\Users\Username\AppData\Local\Bitcoin |
| 866 | // macOS: ~/Library/Application Support/Bitcoin |
| 867 | // Unix-like: ~/.bitcoin |
| 868 | #ifdef WIN32 |
| 869 | // Windows |
| 870 | // Check for existence of datadir in old location and keep it there |
| 871 | fs::path legacy_path = GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin"; |
| 872 | if (fs::exists(legacy_path)) return legacy_path; |
| 873 | |
| 874 | // Otherwise, fresh installs can start in the new, "proper" location |
| 875 | return GetSpecialFolderPath(CSIDL_LOCAL_APPDATA) / "Bitcoin"; |
| 876 | #else |
| 877 | fs::path pathRet; |
| 878 | char* pszHome = getenv("HOME"); |
| 879 | if (pszHome == nullptr || strlen(pszHome) == 0) |
| 880 | pathRet = fs::path("/"); |
| 881 | else |
| 882 | pathRet = fs::path(pszHome); |
| 883 | #ifdef __APPLE__ |
| 884 | // macOS |
| 885 | return pathRet / "Library/Application Support/Bitcoin"; |
| 886 | #else |
| 887 | // Unix-like |
| 888 | return pathRet / ".bitcoin"; |
| 889 | #endif |
| 890 | #endif |
| 891 | } |
| 892 | |
| 893 | bool CheckDataDirOption(const ArgsManager& args) |
| 894 | { |
no test coverage detected