2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2011-03-18 03:14:45 +03:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <QDebug>
|
2011-03-31 21:06:30 +04:00
|
|
|
#include <QDir>
|
2011-03-18 03:14:45 +03:00
|
|
|
|
|
|
|
#include "mirall/temporarydir.h"
|
|
|
|
#include "mirall/fileutils.h"
|
|
|
|
|
|
|
|
namespace Mirall
|
|
|
|
{
|
|
|
|
|
2011-03-31 21:06:30 +04:00
|
|
|
static QString dirTemplate = QDir::tempPath() + "/mirall-XXXXXX";
|
2011-03-18 03:14:45 +03:00
|
|
|
|
|
|
|
TemporaryDir::TemporaryDir()
|
|
|
|
{
|
2011-03-31 21:06:30 +04:00
|
|
|
char *buff = ::strdup(dirTemplate.toLocal8Bit().data());
|
|
|
|
char *tmp = ::mkdtemp(buff);
|
2011-03-18 03:14:45 +03:00
|
|
|
_path = QString((const char *) tmp);
|
2011-03-31 21:06:30 +04:00
|
|
|
::free(buff);
|
2011-03-18 03:14:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryDir::~TemporaryDir()
|
|
|
|
{
|
|
|
|
FileUtils::removeDir(_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TemporaryDir::path() const
|
|
|
|
{
|
|
|
|
return _path;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|