| 215 | } |
| 216 | |
| 217 | QString FileSearchUtils::readFileContent(const QString &filePath) |
| 218 | { |
| 219 | QFile file(filePath); |
| 220 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 221 | return QString(); |
| 222 | } |
| 223 | |
| 224 | QString canonicalPath = QFileInfo(filePath).canonicalFilePath(); |
| 225 | bool isInProject = Context::ProjectUtils::isFileInProject(canonicalPath); |
| 226 | |
| 227 | if (!isInProject) { |
| 228 | const auto &settings = Settings::toolsSettings(); |
| 229 | if (!settings.allowAccessOutsideProject()) { |
| 230 | LOG_MESSAGE(QString("Access denied to file outside project: %1").arg(canonicalPath)); |
| 231 | return QString(); |
| 232 | } |
| 233 | LOG_MESSAGE(QString("Reading file outside project scope: %1").arg(canonicalPath)); |
| 234 | } |
| 235 | |
| 236 | QTextStream stream(&file); |
| 237 | stream.setAutoDetectUnicode(true); |
| 238 | QString content = stream.readAll(); |
| 239 | |
| 240 | return content; |
| 241 | } |
| 242 | |
| 243 | } // namespace QodeAssist::Tools |
nothing calls this directly
no outgoing calls
no test coverage detected