mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge pull request #1173 from andreabonel/fix_issue_1120
Fix location for default cookie path
This commit is contained in:
commit
285a18dbe9
3 changed files with 27 additions and 2 deletions
|
|
@ -134,8 +134,7 @@ static fs::path GetMainchainAuthCookieFile()
|
|||
if (gArgs.GetChainName() == "liquidv1") {
|
||||
cookie_file = ".cookie";
|
||||
}
|
||||
std::string path = gArgs.GetArg("-mainchainrpccookiefile", cookie_file);
|
||||
return AbsPathForConfigVal(fs::path(path));
|
||||
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), gArgs.GetArg("-mainchainrpccookiefile", cookie_file));
|
||||
}
|
||||
|
||||
bool GetMainchainAuthCookie(std::string *cookie_out)
|
||||
|
|
|
|||
|
|
@ -827,6 +827,31 @@ fs::path GetDefaultDataDir()
|
|||
}
|
||||
#endif
|
||||
|
||||
fs::path GetMainchainDefaultDataDir()
|
||||
{
|
||||
// Windows: C:\Users\Username\AppData\Roaming\Bitcoin
|
||||
// macOS: ~/Library/Application Support/Bitcoin
|
||||
// Unix-like: ~/.bitcoin
|
||||
#ifdef WIN32
|
||||
// Windows
|
||||
return GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin";
|
||||
#else
|
||||
fs::path pathRet;
|
||||
char* pszHome = getenv("HOME");
|
||||
if (pszHome == nullptr || strlen(pszHome) == 0)
|
||||
pathRet = fs::path("/");
|
||||
else
|
||||
pathRet = fs::path(pszHome);
|
||||
#ifdef MAC_OSX
|
||||
// macOS
|
||||
return pathRet / "Library/Application Support/Bitcoin";
|
||||
#else
|
||||
// Unix-like
|
||||
return pathRet / ".bitcoin";
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CheckDataDirOption()
|
||||
{
|
||||
std::string datadir = gArgs.GetArg("-datadir", "");
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ void ReleaseDirectoryLocks();
|
|||
|
||||
bool TryCreateDirectories(const fs::path& p);
|
||||
fs::path GetDefaultDataDir();
|
||||
fs::path GetMainchainDefaultDataDir();
|
||||
// Return true if -datadir option points to a valid directory or is not specified.
|
||||
bool CheckDataDirOption();
|
||||
fs::path GetConfigFile(const std::string& confPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue