Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletutil.cpp
// Copyright (c) 2017 The Bitcoin Core developers | // Copyright (c) 2017 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <wallet/walletutil.h> | #include <wallet/walletutil.h> | ||||
fs::path GetWalletDir() { | fs::path GetWalletDir() { | ||||
fs::path path; | fs::path path; | ||||
if (gArgs.IsArgSet("-walletdir")) { | if (gArgs.IsArgSet("-walletdir")) { | ||||
path = fs::system_complete(gArgs.GetArg("-walletdir", "")); | path = gArgs.GetArg("-walletdir", ""); | ||||
if (!fs::is_directory(path)) { | if (!fs::is_directory(path)) { | ||||
// If the path specified doesn't exist, we return the deliberately | // If the path specified doesn't exist, we return the deliberately | ||||
// invalid empty string. | // invalid empty string. | ||||
path = ""; | path = ""; | ||||
} | } | ||||
} else { | } else { | ||||
path = GetDataDir(); | path = GetDataDir(); | ||||
// If a wallets directory exists, use that, otherwise default to | // If a wallets directory exists, use that, otherwise default to | ||||
// GetDataDir | // GetDataDir | ||||
if (fs::is_directory(path / "wallets")) { | if (fs::is_directory(path / "wallets")) { | ||||
path /= "wallets"; | path /= "wallets"; | ||||
} | } | ||||
} | } | ||||
return path; | return path; | ||||
} | } |