Espen Ruud Schultz
2003-07-10 14:28:38 UTC
When I use the open() function from io.h to open a file ( or create if it
doesn't exist ) the file is always created with the read only flag. This is
the basic of my code:
int FileHandler = open( FileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY |
O_BINARY );
if( FileHandler == -1 ) { delete[] SaveFileData; return
Status::ErrorOpeningFile; }
int FileWrite = write( FileHandler, SaveFileData,
FileData.FileHeader.FileSize );
if( FileWrite == -1 ) { delete[] SaveFileData; close( FileHandler );
return Status::ErrorWritingFile; }
int FileClose = close( FileHandler );
if( FileClose == -1 ) { delete[] SaveFileData; close( FileHandler );
return Status::ErrorClosingFile; }
This happens with created files or existing files. I remember having this
problem before, but then it only happened when creating files, not when
writing to existing ones. But then I was dealing with text files, and now I
do binary...
How do I fix this?
TIA!
, Espen
doesn't exist ) the file is always created with the read only flag. This is
the basic of my code:
int FileHandler = open( FileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY |
O_BINARY );
if( FileHandler == -1 ) { delete[] SaveFileData; return
Status::ErrorOpeningFile; }
int FileWrite = write( FileHandler, SaveFileData,
FileData.FileHeader.FileSize );
if( FileWrite == -1 ) { delete[] SaveFileData; close( FileHandler );
return Status::ErrorWritingFile; }
int FileClose = close( FileHandler );
if( FileClose == -1 ) { delete[] SaveFileData; close( FileHandler );
return Status::ErrorClosingFile; }
This happens with created files or existing files. I remember having this
problem before, but then it only happened when creating files, not when
writing to existing ones. But then I was dealing with text files, and now I
do binary...
How do I fix this?
TIA!
, Espen