fix File::open() when opening for writing

This commit is contained in:
Josh Holtrop 2016-07-24 17:06:56 -04:00
parent a416a47b29
commit e66130b603

View File

@ -19,8 +19,16 @@
*/
bool File::open(const char * filename, bool writing)
{
int flags = (writing ? 0 : O_RDONLY) | JES_O_BINARY;
int fd = ::open(filename, flags);
int fd;
if (writing)
{
/* TODO: handle mode */
fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC | JES_O_BINARY, 0644);
}
else
{
fd = ::open(filename, O_RDONLY | JES_O_BINARY);
}
if (fd < 0)
{
return false;