/*! \internal */ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) { #ifdef Q_OS_SYMBIAN Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { if(len > KMaxTInt) { //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..) q->setError(QFile::WriteError, QLatin1String("Maximum 2GB in single write on this platform")); return -1; } const TPtrC8 ptr(reinterpret_cast<const TUint8*>(data), static_cast<TInt>(len)); #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API TInt64 eofpos = 0; #else TInt eofpos = 0; #endif //The end of file position is not cached because QFile is read/write sharable, therefore another //process may have altered the file size. TInt r = symbianFile.Seek(ESeekEnd, eofpos); if (r == KErrNone && symbianFilePos > eofpos) { //seek position is beyond end of file so file needs to be extended before write. //note that SetSize does not zero-initialise (c.f. posix lseek) r = symbianFile.SetSize(symbianFilePos); } if (r == KErrNone) { //write to specific position in the file (i.e. use our own cursor rather than calling seek) r = symbianFile.Write(symbianFilePos, ptr); } if (r != KErrNone) { q->setError(QFile::WriteError, QSystemError(r, QSystemError::NativeError).toString()); return -1; } symbianFilePos += len; return len; } #endif return writeFdFh(data, len); }
/* \internal */ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) { Q_Q(QFSFileEngine); if (fh || fd != -1) { // stdio / stdlib mode. return writeFdFh(data, len); } // Windows native mode. if (fileHandle == INVALID_HANDLE_VALUE) return -1; qint64 bytesToWrite = len; // Writing on Windows fails with ERROR_NO_SYSTEM_RESOURCES when // the chunks are too large, so we limit the block size to 32MB. const DWORD blockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024))); qint64 totalWritten = 0; do { DWORD bytesWritten; if (!WriteFile(fileHandle, data + totalWritten, blockSize, &bytesWritten, NULL)) { if (totalWritten == 0) { // Note: Only return error if the first WriteFile failed. q->setError(QFile::WriteError, qt_error_string()); return -1; } break; } if (bytesWritten == 0) break; totalWritten += bytesWritten; bytesToWrite -= bytesWritten; } while (totalWritten < len); return qint64(totalWritten); }
/*! \internal */ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) { return writeFdFh(data, len); }