mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:05:08 +00:00
LibCore: Make CFile::open() truncate when opening something "WriteOnly"
Unless we're also opening to append (and/or if the file is required to be a new file), CFile::open(WriteOnly) will now truncate the file.
This commit is contained in:
parent
67d2875d60
commit
aa49419173
1 changed files with 3 additions and 0 deletions
|
@ -34,6 +34,9 @@ bool CFile::open(CIODevice::OpenMode mode)
|
|||
flags |= O_RDONLY;
|
||||
} else if (mode & CIODevice::WriteOnly) {
|
||||
flags |= O_WRONLY | O_CREAT;
|
||||
bool should_truncate = !((mode & CIODevice::Append) || (mode & CIODevice::MustBeNew));
|
||||
if (should_truncate)
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
if (mode & CIODevice::Append)
|
||||
flags |= O_APPEND;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue