Unix to Windows Porting Dictionary for HPC |
|
|
RSS
LinksFunction List
|
Table of Contents header file: unistd.h int truncate (const char *path, off_t length) int ftruncate (int fd, off_t length) The Windows _chsize() and _chsize_s() functions perform the same as the Unix ftruncate() function. The difference between the two Windows functions centers mostly with the "size" argument. With Windows you will need to open the file before requesting the truncating because there is no direct equivalent to truncate().
int fh, result;
unsigned int nbytes = BUFSIZ;
/* This replicates the use of truncate */
if (_sopen_s(&f, "data", _O_RDWR) == 0)
{
if (( result = _chsize(f, 12000)) == 0)
printf("Size changed\n" );
else
printf("Size not changed\n)");
_close(f);
}
|
|
|
|