| 344 | } |
| 345 | |
| 346 | void FileSource::clearFileCache() |
| 347 | { |
| 348 | if (!this->isFileOpened) |
| 349 | return; |
| 350 | |
| 351 | #ifdef Q_OS_WIN |
| 352 | // Currently, we only support this on windows. But this is only used in performance testing. |
| 353 | // We will close the QFile, open it using the FILE_FLAG_NO_BUFFERING flags, close it and reopen |
| 354 | // the QFile. Suggested: |
| 355 | // http://stackoverflow.com/questions/478340/clear-file-cache-to-repeat-performance-testing |
| 356 | QMutexLocker locker(&this->readMutex); |
| 357 | this->srcFile.close(); |
| 358 | |
| 359 | LPCWSTR file = (const wchar_t *)this->fullFilePath.utf16(); |
| 360 | HANDLE hFile = |
| 361 | CreateFile(file, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL); |
| 362 | CloseHandle(hFile); |
| 363 | |
| 364 | this->srcFile.setFileName(this->fullFilePath); |
| 365 | this->srcFile.open(QIODevice::ReadOnly); |
| 366 | #endif |
| 367 | } |