| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
** All rights reserved. |
| 5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
| 6 |
** |
| 7 |
** This file is part of the QtCore module of the Qt Toolkit. |
| 8 |
** |
| 9 |
** $QT_BEGIN_LICENSE:LGPL$ |
| 10 |
** No Commercial Usage |
| 11 |
** This file contains pre-release code and may not be distributed. |
| 12 |
** You may use this file in accordance with the terms and conditions |
| 13 |
** contained in the Technology Preview License Agreement accompanying |
| 14 |
** this package. |
| 15 |
** |
| 16 |
** GNU Lesser General Public License Usage |
| 17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
| 18 |
** General Public License version 2.1 as published by the Free Software |
| 19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
| 20 |
** packaging of this file. Please review the following information to |
| 21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
| 22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 23 |
** |
| 24 |
** In addition, as a special exception, Nokia gives you certain additional |
| 25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
| 26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 27 |
** |
| 28 |
** If you have questions regarding the use of this file, please contact |
| 29 |
** Nokia at qt-info@nokia.com. |
| 30 |
** |
| 31 |
** |
| 32 |
** |
| 33 |
** |
| 34 |
** |
| 35 |
** |
| 36 |
** |
| 37 |
** |
| 38 |
** $QT_END_LICENSE$ |
| 39 |
** |
| 40 |
****************************************************************************/ |
| 41 |
|
| 42 |
#ifndef QFSFILEENGINE_P_H |
| 43 |
#define QFSFILEENGINE_P_H |
| 44 |
|
| 45 |
// |
| 46 |
// W A R N I N G |
| 47 |
// ------------- |
| 48 |
// |
| 49 |
// This file is not part of the Qt API. It exists purely as an |
| 50 |
// implementation detail. This header file may change from version to |
| 51 |
// version without notice, or even be removed. |
| 52 |
// |
| 53 |
// We mean it. |
| 54 |
// |
| 55 |
|
| 56 |
#include "qplatformdefs.h" |
| 57 |
#include "QtCore/qfsfileengine.h" |
| 58 |
#include "private/qabstractfileengine_p.h" |
| 59 |
#include <qhash.h> |
| 60 |
|
| 61 |
#ifndef QT_NO_FSFILEENGINE |
| 62 |
|
| 63 |
QT_BEGIN_NAMESPACE |
| 64 |
|
| 65 |
#if defined(Q_OS_WINCE_STD) && _WIN32_WCE < 0x600 |
| 66 |
#define Q_USE_DEPRECATED_MAP_API 1 |
| 67 |
#endif |
| 68 |
|
| 69 |
class QFSFileEnginePrivate : public QAbstractFileEnginePrivate |
| 70 |
{ |
| 71 |
Q_DECLARE_PUBLIC(QFSFileEngine) |
| 72 |
|
| 73 |
public: |
| 74 |
#ifdef Q_WS_WIN |
| 75 |
static QByteArray win95Name(const QString &path); |
| 76 |
static QString longFileName(const QString &path); |
| 77 |
#endif |
| 78 |
static QString canonicalized(const QString &path); |
| 79 |
|
| 80 |
QString filePath; |
| 81 |
QByteArray nativeFilePath; |
| 82 |
QIODevice::OpenMode openMode; |
| 83 |
|
| 84 |
void nativeInitFileName(); |
| 85 |
bool nativeOpen(QIODevice::OpenMode openMode); |
| 86 |
bool openFh(QIODevice::OpenMode flags, FILE *fh); |
| 87 |
bool openFd(QIODevice::OpenMode flags, int fd); |
| 88 |
bool nativeClose(); |
| 89 |
bool closeFdFh(); |
| 90 |
bool nativeFlush(); |
| 91 |
bool flushFh(); |
| 92 |
qint64 nativeSize() const; |
| 93 |
qint64 sizeFdFh() const; |
| 94 |
qint64 nativePos() const; |
| 95 |
qint64 posFdFh() const; |
| 96 |
bool nativeSeek(qint64); |
| 97 |
bool seekFdFh(qint64); |
| 98 |
qint64 nativeRead(char *data, qint64 maxlen); |
| 99 |
qint64 readFdFh(char *data, qint64 maxlen); |
| 100 |
qint64 nativeReadLine(char *data, qint64 maxlen); |
| 101 |
qint64 readLineFdFh(char *data, qint64 maxlen); |
| 102 |
qint64 nativeWrite(const char *data, qint64 len); |
| 103 |
qint64 writeFdFh(const char *data, qint64 len); |
| 104 |
int nativeHandle() const; |
| 105 |
bool nativeIsSequential() const; |
| 106 |
bool isSequentialFdFh() const; |
| 107 |
|
| 108 |
uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); |
| 109 |
bool unmap(uchar *ptr); |
| 110 |
|
| 111 |
FILE *fh; |
| 112 |
#ifdef Q_WS_WIN |
| 113 |
HANDLE fileHandle; |
| 114 |
QHash<uchar *, QPair<int /*offset*/, HANDLE /*handle*/> > maps; |
| 115 |
mutable int cachedFd; |
| 116 |
mutable DWORD fileAttrib; |
| 117 |
#else |
| 118 |
QHash<uchar *, QPair<int /*offset*/, int /*handle|len*/> > maps; |
| 119 |
mutable QT_STATBUF st; |
| 120 |
#endif |
| 121 |
int fd; |
| 122 |
|
| 123 |
#ifdef Q_USE_DEPRECATED_MAP_API |
| 124 |
void mapHandleClose(); |
| 125 |
HANDLE fileMapHandle; |
| 126 |
#endif |
| 127 |
|
| 128 |
enum LastIOCommand |
| 129 |
{ |
| 130 |
IOFlushCommand, |
| 131 |
IOReadCommand, |
| 132 |
IOWriteCommand |
| 133 |
}; |
| 134 |
LastIOCommand lastIOCommand; |
| 135 |
bool lastFlushFailed; |
| 136 |
bool closeFileHandle; |
| 137 |
|
| 138 |
mutable uint is_sequential : 2; |
| 139 |
mutable uint could_stat : 1; |
| 140 |
mutable uint tried_stat : 1; |
| 141 |
#ifdef Q_OS_UNIX |
| 142 |
mutable uint need_lstat : 1; |
| 143 |
mutable uint is_link : 1; |
| 144 |
#endif |
| 145 |
bool doStat() const; |
| 146 |
bool isSymlink() const; |
| 147 |
|
| 148 |
#if defined(Q_OS_WIN32) |
| 149 |
int sysOpen(const QString &, int flags); |
| 150 |
#endif |
| 151 |
|
| 152 |
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) |
| 153 |
static void resolveLibs(); |
| 154 |
static bool resolveUNCLibs_NT(); |
| 155 |
static bool resolveUNCLibs_9x(); |
| 156 |
static bool uncListSharesOnServer(const QString &server, QStringList *list); |
| 157 |
#endif |
| 158 |
|
| 159 |
protected: |
| 160 |
QFSFileEnginePrivate(); |
| 161 |
|
| 162 |
void init(); |
| 163 |
|
| 164 |
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) |
| 165 |
QAbstractFileEngine::FileFlags getPermissions() const; |
| 166 |
QString getLink() const; |
| 167 |
#endif |
| 168 |
}; |
| 169 |
|
| 170 |
QT_END_NAMESPACE |
| 171 |
|
| 172 |
#endif // QT_NO_FSFILEENGINE |
| 173 |
|
| 174 |
#endif // QFSFILEENGINE_P_H |