libite
Functions
truncatef.c File Reference
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
Include dependency graph for truncatef.c:

Functions

int truncatef (off_t length, const char *fmt,...)
 Truncate a file based on the formatted string. More...
 

Detailed Description

Author
Joachim Wiberg
Date
2021

Function Documentation

◆ truncatef()

int truncatef ( off_t  length,
const char *  fmt,
  ... 
)

Truncate a file based on the formatted string.

Parameters
lengthSize in bytes to truncate file to, zero to empty it
fmtFormatted string to be composed into a pathname

This is an extension to the truncate() family, lessening the burden of having to compose the filename from parts in a seprate buffer.

Returns
Upon successful completion truncate() returns POSIX OK(0), otherwise, -1 is returned and errno is set to indicate error.