posix/fd: add an ftruncate wrapper

This commit is contained in:
Danny Robson 2020-01-21 13:03:49 +11:00
parent 0a7adfb037
commit 450b65e2e5
2 changed files with 14 additions and 0 deletions

View File

@ -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
{

View File

@ -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; }