79 return !(fileName.startsWith(QLatin1Char('/')) |
79 return !(fileName.startsWith(QLatin1Char('/')) |
80 || (fileName.length() >= 2 |
80 || (fileName.length() >= 2 |
81 && ((fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) |
81 && ((fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) |
82 || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/'))))); |
82 || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/'))))); |
83 } |
83 } |
|
84 |
|
85 /*! |
|
86 \internal |
|
87 convert symbian error code to the one suitable for setError. |
|
88 example usage: setSymbianError(err, QFile::CopyError, QLatin1String("copy error")) |
|
89 */ |
|
90 void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString) |
|
91 { |
|
92 Q_Q(QFSFileEngine); |
|
93 switch (symbianError) { |
|
94 case KErrNone: |
|
95 q->setError(QFile::NoError, QLatin1String("")); |
|
96 break; |
|
97 case KErrAccessDenied: |
|
98 q->setError(QFile::PermissionsError, QLatin1String("access denied")); |
|
99 break; |
|
100 case KErrPermissionDenied: |
|
101 q->setError(QFile::PermissionsError, QLatin1String("permission denied")); |
|
102 break; |
|
103 case KErrAbort: |
|
104 q->setError(QFile::AbortError, QLatin1String("aborted")); |
|
105 break; |
|
106 case KErrCancel: |
|
107 q->setError(QFile::AbortError, QLatin1String("cancelled")); |
|
108 break; |
|
109 case KErrTimedOut: |
|
110 q->setError(QFile::TimeOutError, QLatin1String("timed out")); |
|
111 break; |
|
112 default: |
|
113 q->setError(defaultError, defaultString); |
|
114 break; |
|
115 } |
|
116 } |
|
117 |
84 #endif |
118 #endif |
85 |
119 |
86 /*! |
120 /*! |
87 \internal |
121 \internal |
88 |
122 |
425 err = fm->Copy(rfile, newPtr); |
459 err = fm->Copy(rfile, newPtr); |
426 rfile.Close(); |
460 rfile.Close(); |
427 } |
461 } |
428 ) // End TRAP |
462 ) // End TRAP |
429 delete fm; |
463 delete fm; |
430 // ### Add error reporting on failure |
464 if (err == KErrNone) |
431 return (err == KErrNone); |
465 return true; |
|
466 d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error")); |
|
467 return false; |
432 #else |
468 #else |
433 Q_UNUSED(newName); |
469 Q_UNUSED(newName); |
434 // ### Add copy code for Unix here |
470 // ### Add copy code for Unix here |
435 setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); |
471 setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); |
436 return false; |
472 return false; |
666 if (fh && nativeFilePath.isEmpty()) { |
704 if (fh && nativeFilePath.isEmpty()) { |
667 // ### actually covers two cases: d->fh and when the file is not open |
705 // ### actually covers two cases: d->fh and when the file is not open |
668 could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); |
706 could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); |
669 } else if (fd == -1) { |
707 } else if (fd == -1) { |
670 // ### actually covers two cases: d->fh and when the file is not open |
708 // ### actually covers two cases: d->fh and when the file is not open |
|
709 #if defined(Q_OS_SYMBIAN) |
|
710 // Optimisation for Symbian where fileFlags() calls both doStat() and isSymlink(), but rarely on real links. |
|
711 // When the filename is not a link, lstat will return the same info as stat, but this also removes |
|
712 // any need for a further call to lstat to check if the file is a link. |
|
713 need_lstat = false; |
|
714 could_stat = (QT_LSTAT(nativeFilePath.constData(), &st) == 0); |
|
715 is_link = could_stat ? S_ISLNK(st.st_mode) : false; |
|
716 // if it turns out this was a link, we can call stat too. |
|
717 if (is_link) |
|
718 #endif |
671 could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); |
719 could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); |
672 } else { |
720 } else { |
673 could_stat = (QT_FSTAT(fd, &st) == 0); |
721 could_stat = (QT_FSTAT(fd, &st) == 0); |
674 } |
722 } |
675 } |
723 } |
1268 if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; |
1316 if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; |
1269 |
1317 |
1270 int pageSize = getpagesize(); |
1318 int pageSize = getpagesize(); |
1271 int extra = offset % pageSize; |
1319 int extra = offset % pageSize; |
1272 |
1320 |
1273 if (size + extra > (size_t)-1) { |
1321 if (quint64(size + extra) > quint64((size_t)-1)) { |
1274 q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); |
1322 q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); |
1275 return 0; |
1323 return 0; |
1276 } |
1324 } |
1277 |
1325 |
1278 size_t realSize = (size_t)size + extra; |
1326 size_t realSize = (size_t)size + extra; |