diff --git a/posix/fd.cpp b/posix/fd.cpp index c910d8b1..115bfd93 100644 --- a/posix/fd.cpp +++ b/posix/fd.cpp @@ -215,6 +215,16 @@ fd::lseek (off_t offset, int whence) } +/////////////////////////////////////////////////////////////////////////////// +void +fd::truncate (off_t length) +{ + error::try_call ( + ::ftruncate, m_fd, length + ); +} + + /////////////////////////////////////////////////////////////////////////////// fd::operator int (void) const { diff --git a/posix/fd.hpp b/posix/fd.hpp index cc67f50f..1064b9b0 100644 --- a/posix/fd.hpp +++ b/posix/fd.hpp @@ -73,6 +73,10 @@ namespace cruft::posix { [[nodiscard]] off_t lseek (off_t offset, int whence); + //--------------------------------------------------------------------- + void truncate (off_t length); + + /////////////////////////////////////////////////////////////////////// operator int (void) const; int native (void) const { return m_fd; }