| 57 | } |
| 58 | |
| 59 | bool FileSource::openFile(const QString &filePath) |
| 60 | { |
| 61 | // Check if the file exists |
| 62 | this->fileInfo.setFile(filePath); |
| 63 | if (!this->fileInfo.exists() || !this->fileInfo.isFile()) |
| 64 | return false; |
| 65 | |
| 66 | if (this->isFileOpened && this->srcFile.isOpen()) |
| 67 | this->srcFile.close(); |
| 68 | |
| 69 | // open file for reading |
| 70 | this->srcFile.setFileName(filePath); |
| 71 | this->isFileOpened = this->srcFile.open(QIODevice::ReadOnly); |
| 72 | if (!this->isFileOpened) |
| 73 | return false; |
| 74 | |
| 75 | // Save the full file path |
| 76 | this->fullFilePath = filePath; |
| 77 | |
| 78 | // Install a watcher for the file (if file watching is active) |
| 79 | this->updateFileWatchSetting(); |
| 80 | this->fileChanged = false; |
| 81 | |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | #if SSE_CONVERSION |
| 86 | // Resize the target array if necessary and read the given number of bytes to the data array |