fix File::open() when opening for writing

This commit is contained in:
josh committed 2016-07-24 17:16:05 -04:00
1 parent a416a47b29
commit e66130b603
1 file changed
+10 -2
+10 -2
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;