author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/tools/qfile_unix.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
-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 | |||
@@ -422,37 +422,40 @@ bool QFile::open( int m, int f ) | |||
422 | ioIndex = 0; | 422 | ioIndex = 0; |
423 | } | 423 | } |
424 | resetStatus(); | 424 | resetStatus(); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | return TRUE; | 427 | return TRUE; |
428 | } | 428 | } |
429 | 429 | ||
430 | /*! | 430 | /*! |
431 | Returns the file size. | 431 | Returns the file size. |
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 | } |
449 | 452 | ||
450 | 453 | ||
451 | /*! | 454 | /*! |
452 | \overload | 455 | \overload |
453 | 456 | ||
454 | Sets the file index to \a pos. Returns TRUE if successful; | 457 | Sets the file index to \a pos. Returns TRUE if successful; |
455 | otherwise returns FALSE. | 458 | otherwise returns FALSE. |
456 | 459 | ||
457 | Example: | 460 | Example: |
458 | \code | 461 | \code |
@@ -525,33 +528,33 @@ Q_LONG QFile::readBlock( char *p, Q_ULONG len ) | |||
525 | #endif | 528 | #endif |
526 | #if defined(QT_CHECK_STATE) | 529 | #if defined(QT_CHECK_STATE) |
527 | if ( !isOpen() ) { | 530 | if ( !isOpen() ) { |
528 | qWarning( "QFile::readBlock: File not open" ); | 531 | qWarning( "QFile::readBlock: File not open" ); |
529 | return -1; | 532 | return -1; |
530 | } | 533 | } |
531 | if ( !isReadable() ) { | 534 | if ( !isReadable() ) { |
532 | qWarning( "QFile::readBlock: Read operation not permitted" ); | 535 | qWarning( "QFile::readBlock: Read operation not permitted" ); |
533 | return -1; | 536 | return -1; |
534 | } | 537 | } |
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 | ||
548 | if ( nread < len ) { | 551 | if ( nread < len ) { |
549 | if ( isRaw() ) { // raw file | 552 | if ( isRaw() ) { // raw file |
550 | nread += ::read( fd, p, len-nread ); | 553 | nread += ::read( fd, p, len-nread ); |
551 | if ( len && nread <= 0 ) { | 554 | if ( len && nread <= 0 ) { |
552 | nread = 0; | 555 | nread = 0; |
553 | setStatus(IO_ReadError); | 556 | setStatus(IO_ReadError); |
554 | } | 557 | } |
555 | } else { // buffered file | 558 | } else { // buffered file |
556 | nread += fread( p, 1, len-nread, fh ); | 559 | nread += fread( p, 1, len-nread, fh ); |
557 | if ( (uint)nread != len ) { | 560 | if ( (uint)nread != len ) { |
@@ -616,33 +619,35 @@ Q_LONG QFile::writeBlock( const char *p, Q_ULONG len ) | |||
616 | ioIndex = (Offset)::fseek( fh, 0, SEEK_CUR ); | 619 | ioIndex = (Offset)::fseek( fh, 0, SEEK_CUR ); |
617 | #endif | 620 | #endif |
618 | } | 621 | } |
619 | } else { | 622 | } else { |
620 | if ( !isSequentialAccess() ) | 623 | if ( !isSequentialAccess() ) |
621 | ioIndex += nwritten; | 624 | ioIndex += nwritten; |
622 | } | 625 | } |
623 | if ( ioIndex > length ) // update file length | 626 | if ( ioIndex > length ) // update file length |
624 | length = ioIndex; | 627 | length = ioIndex; |
625 | return nwritten; | 628 | return nwritten; |
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 | ||
639 | int QFile::handle() const | 644 | int QFile::handle() const |
640 | { | 645 | { |
641 | if ( !isOpen() ) | 646 | if ( !isOpen() ) |
642 | return -1; | 647 | return -1; |
643 | else if ( fh ) | 648 | else if ( fh ) |
644 | return fileno( fh ); | 649 | return fileno( fh ); |
645 | else | 650 | else |
646 | return fd; | 651 | return fd; |
647 | } | 652 | } |
648 | 653 | ||