| 1342 | } |
| 1343 | |
| 1344 | bool CaptureContext::SaveCaptureTo(const rdcstr &captureFile) |
| 1345 | { |
| 1346 | bool success = false; |
| 1347 | QString error; |
| 1348 | |
| 1349 | if(IsCaptureLocal()) |
| 1350 | { |
| 1351 | if(QFileInfo(GetCaptureFilename()).exists()) |
| 1352 | { |
| 1353 | if(GetCaptureFilename() == captureFile) |
| 1354 | { |
| 1355 | success = true; |
| 1356 | } |
| 1357 | else |
| 1358 | { |
| 1359 | ICaptureFile *capFile = m_Replay.GetCaptureFile(); |
| 1360 | |
| 1361 | if(capFile) |
| 1362 | { |
| 1363 | // this will overwrite |
| 1364 | ResultDetails result = capFile->CopyFileTo(captureFile); |
| 1365 | success = result.OK(); |
| 1366 | error = result.Message(); |
| 1367 | } |
| 1368 | else |
| 1369 | { |
| 1370 | // QFile::copy won't overwrite, so remove the destination first (the save dialog already |
| 1371 | // prompted for overwrite) |
| 1372 | QFile::remove(captureFile); |
| 1373 | success = QFile::copy(GetCaptureFilename(), captureFile); |
| 1374 | error = tr("File move failed"); |
| 1375 | } |
| 1376 | |
| 1377 | error = tr("Couldn't save to %1: %2").arg(captureFile).arg(error); |
| 1378 | } |
| 1379 | } |
| 1380 | else |
| 1381 | { |
| 1382 | error = tr("Capture '%1' couldn't be found on disk, cannot save.").arg(GetCaptureFilename()); |
| 1383 | success = false; |
| 1384 | RDDialog::critical(NULL, tr("File not found"), error); |
| 1385 | } |
| 1386 | } |
| 1387 | else |
| 1388 | { |
| 1389 | Replay().CopyCaptureFromRemote(GetCaptureFilename(), captureFile, m_MainWindow); |
| 1390 | success = QFile::exists(captureFile); |
| 1391 | |
| 1392 | error = tr("File couldn't be transferred from remote host"); |
| 1393 | } |
| 1394 | |
| 1395 | if(!success) |
| 1396 | { |
| 1397 | RDDialog::critical(NULL, tr("Error Saving"), error); |
| 1398 | return false; |
| 1399 | } |
| 1400 | |
| 1401 | // if it was a temporary capture, remove the old instnace |
nothing calls this directly
no test coverage detected