filesystem::rename() can handle file from cross device

This commit is contained in:
alt 2014-03-20 09:27:32 +08:00
parent e4e99f98d9
commit 7506790bee

View file

@ -234,8 +234,13 @@ namespace fc {
try {
boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) );
} catch ( boost::system::system_error& e ) {
FC_THROW( "Rename from ${srcfile} to ${dstfile} failed because ${reason}",
("srcfile",f)("dstfile",t)("reason",e.what() ) );
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 ( ... ) {
FC_THROW( "Rename from ${srcfile} to ${dstfile} failed",
("srcfile",f)("dstfile",t)("inner", fc::except_str() ) );