@@ -928,27 +928,33 @@ void NotifyBacked(const CWallet& wallet, bool fSuccess, std::string strMessage)
928928 wallet.NotifyWalletBacked (fSuccess , strMessage);
929929}
930930
931- bool BackupWallet (const CWallet& wallet, const fs::path& strDest, bool fEnableCustom )
931+ // Returns first the pathCustom, second the pathWithFile.
932+ std::pair<fs::path, fs::path> GetBackupPath (const CWallet& wallet)
932933{
933934 fs::path pathCustom;
934- fs::path pathWithFile;
935- if (fEnableCustom ) {
936- pathWithFile = gArgs .GetArg (" -backuppath" , " " );
937- if (!pathWithFile.empty ()) {
938- if (!pathWithFile.has_extension ()) {
939- pathCustom = pathWithFile;
940- pathWithFile /= wallet.GetUniqueWalletBackupName ();
941- } else {
942- pathCustom = pathWithFile.parent_path ();
943- }
944- try {
945- fs::create_directories (pathCustom);
946- } catch (const fs::filesystem_error& e) {
947- NotifyBacked (wallet, false , strprintf (" %s\n " , e.what ()));
948- pathCustom = " " ;
949- }
935+ fs::path pathWithFile = gArgs .GetArg (" -backuppath" , " " );
936+ if (!pathWithFile.empty ()) {
937+ if (!pathWithFile.has_extension ()) {
938+ pathCustom = pathWithFile;
939+ pathWithFile /= wallet.GetUniqueWalletBackupName ();
940+ } else {
941+ pathCustom = pathWithFile.parent_path ();
942+ }
943+ try {
944+ fs::create_directories (pathCustom);
945+ } catch (const fs::filesystem_error& e) {
946+ NotifyBacked (wallet, false , strprintf (" %s\n " , e.what ()));
947+ pathCustom = " " ;
950948 }
951949 }
950+ return {pathCustom, pathWithFile};
951+ }
952+
953+ bool BackupWallet (const CWallet& wallet, const fs::path& strDest)
954+ {
955+ const auto & pathsPair = GetBackupPath (wallet);
956+ fs::path pathCustom = pathsPair.first ;
957+ fs::path pathWithFile = pathsPair.second ;
952958
953959 while (true ) {
954960 {
0 commit comments