version Ok
This commit is contained in:
+13
-6
@@ -41,16 +41,24 @@ void downloadFile::download(MainWindow *mw)
|
||||
vector<string> v;
|
||||
int value;
|
||||
char buffer[4096];
|
||||
|
||||
argv[0] = "/usr/bin/rsync";
|
||||
argv[1] = "--bwlimit=" + mw->connexion.bandwidthLimit;
|
||||
if (mw->connexion.bandwidthLimit == 0)
|
||||
{
|
||||
argv[1] = "--bwlimit=1000P";
|
||||
}else
|
||||
{
|
||||
output << mw->connexion.bandwidthLimit;
|
||||
argv[1] = "--bwlimit=" + output.str() + mw->connexion.bandwidthLimitUnit;
|
||||
}
|
||||
argv[2] = "--port=" + to_string(mw->connexion.port);
|
||||
argv[3] = "-P";
|
||||
argv[4] = mw->connexion.server + "::" + mw->downloading.service + "/" + mw->downloading.path;
|
||||
argv[5] = mw->downloading.savePath + "/";
|
||||
argv[6] = "";
|
||||
|
||||
//unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd "r"), pclose);
|
||||
//launching downloading thread
|
||||
FILE * fp = popen2(argv, "r", mw->downloading.pid);
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
throw runtime_error("popen2() failed!");
|
||||
@@ -64,7 +72,6 @@ void downloadFile::download(MainWindow *mw)
|
||||
return;
|
||||
}
|
||||
line = buffer;
|
||||
//cout << line << endl;
|
||||
pos = line.find('%');
|
||||
if (pos != -1)
|
||||
{
|
||||
@@ -74,14 +81,14 @@ void downloadFile::download(MainWindow *mw)
|
||||
{
|
||||
line.erase(0, pos);
|
||||
value = stoi(line);
|
||||
//cout << value << endl;
|
||||
emit progressSignal(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
pclose2(fp, mw->downloading.pid);
|
||||
|
||||
// ProgressBar to 100% and emit signal finished to main application
|
||||
emit progressSignal(100);
|
||||
emit finishedSignal(true);
|
||||
//cout << path << endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user