static inline int addDeleteRequest
(QHttp *http,
const QString
& name
) {
}
bool recursiveDeleteDir
(const QString &path
){ QStack<QString> currentPathStack;
QStack<QString> deletablePathStack;
currentPathStack.push(path);
while (!currentPathStack.isEmpty()) {
QString currentPath
= currentPathStack.
pop();
if (!isDeletableDir(currentPath))
return false;
if(isFile(entry) && isDeletableFile(entry)) {
deletableFileList << entry;
} else if (isDir(entry)) {
currentPathStack.push(entry);
} else {
return false;
}
}
deletablePathStack.push(currentPath);
}
// CONNECT deleterHttp HERE
foreach
(QString file, deletableFile
) { addDeleteRequest(deleterHttp, file);
}
while (!deletablePathStack.isEmpty()) {
addDeleteRequest(deleterHttp, deletablePathStack.pop());
}
QObject::connect(deleterHttp,
SIGNAL(done
(bool), deleterHttp,
SLOT(deleteLater
()));
return true;
}
static inline int addDeleteRequest(QHttp *http, const QString& name)
{
return http->request(QHttpRequestHeader("DELETE", name ,1,1));
}
bool recursiveDeleteDir(const QString &path){
QStack<QString> currentPathStack;
QStack<QString> deletablePathStack;
QStringList deletableFileList;
currentPathStack.push(path);
while (!currentPathStack.isEmpty()) {
QString currentPath = currentPathStack.pop();
if (!isDeletableDir(currentPath))
return false;
QStringList entries = children(currentPath);
foreach(QString entry, entries){
if(isFile(entry) && isDeletableFile(entry)) {
deletableFileList << entry;
} else if (isDir(entry)) {
currentPathStack.push(entry);
} else {
return false;
}
}
deletablePathStack.push(currentPath);
}
QHttp *deleterHttp = new QHttp;
// CONNECT deleterHttp HERE
foreach(QString file, deletableFile) {
addDeleteRequest(deleterHttp, file);
}
while (!deletablePathStack.isEmpty()) {
addDeleteRequest(deleterHttp, deletablePathStack.pop());
}
QObject::connect(deleterHttp, SIGNAL(done(bool), deleterHttp, SLOT(deleteLater()));
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks