std::filesystem::rename()
instead of std::rename()
. We rely on the
destination to be overwritten if it exists, but std::rename()
’s behavior
is implementation-defined in this case.
std::filesystem::rename()
instead of std::rename()
. We rely on the
destination to be overwritten if it exists, but std::rename()
’s behavior
is implementation-defined in this case.
Please update doc/dependencies to gcc 8 (from 7), as std::fs is not included in gcc 7
Edit: And clang-7
-lstdc++fs
to the build flags via configure by default fixes the compile errors?
Concept ACK! That’s another WIN32 specific hack less.
But yes it’s probably going to be a looong time before this can be merged.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
No conflicts as of last run.
I will leave this as is (open, with failing CI) until the compilers we support catch up with C++17 filesystem support.
I don’t think labeling this as “waiting for author” is quite right.
1006@@ -1005,15 +1007,15 @@ void ArgsManager::LogArgs() const
1007 logArgsPrefix("Command-line arg:", "", m_settings.command_line_options);
1008 }
1009
1010+/**
1011+ * Rename src to dest.
1012+ * @return true if the rename was successful.
1013+ */
.h
file?
If you want, you can now rebase on top of #20744.
I think a rebase is not (strictly) needed, just a (force) push to re-trigger CI.
I don’t think this PR depends on #20744. @fanquake, why do you think this PR cannot be merged before #20744?
Because we are either using boost::filesystem
or std::filesystem
. We’re not going to have the repo exist in some awkward middle ground where we are using both. In any case, using std::filesystem
is not necessarily straight forward, and likely requires the changes in #22937 before it can be used.
std::filesystem
, and the additional linker flags that may be needed, i.e https://github.com/bitcoin/bitcoin/pull/20744/commits/721928821f1623265db9c07f2fcef49a356d477f.
1071-#else
1072- int rc = std::rename(src.string().c_str(), dest.string().c_str());
1073- return (rc == 0);
1074-#endif /* WIN32 */
1075+ std::error_code error;
1076+ std::filesystem::rename(src.string(), dest.string(), error);
In commit “util: use stronger-guarantee rename method” (99b151df9c074f60150c5eb777ed98bfd7118e91)
This will result in narrow string conversion on windows, and after #22937 will be a compiler error. Should be easy to fix by changing to:
0std::filesystem::rename(src.native(), dest.native(), error);
This should also work after #20744, but after #20744 it could be simplified more to
0std::filesystem::rename(src, dest, error);
src
and dest
, thanks!
Conditional code review ACK 99b151df9c074f60150c5eb777ed98bfd7118e91 if this is rebased and .string()
is replaced by .native()
(see comment below).
This is just a review of the c++ code, disregarding build issues. IIUC the new rename function may not be callable on all platforms without some of the build changes in #20744.
Use std::filesystem::rename() instead of std::rename(). We rely on the
destination to be overwritten if it exists, but std::rename()'s behavior
is implementation-defined in this case.
99b151df9c...a9ab42ca97
: rebase due to conflicts and pick up a suggestion.
This now depends on #20744 in two ways:
fs::path
is std::filesystem::path
(passes a variable of type fs::path
to std::filesystem::rename()
).Invalidates ACK from @ryanofsky (conditional)
🐙 This pull request conflicts with the target branch and needs rebase.
Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a “draft”.
vasild
MarcoFalke
laanwj
DrahtBot
luke-jr
fanquake
ryanofsky
Labels
Utils/log/libs
Needs rebase
Milestone
Future