From 35cb63d3ead1447e7e6cd3b6e7acedd6a86ae8cf Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 9 Aug 2018 12:57:08 -0400 Subject: [PATCH] Call FC wrappers of copy and remove in rename() to get around boost 1.67 boost::filesystem::copy() null pointer dereferencing issue --- src/filesystem.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index bd98e57..8185fc3 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -303,13 +303,14 @@ namespace fc { void rename( const path& f, const path& t ) { try { boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) ); - } catch ( boost::system::system_error& ) { - try{ - boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); - boost::filesystem::remove( boost::filesystem::path(f)); - } catch ( boost::system::system_error& e ) { - FC_THROW( "Rename from ${srcfile} to ${dstfile} failed because ${reason}", - ("srcfile",f)("dstfile",t)("reason",e.what() ) ); + } catch ( boost::system::system_error& er ) { + try { + copy( f, t ); + remove( f ); + } catch ( fc::exception& e ) { + FC_RETHROW_EXCEPTION( e, error, + "Rename from ${srcfile} to ${dstfile} failed due to ${reason}, trying to copy then remove", + ("srcfile",f)("dstfile",t)("reason",er.what()) ); } } catch ( ... ) { FC_THROW( "Rename from ${srcfile} to ${dstfile} failed",