Core/Posix: Fix file opening in ReadWrite mode
Former-commit-id: 7c4a5d3e31e9449fa3c23cfad58523ed54b7834a
This commit is contained in:
parent
840c591b6e
commit
5e8f8549af
|
|
@ -54,31 +54,21 @@ namespace Nz
|
|||
int flags;
|
||||
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
|
||||
if (mode & OpenMode_ReadOnly)
|
||||
flags = O_RDONLY;
|
||||
else if (mode & OpenMode_ReadWrite)
|
||||
{
|
||||
if (mode & OpenMode_ReadWrite)
|
||||
flags = O_CREAT | O_RDWR;
|
||||
|
||||
if (mode & OpenMode_Append)
|
||||
flags |= O_APPEND;
|
||||
|
||||
if (mode & OpenMode_Truncate)
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
else if (mode & OpenMode_ReadOnly)
|
||||
flags = O_RDONLY;
|
||||
else if (mode & OpenMode_WriteOnly)
|
||||
{
|
||||
flags = O_CREAT | O_WRONLY;
|
||||
|
||||
if (mode & OpenMode_Append)
|
||||
flags |= O_APPEND;
|
||||
|
||||
if (mode & OpenMode_Truncate)
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
if (mode & OpenMode_Append)
|
||||
flags |= O_APPEND;
|
||||
|
||||
if (mode & OpenMode_Truncate)
|
||||
flags |= O_TRUNC;
|
||||
|
||||
///TODO: lock
|
||||
// if ((mode & OpenMode_Lock) == 0)
|
||||
// shareMode |= FILE_SHARE_WRITE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue