Try this:
#include <stdio.h>
#include <io.h>
BOOL SetFileLength(int fd, long long pos)
{
HANDLE fh = (HANDLE)_get_osfhandle(fd);
if (!SetFilePointerEx(fh, *((LARGE_INTEGER *)&pos), NULL, FILE_BEGIN))
return FALSE;
return SetEndOfFile(fh);
}
BOOL fset_file_len(FILE *fp, long long pos)
{
return SetFileLength(_fileno(fp), pos);
}
I had no time to test, but should work.