47 lines
1.1 KiB
C++
Executable File
47 lines
1.1 KiB
C++
Executable File
#include "konaclient.h"
|
|
|
|
KonaClient::KonaClient(QString TempDir, QString CacheDir, QString ArchiveDir, QString Server)
|
|
{
|
|
// Copy info to RAM
|
|
tempDir = TempDir;
|
|
cacheDir = CacheDir;
|
|
archiveDir = ArchiveDir;
|
|
server = Server;
|
|
|
|
// Create all directories
|
|
QDir aD(archiveDir);
|
|
if (!aD.exists()) aD.mkpath(archiveDir);
|
|
|
|
QDir cD(cacheDir);
|
|
if (!cD.exists()) cD.mkpath(cacheDir);
|
|
|
|
QDir tD(tempDir);
|
|
if (!tD.exists()) tD.mkpath(tempDir);
|
|
}
|
|
|
|
KonaClient::~KonaClient()
|
|
{
|
|
// Remove temp dir
|
|
QDir tD(tempDir);
|
|
if (tD.exists()) removeDir(tempDir);
|
|
}
|
|
|
|
// Copied from http://www.qtcentre.org/threads/4166-remove-directory-empty-or-not-empty
|
|
// Removes all files and subdirectories of a specific directory.
|
|
void KonaClient::removeDir(const QString &path)
|
|
{
|
|
QFileInfo fileInfo(path);
|
|
if(fileInfo.isDir()){
|
|
QDir dir(path);
|
|
QStringList fileList = dir.entryList();
|
|
for(int i = 0; i < fileList.count(); ++i){
|
|
|
|
QFile::remove(fileList.at(i));
|
|
}
|
|
dir.rmdir(path);
|
|
}
|
|
else{
|
|
QFile::remove(path);
|
|
}
|
|
}
|