From 45903de1b5a8125c86254e2f712bc4f2d3a9f462 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sat, 29 Mar 2014 11:33:31 +0100 Subject: [PATCH] QPhotoRec: handle no space left and non-writable destination --- src/qphotorec.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qphotorec.cpp b/src/qphotorec.cpp index 75c4bf05..b55e2224 100644 --- a/src/qphotorec.cpp +++ b/src/qphotorec.cpp @@ -792,6 +792,40 @@ int QPhotorec::photorec(alloc_data_t *list_search_space) session_save(list_search_space, params, options); switch(ind_stop) { + case PSTATUS_EACCES: + { + int ret=QMessageBox::warning(this,"QPhotoRec: Failed to create file!", "Failed to create file! Please choose another destination", QMessageBox::Ok| QMessageBox::Cancel, QMessageBox::Ok); + if(ret==QMessageBox::Cancel) + { + params->status=STATUS_QUIT; + } + else + { + setExistingDirectory(); + free(params->recup_dir); + QByteArray byteArray = (directoryLabel->text() + "/" + DEFAULT_RECUP_DIR).toUtf8(); + params->recup_dir=strdup(byteArray.constData()); + params->dir_num=photorec_mkdir(params->recup_dir, params->dir_num); + } + } + break; + case PSTATUS_ENOSPC: + { + int ret=QMessageBox::warning(this,"QPhotoRec: Not enough space!", "There is not enough space left! Please free disk space and/or choose another destination", QMessageBox::Ok| QMessageBox::Cancel, QMessageBox::Ok); + if(ret==QMessageBox::Cancel) + { + params->status=STATUS_QUIT; + } + else + { + setExistingDirectory(); + free(params->recup_dir); + QByteArray byteArray = (directoryLabel->text() + "/" + DEFAULT_RECUP_DIR).toUtf8(); + params->recup_dir=strdup(byteArray.constData()); + params->dir_num=photorec_mkdir(params->recup_dir, params->dir_num); + } + } +break; case PSTATUS_OK: status_inc(params, options); if(params->status==STATUS_QUIT)