| 218 | } |
| 219 | |
| 220 | bool initProjectFiles() |
| 221 | { |
| 222 | KIO::StatJob* statJob = KIO::stat( projectFile.toUrl(), KIO::HideProgressInfo ); |
| 223 | if ( !statJob->exec() ) //be sync for right now |
| 224 | { |
| 225 | const QString messageText = |
| 226 | i18n("Unable to load the project file %1.<br>" |
| 227 | "The project has been removed from the session.", |
| 228 | projectFile.pathOrUrl()); |
| 229 | auto* message = new Sublime::Message(messageText, Sublime::Message::Error); |
| 230 | ICore::self()->uiController()->postMessage(message); |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | // developerfile == dirname(projectFileUrl) ."/.kdev4/". basename(projectfileUrl) |
| 235 | developerFile = projectFile; |
| 236 | developerFile.setLastPathSegment( QStringLiteral(".kdev4") ); |
| 237 | developerFile.addPath( projectFile.lastPathSegment() ); |
| 238 | |
| 239 | statJob = KIO::stat( developerFile.toUrl(), KIO::HideProgressInfo ); |
| 240 | if( !statJob->exec() ) |
| 241 | { |
| 242 | // the developerfile does not exist yet, check if its folder exists |
| 243 | // the developerfile itself will get created below |
| 244 | QUrl dir = developerFile.parent().toUrl(); |
| 245 | statJob = KIO::stat( dir, KIO::HideProgressInfo ); |
| 246 | if( !statJob->exec() ) |
| 247 | { |
| 248 | KIO::SimpleJob* mkdirJob = KIO::mkdir( dir ); |
| 249 | if( !mkdirJob->exec() ) |
| 250 | { |
| 251 | const QString messageText = |
| 252 | i18n("Unable to create hidden dir (%1) for developer file", |
| 253 | dir.toDisplayString(QUrl::PreferLocalFile)); |
| 254 | auto* message = new Sublime::Message(messageText, Sublime::Message::Error); |
| 255 | ICore::self()->uiController()->postMessage(message); |
| 256 | return false; |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | projectTempFile.open(); |
| 262 | auto copyJob = KIO::file_copy(projectFile.toUrl(), QUrl::fromLocalFile(projectTempFile.fileName()), -1, KIO::HideProgressInfo | KIO::Overwrite); |
| 263 | KJobWidgets::setWindow(copyJob, Core::self()->uiController()->activeMainWindow()); |
| 264 | if (!copyJob->exec()) |
| 265 | { |
| 266 | qCDebug(SHELL) << "Job failed:" << copyJob->errorString(); |
| 267 | |
| 268 | const QString messageText = i18n("Unable to get project file: %1", projectFile.pathOrUrl()); |
| 269 | auto* message = new Sublime::Message(messageText, Sublime::Message::Error); |
| 270 | ICore::self()->uiController()->postMessage(message); |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | if(developerFile.isLocalFile()) |
| 275 | { |
| 276 | developerTempFile = developerFile.toLocalFile(); |
| 277 | } |
no test coverage detected