MCPcopy Create free account
hub / github.com/KDE/kdiff3 / interruptableReadFile

Method interruptableReadFile

src/fileaccess.cpp:785–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783}
784
785bool 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
812bool FileAccess::readFile(void* pDestBuffer, qint64 maxLength)
813{

Callers

nothing calls this directly

Calls 2

readFunction · 0.85
setCurrentFunction · 0.85

Tested by

no test coverage detected