Add `seek` method to `File` class

This method is necessary for random-access streams.  It will also be
helpful in the future when implementing the [IO/A spec][1].

[1]: http://wiki.commonjs.org/wiki/IO/A#Instance_Methods

http://code.google.com/p/phantomjs/issues/detail?id=937
1.9
execjosh 2012-12-18 09:48:09 +09:00 committed by Ariya Hidayat
parent f6c87221a7
commit 6bc3a93118
2 changed files with 11 additions and 0 deletions

View File

@ -110,6 +110,15 @@ bool File::write(const QString &data)
}
}
bool File::seek(const qint64 pos)
{
if (m_fileStream) {
return m_fileStream->seek(pos);
} else {
return m_file->seek(pos);
}
}
QString File::readLine()
{
if ( !m_file->isReadable() ) {

View File

@ -52,6 +52,8 @@ public slots:
QString read();
bool write(const QString &data);
bool seek(const qint64 pos);
QString readLine();
bool writeLine(const QString &data);