Grow the file with descriptor to at least the specified size.

Synopsis

Declared in <bdls_filesystemutil.h>

static
int
growFile(
    FileDescriptor descriptor,
    Offset size,
    bool reserveFlag = false,
    std::size_t increment = k_DEFAULT_FILE_GROWTH_INCREMENT);

Description

Grow the file with the specified descriptor to the size of at least the specified size bytes. Return 0 on success, and a non‐zero value otherwise. If the optionally specified reserveFlag is true, make sure the space on disk is preallocated and not allocated on demand, preventing a possible out‐of‐disk‐space error when accessing the data on file systems with sparse file support. Preallocation is done by writing unspecified data to file in blocks of the optionally specified increment or a default value if increment is zero or unspecified. Note that if the size of the file is greater than or equal to size, this function has no effect. Also note that the contents of the newly grown portion of the file is undefined.

Return Value

0 on success, and a non‐zero value otherwise

Parameters

Name

Description

descriptor

file descriptor of the file to grow

size

minimum size, in bytes, to which the file is grown

reserveFlag

whether to preallocate disk space

increment

block size used when preallocating space

Created with MrDocs