| 783 | } |
| 784 | |
| 785 | bool FileAccess::interruptableReadFile(void* pDestBuffer, qint64 maxLength) |
| 786 | { |
| 787 | ProgressScope pp; |
| 788 | const qint64 maxChunkSize = 100000; |
| 789 | qint64 i = 0; |
| 790 | ProgressProxy::setMaxNofSteps(maxLength / maxChunkSize + 1); |
| 791 | |
| 792 | setStatusText(""); |
| 793 | |
| 794 | while(i < maxLength) |
| 795 | { |
| 796 | qint64 nextLength = std::min(maxLength - i, maxChunkSize); |
| 797 | qint64 reallyRead = read((char*)pDestBuffer + i, nextLength); |
| 798 | if(reallyRead != nextLength) |
| 799 | { |
| 800 | setStatusText(i18n("Failed to read file: %1", absoluteFilePath())); |
| 801 | return false; |
| 802 | } |
| 803 | i += reallyRead; |
| 804 | |
| 805 | ProgressProxy::setCurrent(std::floor(i / maxLength * 100)); |
| 806 | if(ProgressProxy::wasCancelled()) |
| 807 | return false; |
| 808 | } |
| 809 | return true; |
| 810 | } |
| 811 | |
| 812 | bool FileAccess::readFile(void* pDestBuffer, qint64 maxLength) |
| 813 | { |
nothing calls this directly
no test coverage detected