/* \internal */ qint64 QFSFileEnginePrivate::nativeSize() const { Q_Q(const QFSFileEngine); QFSFileEngine *thatQ = const_cast<QFSFileEngine *>(q); // ### Don't flush; for buffered files, we should get away with ftell. thatQ->flush(); // Always retrive the current information metaData.clearFlags(QFileSystemMetaData::SizeAttribute); #if defined(Q_OS_WINCE) // Buffered stdlib mode. if (fh) { QT_OFF_T oldPos = QT_FTELL(fh); QT_FSEEK(fh, 0, SEEK_END); qint64 fileSize = (qint64)QT_FTELL(fh); QT_FSEEK(fh, oldPos, SEEK_SET); if (fileSize == -1) { fileSize = 0; thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno)); } return fileSize; } if (fd != -1) { thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); return 0; } #endif bool filled = false; if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen ) filled = QFileSystemEngine::fillMetaData(fileHandle, metaData, QFileSystemMetaData::SizeAttribute); else filled = doStat(QFileSystemMetaData::SizeAttribute); if (!filled) { thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno)); return 0; } return metaData.size(); }
/* \internal */ qint64 QFSFileEnginePrivate::nativePos() const { Q_Q(const QFSFileEngine); QFSFileEngine *thatQ = const_cast<QFSFileEngine *>(q); if (fh || fd != -1) { // stdlib / stido mode. return posFdFh(); } // Windows native mode. if (fileHandle == INVALID_HANDLE_VALUE) return 0; #if !defined(Q_OS_WINCE) LARGE_INTEGER currentFilePos; LARGE_INTEGER offset; offset.QuadPart = 0; if (!::SetFilePointerEx(fileHandle, offset, ¤tFilePos, FILE_CURRENT)) { thatQ->setError(QFile::UnspecifiedError, qt_error_string()); return 0; } return qint64(currentFilePos.QuadPart); #else LARGE_INTEGER filepos; filepos.HighPart = 0; DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT); if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { thatQ->setError(QFile::UnspecifiedError, qt_error_string()); return 0; } filepos.LowPart = newFilePointer; return filepos.QuadPart; #endif }