mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
Simplify fs::path by dropping filename() and make_preferred() overloads
These overloads were needed to allow passing `fs::path` objects directly to libstdc++'s `fstream` constructors, but after the previous commit, there is no longer any remaining code that does pass `fs::path` objects to `fstream` constructors. Writing new code which does this is also discouraged because the standard has been updated in https://wg21.link/lwg3430 to disallow it. Dropping these also means its no longer possible to pass `fs::path` arguments directly to `fstream::open` in libstdc++, which is somewhat unfortunate but not a big loss because it is already not possible to pass them to the constructor. So this commit updates `fstream::open` calls. Additionally, this change required updates to src/bitcoin.cpp since it was relying on the overloaded filename() method.
This commit is contained in:
@@ -209,7 +209,7 @@ static void ExecCommand(const std::vector<const char*>& args, std::string_view w
|
||||
|
||||
// Try to resolve any symlinks and figure out the directory containing the wrapper executable.
|
||||
std::error_code ec;
|
||||
fs::path wrapper_dir{fs::weakly_canonical(wrapper_path, ec)};
|
||||
auto wrapper_dir{fs::weakly_canonical(wrapper_path, ec)};
|
||||
if (wrapper_dir.empty()) wrapper_dir = wrapper_path; // Restore previous path if weakly_canonical failed.
|
||||
wrapper_dir = wrapper_dir.parent_path();
|
||||
|
||||
@@ -225,7 +225,7 @@ static void ExecCommand(const std::vector<const char*>& args, std::string_view w
|
||||
|
||||
// If wrapper is installed in a bin/ directory, look for target executable
|
||||
// in libexec/
|
||||
(wrapper_dir.filename() == "bin" && try_exec(fs::path{wrapper_dir.parent_path()} / "libexec" / arg0.filename())) ||
|
||||
(wrapper_dir.filename() == "bin" && try_exec(wrapper_dir.parent_path() / "libexec" / arg0.filename())) ||
|
||||
#ifdef WIN32
|
||||
// Otherwise check the "daemon" subdirectory in a windows install.
|
||||
(!wrapper_dir.empty() && try_exec(wrapper_dir / "daemon" / arg0.filename())) ||
|
||||
|
||||
Reference in New Issue
Block a user