OSX: Handle zonebg for first time installations

If none of the gameboard images is set and and the user’s data
directory doesn’t contain a “zonebg” directory, create the directory,
copy contents from cockatrice’s app bundle and sets the config
accordingly.
This commit is contained in:
Fabio Bas 2014-06-22 23:21:29 +02:00
parent 55c4c464e4
commit 0b4701c42f
4 changed files with 52 additions and 1 deletions

View file

@ -1,5 +1,6 @@
#include "settingscache.h"
#include <QSettings>
#include <QDir>
SettingsCache::SettingsCache()
{
@ -256,3 +257,28 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry)
mainWindowGeometry = _mainWindowGeometry;
settings->setValue("interface/main_window_geometry", mainWindowGeometry);
}
void SettingsCache::copyPath(const QString &src, const QString &dst)
{
// test source && return if inexistent
QDir dir(src);
if (! dir.exists())
return;
// test destination && create if inexistent
QDir tmpDir(dst);
if (!tmpDir.exists())
{
tmpDir.setPath(QDir::rootPath());
tmpDir.mkdir(dst);
}
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QString dst_path = dst + QDir::separator() + d;
dir.mkpath(dst_path);
copyPath(src+ QDir::separator() + d, dst_path);
}
foreach (QString f, dir.entryList(QDir::Files)) {
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
}
}