-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace boost/fc filesystem #1011
Conversation
This change will require gcc 9.1+ or clang 9+ (technically libstdc++ & libc++). Please increase the minimum version in the root cmake, Lines 38 to 47 in 69c4e00
(I think it's okay to remove AppleClang completely from this check; what's there isn't correct anyways)
|
Can you test if it's possible to remove this workaround now leap/.github/workflows/build.yaml Lines 134 to 136 in 69c4e00
|
There is at least one remaining
This causes a compile error in gcc12. |
if(save_log) | ||
{ | ||
// Cannot use fc::copy as it does not copy to an existing destination file | ||
fc::rename(log_output.path().preferred_string(), DEEP_MIND_LOGFILE); | ||
std::filesystem::copy(log_output_path, DEEP_MIND_LOGFILE, std::filesystem::copy_options::update_existing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fc::rename()
became fs::copy(.. update_existing)
. The semantics are clearly different between the two. Any reason for the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_output_path
is derived from tmp
of type temp_cfile object which
would remove the file when tmp
is out of scope. Simply rename the file would cause the desctructor tryiing to remove an non-existent file.
if (abi_path.is_relative()) { | ||
abi_path = data_dir / abi_path; | ||
} | ||
|
||
EOS_ASSERT(fc::exists(abi_path) && !fc::is_directory(abi_path), chain::plugin_config_exception, "${path} does not exist or is not a file", ("path", abi_path.generic_string())); | ||
EOS_ASSERT(std::filesystem::exists(abi_path) && !std::filesystem::is_directory(abi_path), chain::plugin_config_exception, "${path} does not exist or is not a file", ("path", abi_path.generic_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding a to_variant(fs::path)
so we don't need to put generic_string()
in all these log/asserts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Although a new logging framework is likely going to make us add fmt::formatter<>
for all our types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like to_variant
is already provided.
temp_cfile(const char* mode = "wb"){ | ||
std::filesystem::path template_path{ std::filesystem::temp_directory_path() / "fc-XXXXXX" }; | ||
char tmp_buf[4096]; | ||
strncpy(tmp_buf, template_path.c_str(), 4096); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can result in tmp_buf
lacking a null terminator.
programs/cleos/program_location.hpp
Outdated
#include <boost/predef/os.h> | ||
#include <filesystem> | ||
|
||
// adapted from boost source boost/dll/detail/posix/program_location_impl.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we continue to use boost DLL with BOOST_DLL_USE_STD_FS
, so we don't need this local reimplementation?
@@ -692,7 +690,7 @@ namespace fc { namespace json_relaxed | |||
|
|||
FC_THROW_EXCEPTION( parse_error_exception, "expected: null|true|false" ); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way you can turn this auto removal of whitespace off in your editor?
This PR
boost
andfc
filesystem withstd::filesystem
,temp_cfile
to replace the usages ofboost::filesystem::unique_path
which doesn't exists instd::filesystem
due to safety concern,Includes
AntelopeIO/appbase#15
AntelopeIO/appbase#16
AntelopeIO/appbase#17
AntelopeIO/appbase#18
AntelopeIO/appbase#19
AntelopeIO/appbase#20
AntelopeIO/appbase#21
AntelopeIO/chainbase#5
AntelopeIO/chainbase#6
AntelopeIO/chainbase#7
AntelopeIO/chainbase#8
AntelopeIO/chainbase#9
Resolves #620