-rw-r--r-- | qmake/tools/qfile_unix.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/qmake/tools/qfile_unix.cpp b/qmake/tools/qfile_unix.cpp index 2d5a856..460bf06 100644 --- a/qmake/tools/qfile_unix.cpp +++ b/qmake/tools/qfile_unix.cpp | |||
@@ -432,17 +432,20 @@ bool QFile::open( int m, int f ) | |||
432 | \sa at() | 432 | \sa at() |
433 | */ | 433 | */ |
434 | 434 | ||
435 | QIODevice::Offset QFile::size() const | 435 | QIODevice::Offset QFile::size() const |
436 | { | 436 | { |
437 | struct stat st; | 437 | struct stat st; |
438 | int ret = 0; | ||
438 | if ( isOpen() ) { | 439 | if ( isOpen() ) { |
439 | ::fstat( fh ? fileno(fh) : fd, &st ); | 440 | ret = ::fstat( fh ? fileno(fh) : fd, &st ); |
440 | } else { | 441 | } else { |
441 | ::stat( QFile::encodeName(fn), &st ); | 442 | ret = ::stat( QFile::encodeName(fn), &st ); |
442 | } | 443 | } |
444 | if ( ret == -1 ) | ||
445 | return 0; | ||
443 | #if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_64BITOFFSET) | 446 | #if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_64BITOFFSET) |
444 | return (uint)st.st_size > UINT_MAX ? UINT_MAX : (QIODevice::Offset)st.st_size; | 447 | return (uint)st.st_size > UINT_MAX ? UINT_MAX : (QIODevice::Offset)st.st_size; |
445 | #else | 448 | #else |
446 | return st.st_size; | 449 | return st.st_size; |
447 | #endif | 450 | #endif |
448 | } | 451 | } |
@@ -535,13 +538,13 @@ Q_LONG QFile::readBlock( char *p, Q_ULONG len ) | |||
535 | #endif | 538 | #endif |
536 | Q_ULONG nread = 0; // number of bytes read | 539 | Q_ULONG nread = 0; // number of bytes read |
537 | if ( !ungetchBuffer.isEmpty() ) { | 540 | if ( !ungetchBuffer.isEmpty() ) { |
538 | // need to add these to the returned string. | 541 | // need to add these to the returned string. |
539 | uint l = ungetchBuffer.length(); | 542 | uint l = ungetchBuffer.length(); |
540 | while( nread < l ) { | 543 | while( nread < l ) { |
541 | *p = ungetchBuffer[ l - nread - 1 ]; | 544 | *p = ungetchBuffer.at( l - nread - 1 ); |
542 | p++; | 545 | p++; |
543 | nread++; | 546 | nread++; |
544 | } | 547 | } |
545 | ungetchBuffer.truncate( l - nread ); | 548 | ungetchBuffer.truncate( l - nread ); |
546 | } | 549 | } |
547 | 550 | ||
@@ -626,13 +629,15 @@ Q_LONG QFile::writeBlock( const char *p, Q_ULONG len ) | |||
626 | } | 629 | } |
627 | 630 | ||
628 | /*! | 631 | /*! |
629 | Returns the file handle of the file. | 632 | Returns the file handle of the file. |
630 | 633 | ||
631 | This is a small positive integer, suitable for use with C library | 634 | This is a small positive integer, suitable for use with C library |
632 | functions such as fdopen() and fcntl(), as well as with QSocketNotifier. | 635 | functions such as fdopen() and fcntl(). On systems that use file |
636 | descriptors for sockets (ie. Unix systems, but not Windows) the handle | ||
637 | can be used with QSocketNotifier as well. | ||
633 | 638 | ||
634 | If the file is not open or there is an error, handle() returns -1. | 639 | If the file is not open or there is an error, handle() returns -1. |
635 | 640 | ||
636 | \sa QSocketNotifier | 641 | \sa QSocketNotifier |
637 | */ | 642 | */ |
638 | 643 | ||