mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 23:54:00 -06:00
Fix of empty error string. No testing errors for boost::filesystem::permission.
This commit is contained in:
parent
ab6e653de4
commit
64f6499db5
3 changed files with 21 additions and 18 deletions
|
@ -75,11 +75,12 @@ enum CopyFileResult {
|
|||
FAIL_CHECK_TARGET_NOT_OPENED
|
||||
};
|
||||
// Copy a file, adjust the access attributes, so that the target is writable.
|
||||
CopyFileResult copy_file_inner(const std::string &from, const std::string &to, boost::system::error_code& error_code);
|
||||
CopyFileResult copy_file_inner(const std::string &from, const std::string &to, std::string& error_message);
|
||||
// Copy file to a temp file first, then rename it to the final file name.
|
||||
// If with_check is true, then the content of the copied file is compared to the content
|
||||
// of the source file before renaming.
|
||||
extern CopyFileResult copy_file(const std::string &from, const std::string &to, boost::system::error_code& error_code, const bool with_check = false);
|
||||
// Additional error info is passed in error message.
|
||||
extern CopyFileResult copy_file(const std::string &from, const std::string &to, std::string& error_message, const bool with_check = false);
|
||||
|
||||
// Compares two files if identical.
|
||||
extern CopyFileResult check_copy(const std::string& origin, const std::string& copy);
|
||||
|
|
|
@ -417,7 +417,7 @@ std::error_code rename_file(const std::string &from, const std::string &to)
|
|||
#endif
|
||||
}
|
||||
|
||||
CopyFileResult copy_file_inner(const std::string& from, const std::string& to, boost::system::error_code &error_code)
|
||||
CopyFileResult copy_file_inner(const std::string& from, const std::string& to, std::string& error_message)
|
||||
{
|
||||
const boost::filesystem::path source(from);
|
||||
const boost::filesystem::path target(to);
|
||||
|
@ -434,25 +434,26 @@ CopyFileResult copy_file_inner(const std::string& from, const std::string& to, b
|
|||
boost::system::error_code ec;
|
||||
|
||||
boost::filesystem::permissions(target, perms, ec);
|
||||
if (ec)
|
||||
BOOST_LOG_TRIVIAL(error) << "Copy file permisions before copy error message: " << ec.message();
|
||||
//if (ec)
|
||||
// BOOST_LOG_TRIVIAL(error) << "Copy file permisions before copy error message: " << ec.message();
|
||||
// This error code is passed up
|
||||
error_code.clear();
|
||||
boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, error_code);
|
||||
if (error_code) {
|
||||
ec.clear();
|
||||
boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, ec);
|
||||
if (ec) {
|
||||
error_message = ec.message();
|
||||
return FAIL_COPY_FILE;
|
||||
}
|
||||
ec.clear();
|
||||
//ec.clear();
|
||||
boost::filesystem::permissions(target, perms, ec);
|
||||
if (ec)
|
||||
BOOST_LOG_TRIVIAL(error) << "Copy file permisions after copy error message: " << ec.message();
|
||||
//if (ec)
|
||||
// BOOST_LOG_TRIVIAL(error) << "Copy file permisions after copy error message: " << ec.message();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
CopyFileResult copy_file(const std::string &from, const std::string &to, boost::system::error_code &error_code, const bool with_check)
|
||||
CopyFileResult copy_file(const std::string &from, const std::string &to, std::string& error_message, const bool with_check)
|
||||
{
|
||||
std::string to_temp = to + ".tmp";
|
||||
CopyFileResult ret_val = copy_file_inner(from, to_temp, error_code);
|
||||
CopyFileResult ret_val = copy_file_inner(from, to_temp, error_message);
|
||||
if(ret_val == SUCCESS)
|
||||
{
|
||||
if (with_check)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue