Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

MinGW program

Name: Anonymous 2007-07-03 16:01 ID:QeLHvrNT

I'm porting a small app from linux to windows and I need a replacement for truncate() function

will this:

FILE *file;
char *path="/tmp/aaa.txt";
long outpos;
file = fopen(path);
/* some code changing file */
chsize(file->_file, outpos);
fclose(file);

work as in the same way as truncate()?

Name: Anonymous 2007-07-04 9:14 ID:Heaven

file = fopen(path);
FAIL.
FILE * fopen(const char * restrict path, const char * restrict mode);

truncate(path);
FAIL.
int truncate(const char *path, off_t length);

also, if you have the file open for writing you can just use ftruncate() on the file descriptor (file) instead of using truncate() on the path.
ftruncate() is in mingw's unistd.h.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List