forked from qt-creator/qt-creator
Utils: Allow an offset in FilePath::readContents()
Also, change the size limit to take a qint64. Contrary to e.g. Q(6)Hash::size() there is a realistic chance that 31 bits are not enough. Change-Id: Idbe6e765a5cac4336b3d64a8e0adb14966fd18a3 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -967,11 +967,11 @@ QList<FilePath> FilePath::dirEntries(QDir::Filters filters) const
|
||||
return dirEntries({}, filters);
|
||||
}
|
||||
|
||||
QByteArray FilePath::fileContents(int maxSize) const
|
||||
QByteArray FilePath::fileContents(qint64 maxSize, qint64 offset) const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
QTC_ASSERT(s_deviceHooks.fileContents, return {});
|
||||
return s_deviceHooks.fileContents(*this, maxSize);
|
||||
return s_deviceHooks.fileContents(*this, maxSize, offset);
|
||||
}
|
||||
|
||||
const QString path = toString();
|
||||
@@ -982,6 +982,9 @@ QByteArray FilePath::fileContents(int maxSize) const
|
||||
if (!f.open(QFile::ReadOnly))
|
||||
return {};
|
||||
|
||||
if (offset != 0)
|
||||
f.seek(offset);
|
||||
|
||||
if (maxSize != -1)
|
||||
return f.read(maxSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user