diff --git a/include/fc/filesystem.hpp b/include/fc/filesystem.hpp index f7eb868..3661813 100644 --- a/include/fc/filesystem.hpp +++ b/include/fc/filesystem.hpp @@ -115,6 +115,7 @@ namespace fc { bool remove( const path& p ); void copy( const path& from, const path& to ); void rename( const path& from, const path& to ); + void resize_file( const path& file, size_t s ); void create_hard_link( const path& from, const path& to ); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 5a40007..66f70c1 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -162,6 +162,22 @@ namespace fc { ("srcfile",f)("dstfile",t)("inner", fc::except_str() ) ); } } + void resize_file( const path& f, size_t t ) + { + try { + boost::filesystem::resize_file( f, t ); + } + catch ( boost::system::system_error& e ) + { + FC_THROW( "Resize file '${f}' to size ${s} failed: ${reason}", + ("f",f)("s",t)( "reason", e.what() ) ); + } + catch ( ... ) + { + FC_THROW( "Resize file '${f}' to size ${s} failed: ${reason}", + ("f",f)("s",t)( "reason", fc::except_str() ) ); + } + } void rename( const path& f, const path& t ) { try { boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) );