Qt 4.8
Protected Functions | Protected Variables | Static Private Attributes | List of all members
QFilePrivate Class Reference

#include <qfile_p.h>

Inheritance diagram for QFilePrivate:
QIODevicePrivate QObjectPrivate QObjectData QTemporaryFilePrivate

Protected Functions

bool ensureFlushed () const
 
bool openExternalFile (int flags, int fd, QFile::FileHandleFlags handleFlags)
 
bool openExternalFile (int flags, FILE *fh, QFile::FileHandleFlags handleFlags)
 
bool putCharHelper (char c)
 
 QFilePrivate ()
 
void setError (QFile::FileError err)
 
void setError (QFile::FileError err, const QString &errorString)
 
void setError (QFile::FileError err, int errNum)
 
 ~QFilePrivate ()
 

Protected Variables

qint64 cachedSize
 
QFile::FileError error
 
QAbstractFileEnginefileEngine
 
QString fileName
 
bool lastWasWrite
 
QRingBuffer writeBuffer
 

Static Private Attributes

static QFile::DecoderFn decoder = locale_decode
 
static QFile::EncoderFn encoder = locale_encode
 

Additional Inherited Members

- Public Types inherited from QIODevicePrivate
enum  AccessMode { Unset, Sequential, RandomAccess }
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Public Functions inherited from QIODevicePrivate
bool isSequential () const
 
virtual qint64 peek (char *data, qint64 maxSize)
 
virtual QByteArray peek (qint64 maxSize)
 
 QIODevicePrivate ()
 
virtual ~QIODevicePrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Public Variables inherited from QIODevicePrivate
AccessMode accessMode
 
bool baseReadLineDataCalled
 
QIODevicePrivateLinearBuffer buffer
 
qint64 devicePos
 
QString errorString
 
bool firstRead
 
QIODevice::OpenMode openMode
 
qint64pDevicePos
 
qint64 pos
 
qint64pPos
 
qint64 seqDumpPos
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Detailed Description

Definition at line 62 of file qfile_p.h.

Constructors and Destructors

◆ QFilePrivate()

QFilePrivate::QFilePrivate ( )
protected

Definition at line 92 of file qfile.cpp.

93  : fileEngine(0), lastWasWrite(false),
95  cachedSize(0)
96 {
97 }
QFile::FileError error
Definition: qfile_p.h:85
QRingBuffer writeBuffer
Definition: qfile_p.h:80
QAbstractFileEngine * fileEngine
Definition: qfile_p.h:77
static const int QFILE_WRITEBUFFER_SIZE
Definition: qfile.cpp:62
bool lastWasWrite
Definition: qfile_p.h:79
qint64 cachedSize
Definition: qfile_p.h:90

◆ ~QFilePrivate()

QFilePrivate::~QFilePrivate ( )
protected

Definition at line 99 of file qfile.cpp.

100 {
101  delete fileEngine;
102  fileEngine = 0;
103 }
QAbstractFileEngine * fileEngine
Definition: qfile_p.h:77

Functions

◆ ensureFlushed()

bool QFilePrivate::ensureFlushed ( ) const
inlineprotected

Definition at line 154 of file qfile.cpp.

155 {
156  // This function ensures that the write buffer has been flushed (const
157  // because certain const functions need to call it.
158  if (lastWasWrite) {
159  const_cast<QFilePrivate *>(this)->lastWasWrite = false;
160  if (!const_cast<QFile *>(q_func())->flush())
161  return false;
162  }
163  return true;
164 }
bool lastWasWrite
Definition: qfile_p.h:79

◆ openExternalFile() [1/2]

bool QFilePrivate::openExternalFile ( int  flags,
int  fd,
QFile::FileHandleFlags  handleFlags 
)
protected

Definition at line 106 of file qfile.cpp.

Referenced by openExternalFile().

107 {
108 #ifdef QT_NO_FSFILEENGINE
109  Q_UNUSED(flags);
110  Q_UNUSED(fd);
111  return false;
112 #else
113  delete fileEngine;
114  fileEngine = 0;
115  QFSFileEngine *fe = new QFSFileEngine;
116  fileEngine = fe;
117  return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
118 #endif
119 }
QAbstractFileEngine * fileEngine
Definition: qfile_p.h:77
bool open(QIODevice::OpenMode openMode)
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ openExternalFile() [2/2]

bool QFilePrivate::openExternalFile ( int  flags,
FILE *  fh,
QFile::FileHandleFlags  handleFlags 
)
protected

Definition at line 122 of file qfile.cpp.

123 {
124 #ifdef QT_NO_FSFILEENGINE
125  Q_UNUSED(flags);
126  Q_UNUSED(fh);
127  return false;
128 #else
129  delete fileEngine;
130  fileEngine = 0;
131  QFSFileEngine *fe = new QFSFileEngine;
132  fileEngine = fe;
133  return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
134 #endif
135 }
QAbstractFileEngine * fileEngine
Definition: qfile_p.h:77
bool open(QIODevice::OpenMode openMode)
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ putCharHelper()

