summaryrefslogtreecommitdiff
path: root/qmake/tools/qfile.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qfile.cpp') (more/less context) (ignore 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 );
at() functions. If you've reached the end of the file, atEnd()
returns TRUE. The file handle is returned by handle().
Here is a code fragment that uses QTextStream to read a text file
line by line. It prints each line with a line number.
\code
QStringList lines;
QFile file( "file.txt" );
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
QString line;
int i = 1;
- while ( !stream.eof() ) {
+ while ( !stream.atEnd() ) {
line = stream.readLine(); // line of text excluding '\n'
printf( "%3d: %s\n", i++, line.latin1() );
lines += line;
}
file.close();
}
\endcode
Writing text is just as easy. The following example shows how to
write the data we read into the string list from the previous
example:
\code
@@ -281,24 +281,25 @@ bool QFile::remove()
void QFile::flush()
{
if ( isOpen() && fh ) // can only flush open/buffered
fflush( fh ); // file
}
/*! \reimp
\fn QIODevice::Offset QFile::at() const
*/
/*!
Returns TRUE if the end of file has been reached; otherwise returns FALSE.
+ If QFile has not been open()'d, then the behavior is undefined.
\sa size()
*/
bool QFile::atEnd() const
{
if ( !isOpen() ) {
#if defined(QT_CHECK_STATE)
qWarning( "QFile::atEnd: File is not open" );
#endif
return FALSE;
}