I have chnaged my code below
QScopedPointer<QProcess> my_process
(new QProcess());
source.
append(QDir::separator());
// source.append("*");
destination.
append(QDir::separator());
qDebug() << "Source : " << source;
qDebug() << "Destination : " << destination;
arguments << "-rf"
<< source
<< destination;
my_process->start("cp", arguments);
qDebug() << "Copied : " << my_process->waitForFinished();
qDebug() << my_process->errorString();
QScopedPointer<QProcess> my_process(new QProcess());
QString source = parent_path;
source.append(QDir::separator());
// source.append("*");
QString destination = map_path;
destination.append(QDir::separator());
qDebug() << "Source : " << source;
qDebug() << "Destination : " << destination;
QStringList arguments;
arguments << "-rf"
<< source
<< destination;
my_process->start("cp", arguments);
qDebug() << "Copied : " << my_process->waitForFinished();
qDebug() << my_process->errorString();
To copy to clipboard, switch view to plain text mode
Now it makes the data Directory in the destination directory.
Source = "/home/DATA/"
Destination = "/home/DATA_MAP/"
now it creates the DATA folder in my DATA_MAP folder.
I just want my data content in my DATA_MAP directory
Added after 12 minutes:
"parent_path" is the absolute path.
//////////////////////////////////
Following code wors for me
{
source.
append(QDir::separator());
source.append(directory);
qDebug() << "Source : " << source;
destination.
append(QDir::separator());
QScopedPointer<QProcess> my_process
(new QProcess());
connect(this, SIGNAL(stopProcessing()), my_process.data(), SLOT(kill()), Qt::DirectConnection);
arguments << "-rf"
<< source
<< destination;
my_process->start("cp", arguments);
qDebug() << "Copied : " << my_process->waitForFinished(-1);
}
{
QDir dir(parent_path);
QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
foreach(QString directory, dirs) {
QString source = parent_path;
source.append(QDir::separator());
source.append(directory);
qDebug() << "Source : " << source;
QString destination = map_path;
destination.append(QDir::separator());
QScopedPointer<QProcess> my_process(new QProcess());
connect(this, SIGNAL(stopProcessing()), my_process.data(), SLOT(kill()), Qt::DirectConnection);
QStringList arguments;
arguments << "-rf"
<< source
<< destination;
my_process->start("cp", arguments);
qDebug() << "Copied : " << my_process->waitForFinished(-1);
}
To copy to clipboard, switch view to plain text mode
Bookmarks