bool QFilePrivate::putCharHelper ( char  c)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QIODevicePrivate.

Definition at line 1865 of file qfile.cpp.

1866 {
1867 #ifdef QT_NO_QOBJECT
1869 #else
1870 
1871  // Cutoff for code that doesn't only touch the buffer.
1872  int writeBufferSize = writeBuffer.size();
1873  if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE
1874 #ifdef Q_OS_WIN
1875  || ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE)
1876 #endif
1877  ) {
1879  }
1880 
1881  if (!(openMode & QIODevice::WriteOnly)) {
1883  qWarning("QIODevice::putChar: Closed device");
1884  else
1885  qWarning("QIODevice::putChar: ReadOnly device");
1886  return false;
1887  }
1888 
1889  // Make sure the device is positioned correctly.
1890  const bool sequential = isSequential();
1891  if (pos != devicePos && !sequential && !q_func()->seek(pos))
1892  return false;
1893 
1894  lastWasWrite = true;
1895 
1896  int len = 1;
1897 #ifdef Q_OS_WIN
1898  if ((openMode & QIODevice::Text) && c == '\n') {
1899  ++len;
1900  *writeBuffer.reserve(1) = '\r';
1901  }
1902 #endif
1903 
1904  // Write to buffer.
1905  *writeBuffer.reserve(1) = c;
1906 
1907  if (!sequential) {
1908  pos += len;
1909  devicePos += len;
1910  if (!buffer.isEmpty())
1911  buffer.skip(len);
1912  }
1913 
1914  return true;
1915 #endif
1916 }
unsigned char c[8]
Definition: qnumeric_p.h:62
QIODevice::OpenMode openMode
Definition: qiodevice_p.h:212
QIODevicePrivateLinearBuffer buffer
Definition: qiodevice_p.h:215
QRingBuffer writeBuffer
Definition: qfile_p.h:80
char * reserve(int bytes)
virtual bool putCharHelper(char c)
Definition: qiodevice.cpp:1494
Q_CORE_EXPORT void qWarning(const char *,...)
static const int QFILE_WRITEBUFFER_SIZE
Definition: qfile.cpp:62
bool lastWasWrite
Definition: qfile_p.h:79
bool isSequential() const
Definition: qiodevice_p.h:233
#define Q_OS_WIN
Definition: qglobal.h:270
int size() const

◆ setError() [1/3]

void QFilePrivate::setError ( QFile::FileError  err)
protected

Definition at line 167 of file qfile.cpp.

168 {
169  error = err;
170  errorString.clear();
171 }
QFile::FileError error
Definition: qfile_p.h:85
QString errorString
Definition: qiodevice_p.h:213
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723

◆ setError() [2/3]

void QFilePrivate::setError ( QFile::FileError  err,
const QString errorString 
)
protected

Definition at line 174 of file qfile.cpp.

175 {
176  error = err;
177  errorString = errStr;
178 }
QFile::FileError error
Definition: qfile_p.h:85

◆ setError() [3/3]

void QFilePrivate::setError ( QFile::FileError  err,
int  errNum 
)
protected

Definition at line 181 of file qfile.cpp.

182 {
183  error = err;
184  errorString = qt_error_string(errNum);
185 }
QString qt_error_string(int errorCode)
Definition: qglobal.cpp:2600
QFile::FileError error
Definition: qfile_p.h:85
QString errorString
Definition: qiodevice_p.h:213

Properties

◆ cachedSize

qint64 QFilePrivate::cachedSize
mutableprotected

Definition at line 90 of file qfile_p.h.

◆ decoder

QFile::DecoderFn QFilePrivate::decoder = locale_decode
staticprivate

Definition at line 94 of file qfile_p.h.

Referenced by QFile::decodeName(), locale_decode(), and QFile::setDecodingFunction().

◆ encoder

QFile::EncoderFn QFilePrivate::encoder = locale_encode
staticprivate

Definition at line 93 of file qfile_p.h.

Referenced by QFile::encodeName(), locale_decode(), and QFile::setEncodingFunction().

◆ error

QFile::FileError QFilePrivate::error
protected

Definition at line 85 of file qfile_p.h.

Referenced by setError().

◆ fileEngine

QAbstractFileEngine* QFilePrivate::fileEngine
mutableprotected

Definition at line 77 of file qfile_p.h.

Referenced by openExternalFile(), and ~QFilePrivate().

◆ fileName

QString QFilePrivate::fileName
protected

Definition at line 76 of file qfile_p.h.

◆ lastWasWrite

bool QFilePrivate::lastWasWrite
protected

Definition at line 79 of file qfile_p.h.

Referenced by ensureFlushed().

◆ writeBuffer

QRingBuffer QFilePrivate::writeBuffer
protected

Definition at line 80 of file qfile_p.h.


The documentation for this class was generated from the following files: