void CtrlrFileDownloader::run() { ScopedPointer <InputStream> is (fileToDownload.createInputStream (false)); const int totalLength = is->getTotalLength(); int bytesSoFar = 0; const String packageFile = CtrlrUpdateManager::getMyPackage(); if (outputFile.exists()) { outputFile.deleteFile(); outputFile.create(); } while (! (is->isExhausted())) { if (threadShouldExit()) { return; } MemoryBlock buffer(8192); const int num = is->read (buffer.getData(), 8192); if (num == 0) break; bytesSoFar += num; outputFile.appendData(buffer.getData(), buffer.getSize()); setStatusMessage ("File: " + packageFile + "\nTotal size: " + File::descriptionOfSizeInBytes (totalLength) + " Got size: " + File::descriptionOfSizeInBytes (bytesSoFar)); setProgress (bytesSoFar / (double)totalLength); } }