summaryrefslogtreecommitdiff
path: root/qmake/tools/qfile.cpp
Unidiff
Diffstat (limited to 'qmake/tools/qfile.cpp') (more/less context) (show whitespace changes)
-rw-r--r--qmake/tools/qfile.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/qmake/tools/qfile.cpp b/qmake/tools/qfile.cpp
index a578b49..c088b55 100644
--- a/qmake/tools/qfile.cpp
+++ b/qmake/tools/qfile.cpp
@@ -79,25 +79,25 @@ extern bool qt_file_access( const QString& fn, int t );
79 at() functions. If you've reached the end of the file, atEnd() 79 at() functions. If you've reached the end of the file, atEnd()
80 returns TRUE. The file handle is returned by handle(). 80 returns TRUE. The file handle is returned by handle().
81 81
82 Here is a code fragment that uses QTextStream to read a text file 82 Here is a code fragment that uses QTextStream to read a text file
83 line by line. It prints each line with a line number. 83 line by line. It prints each line with a line number.
84 \code 84 \code
85 QStringList lines; 85 QStringList lines;
86 QFile file( "file.txt" ); 86 QFile file( "file.txt" );
87 if ( file.open( IO_ReadOnly ) ) { 87 if ( file.open( IO_ReadOnly ) ) {
88 QTextStream stream( &file ); 88 QTextStream stream( &file );
89 QString line; 89 QString line;
90 int i = 1; 90 int i = 1;
91 while ( !stream.eof() ) { 91 while ( !stream.atEnd() ) {
92 line = stream.readLine(); // line of text excluding '\n' 92 line = stream.readLine(); // line of text excluding '\n'
93 printf( "%3d: %s\n", i++, line.latin1() ); 93 printf( "%3d: %s\n", i++, line.latin1() );
94 lines += line; 94 lines += line;
95 } 95 }
96 file.close(); 96 file.close();
97 } 97 }
98 \endcode 98 \endcode
99 99
100 Writing text is just as easy. The following example shows how to 100 Writing text is just as easy. The following example shows how to
101 write the data we read into the string list from the previous 101 write the data we read into the string list from the previous
102 example: 102 example:
103 \code 103 \code
@@ -281,24 +281,25 @@ bool QFile::remove()
281void QFile::flush() 281void QFile::flush()
282{ 282{
283 if ( isOpen() && fh ) // can only flush open/buffered 283 if ( isOpen() && fh ) // can only flush open/buffered
284 fflush( fh ); // file 284 fflush( fh ); // file
285} 285}
286 286
287/*! \reimp 287/*! \reimp
288 \fn QIODevice::Offset QFile::at() const 288 \fn QIODevice::Offset QFile::at() const
289*/ 289*/
290 290
291/*! 291/*!
292 Returns TRUE if the end of file has been reached; otherwise returns FALSE. 292 Returns TRUE if the end of file has been reached; otherwise returns FALSE.
293 If QFile has not been open()'d, then the behavior is undefined.
293 294
294 \sa size() 295 \sa size()
295*/ 296*/
296 297
297bool QFile::atEnd() const 298bool QFile::atEnd() const
298{ 299{
299 if ( !isOpen() ) { 300 if ( !isOpen() ) {
300#if defined(QT_CHECK_STATE) 301#if defined(QT_CHECK_STATE)
301 qWarning( "QFile::atEnd: File is not open" ); 302 qWarning( "QFile::atEnd: File is not open" );
302#endif 303#endif
303 return FALSE; 304 return FALSE;
304 } 305 }