rsyncui/tools.cpp

38 lines
941 B
C++
Raw Normal View History

#include "mainwindow.h"
2023-01-07 12:44:45 +01:00
using namespace std;
#define READ 0
#define WRITE 1
2023-02-10 21:32:20 +01:00
extern QMap<int, QString> rsyncErrorStrings;
2023-03-09 18:13:46 +01:00
extern QApplication a;
2023-02-10 21:32:20 +01:00
// test return code of rsync
2023-03-08 16:03:24 +01:00
// return true in case of error
bool testRsyncReturn(MainWindow * w, QProcess * myProcess)
2023-01-07 12:44:45 +01:00
{
if (myProcess->exitStatus() != 0 and w->stopDlAsked != true)
2023-01-07 12:44:45 +01:00
{
2023-04-27 11:42:53 +02:00
cout << "rsync error: " << myProcess->error() << " : " << myProcess->errorString().toStdString() << endl;
2023-01-18 23:12:21 +01:00
QMessageBox::warning(
2023-03-08 16:03:24 +01:00
w,
2023-03-09 18:13:46 +01:00
a.applicationName(),
2023-02-10 21:32:20 +01:00
myProcess->errorString(),
QMessageBox::Ok,
QMessageBox::Ok);
return true;
2023-01-07 12:44:45 +01:00
}
w->stopDlAsked = false;
2023-02-10 21:32:20 +01:00
return false;
2023-01-07 12:44:45 +01:00
}
2023-03-04 19:12:13 +01:00
QString getFileType(QString filename)
{
QMimeDatabase db;
QMimeType mime = db.mimeTypeForFile(filename);
QString returnValue = mime.name().section('/',0 ,0);
2023-03-04 19:12:13 +01:00
return returnValue;
}
2023-03-08 16:03:24 +01:00