mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
optimize openModeToFopenMode() and openModeToOpenFlags() functions
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8c1c4be290
commit
538dc6495c
1 changed files with 8 additions and 8 deletions
|
@ -61,7 +61,11 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QF
|
|||
QFileSystemMetaData &metaData)
|
||||
{
|
||||
QByteArray mode;
|
||||
if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) {
|
||||
if (flags & QIODevice::Append) {
|
||||
mode = "ab";
|
||||
if (flags & QIODevice::ReadOnly)
|
||||
mode += '+';
|
||||
} else if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) {
|
||||
mode = "rb";
|
||||
if (flags & QIODevice::WriteOnly) {
|
||||
metaData.clearFlags(QFileSystemMetaData::FileType);
|
||||
|
@ -78,11 +82,6 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QF
|
|||
if (flags & QIODevice::ReadOnly)
|
||||
mode += '+';
|
||||
}
|
||||
if (flags & QIODevice::Append) {
|
||||
mode = "ab";
|
||||
if (flags & QIODevice::ReadOnly)
|
||||
mode += '+';
|
||||
}
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
// must be glibc >= 2.7
|
||||
|
@ -99,9 +98,10 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QF
|
|||
*/
|
||||
static inline int openModeToOpenFlags(QIODevice::OpenMode mode)
|
||||
{
|
||||
int oflags = QT_OPEN_RDONLY;
|
||||
#ifdef QT_LARGEFILE_SUPPORT
|
||||
oflags |= QT_OPEN_LARGEFILE;
|
||||
int oflags = QT_OPEN_RDONLY | QT_OPEN_LARGEFILE;
|
||||
#else
|
||||
int oflags = QT_OPEN_RDONLY;
|
||||
#endif
|
||||
|
||||
if ((mode & QFile::ReadWrite) == QFile::ReadWrite) {
|
||||
|
|
Loading…
Add table
Reference in a new issue