diff options
author | hjk <[email protected]> | 2021-07-09 08:30:11 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-07-09 12:48:37 +0000 |
commit | 97578a4feec5c37680d18bb0426d3234fc0f2a29 (patch) | |
tree | 5d5c1babfef99c4cf781f78e5fd7b8404c52d85d /src/libs/utils/fileutils.cpp | |
parent | dba0294b3393097d2439d5b09be734e8ec4bf484 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 87ffc501492..95e935272c3 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -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); |