diff --git a/io_posix.cpp b/io_posix.cpp index d15dbda3..1e0dbeb3 100644 --- a/io_posix.cpp +++ b/io_posix.cpp @@ -83,7 +83,7 @@ mapped_file::~mapped_file () } -//---------------------------------------------------------------------------- +////////////////////////////////////////////////////////////////////////////// size_t mapped_file::size (void) const { diff --git a/posix/fd.cpp b/posix/fd.cpp index 115bfd93..46a945f6 100644 --- a/posix/fd.cpp +++ b/posix/fd.cpp @@ -107,6 +107,14 @@ fd::stat (void) const } +/////////////////////////////////////////////////////////////////////////////// +void +fd::allocate (int mode, off_t offset, off_t len) +{ + error::try_call (fallocate, m_fd, mode, offset, len); +} + + /////////////////////////////////////////////////////////////////////////////// void fd::close (void) diff --git a/posix/fd.hpp b/posix/fd.hpp index 1064b9b0..0babda96 100644 --- a/posix/fd.hpp +++ b/posix/fd.hpp @@ -57,6 +57,11 @@ namespace cruft::posix { struct ::stat stat (void) const; + /////////////////////////////////////////////////////////////////////// + /// A thin wrapper around `fallocate` + void allocate (int mode, off_t offset, off_t len); + + /////////////////////////////////////////////////////////////////////// void close (void); void reset (int);