MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetDefaultDataDir

Function GetDefaultDataDir

src/common/args.cpp:861–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859}
860
861fs::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
893bool CheckDataDirOption(const ArgsManager& args)
894{

Callers 3

StartLoggingFunction · 0.85
getDefaultDataDirectoryFunction · 0.85
GetDataDirMethod · 0.85

Calls 3

GetSpecialFolderPathFunction · 0.85
existsFunction · 0.85
pathClass · 0.50

Tested by

no test coverage detected