resize()
PROTOTYPE
#include <posix.h>
int resize(const char *path, off_t length);
DESCRIPTION
resize() is a non-standard routine that sets the length of the regular file specified by path to length characters. Paths starting with ‘/’ are absolute. Otherwise they are relative to the CWD. If the file is extended, the extended area is left uninitialized.
resize() behaves like truncate() except if the file is extended, the extended area is not zero-filled. Protocols like CIFS that extend a file to its projected new length immediately before writing to it, can use resize() instead of truncate() for higher performance.
The caller needs search access to the path prefix and write access to the specified file. If the file’s length is changed, its status change and data modification timestamps are updated.
If successful, resize() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EACCES | No execute access to a directory in the path prefix or no write access to the specified file. |
| EFAULT | path equals NULL. |
| EINVAL | length is negative. |
| EISDIR | The specified file is a directory. |
| ENAMETOOLONG | A name in path exceeds the effective maximum file name length. |
| ENOENT | path is the empty string or includes a file that was not found. |
| ENOSPC | No space is left on volume to write file data. |
| ENOTDIR | One of the non-leaf path components is not a directory. |
| ENXIO | The volume has been removed. |
| EROFS | The volume is read-only. |