Mail Archives: djgpp/1997/07/04/09:24:32
I have problems using the remove function. Here a sample of my code:
_creat(datafile,0x00);
fd = _open(datafile,O_WRONLY);
....
/* ask user for file input, and write to file using _write() */
if(_close(fd)!=0) printf("Error using closing file");
/* get filesize of datafile */
fp_filesize = fopen(datafile,"rb");
filesize = filelength(fileno(fp_filesize));
fclose(fp_filesize);
/* delete file if there is no data in it */
if (filesize == 0) {
error = remove(datafile);
printf(datafile,"%xd",error);
}
The function _close doesn't give an error message.
If no data is written to the file, the remove function doesn't remove
the file. The error code is 0xFFFFFFFD. When instead of _create(),
_open(), _close() and _write the functions fopen(), fclose() and fwrite
are used then the remove function works right.
Richard
- Raw text -