| 855 | } |
| 856 | |
| 857 | bool LiveCapture::saveCapture(Capture *cap, QString path) |
| 858 | { |
| 859 | // if this is the current capture, do the save through the main window |
| 860 | if(QString(m_Ctx.GetCaptureFilename()) == cap->path) |
| 861 | { |
| 862 | // if there's no target path, let the main window prompt for save. |
| 863 | if(path.isEmpty()) |
| 864 | return m_Main->PromptSaveCaptureAs(); |
| 865 | else |
| 866 | return m_Main->SaveCurrentCapture(path); |
| 867 | } |
| 868 | |
| 869 | if(path.isEmpty()) |
| 870 | { |
| 871 | path = m_Main->GetSavePath(); |
| 872 | |
| 873 | if(path.isEmpty()) |
| 874 | return false; |
| 875 | } |
| 876 | |
| 877 | if(QString(m_Ctx.GetCaptureFilename()) == path) |
| 878 | { |
| 879 | RDDialog::critical(this, tr("Cannot save"), |
| 880 | tr("Can't overwrite currently open capture at %1\n" |
| 881 | "Close the capture or save to another location.") |
| 882 | .arg(path)); |
| 883 | return false; |
| 884 | } |
| 885 | |
| 886 | // we copy the temp capture to the desired path, but the capture item remains referring to the |
| 887 | // temp path. |
| 888 | // This ensures that if the user deletes the saved path we can still open or re-save it. |
| 889 | if(cap->local) |
| 890 | { |
| 891 | QFile src(cap->path); |
| 892 | QFile dst(path); |
| 893 | |
| 894 | // remove any existing file, the user was already prompted to overwrite |
| 895 | if(dst.exists()) |
| 896 | { |
| 897 | if(!dst.remove()) |
| 898 | { |
| 899 | RDDialog::critical(this, tr("Cannot save"), |
| 900 | tr("Couldn't remove file at %1\n%2").arg(path).arg(dst.errorString())); |
| 901 | return false; |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | if(!src.copy(path)) |
| 906 | { |
| 907 | RDDialog::critical(this, tr("Cannot save"), |
| 908 | tr("Couldn't copy file to %1\n%2").arg(path).arg(src.errorString())); |
| 909 | return false; |
| 910 | } |
| 911 | } |
| 912 | else if(m_Connected.available()) |
| 913 | { |
| 914 | // if we have a current live connection, prefer using it |
nothing calls this directly
no test coverage detected