Actually, there is an easy solution with fopen()
Posted Sep 20, 2007 16:29 UTC (Thu) by
hummassa (subscriber, #307)
In reply to:
No easy solution with fopen() by dwheeler
Parent article:
Exploiting symlinks and tmpfiles
I tested it on linux, works ok -- except for the fact that it WILL clobber
an empty file:
FILE* open_only_if_does_not_exist(const char *filename) {
FILE* f = fopen(filename, "a");
if( ftell(f) ) {
fclose(f);
return 0;
}
return f;
}
(
Log in to post comments)