
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>chsize</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
chsize
Usage
#include <io.h>
int chsize(int fd,long posn);
Description
The chsize function will truncate or extend an open file. The argument fd
is the handle of the file to truncate or extend and posn is the new size.
If the specified position is shorter than the existing file, the file
will be truncated. If the specified position is longer than the existing
file, the file will be extended. Note that the new contents of extended
files are undefined.
Example
#include <io.h>
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
int main()
{
int fd;
FILE *fp;
char *fname[2] = {"file1","file2"};
long sizes[2] = {10000L, 20000L};
fd = open(fname[0], O_WRONLY);
fp = fopen(fname[1], "wb");
chsize(fd, sizes[0]);
chsize(fileno(fp), sizes[1]);
return EXIT_SUCCESS;
}
Return Value
0 if successful, otherwise -1.
See Also
filesize, filelength
See Also: filesize filelength
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson