Changeset View
Changeset View
Standalone View
Standalone View
src/qt/intro.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include "config/bitcoin-config.h" | #include "config/bitcoin-config.h" | ||||
#endif | #endif | ||||
#include "fs.h" | |||||
#include "guiutil.h" | |||||
#include "intro.h" | #include "intro.h" | ||||
#include "ui_intro.h" | #include "ui_intro.h" | ||||
#include "guiutil.h" | |||||
#include "util.h" | #include "util.h" | ||||
#include <boost/filesystem.hpp> | |||||
#include <QFileDialog> | #include <QFileDialog> | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
#include <QSettings> | #include <QSettings> | ||||
#include <cmath> | #include <cmath> | ||||
static const uint64_t GB_BYTES = 1000000000LL; | static const uint64_t GB_BYTES = 1000000000LL; | ||||
/* Minimum free space (in GB) needed for data directory */ | /* Minimum free space (in GB) needed for data directory */ | ||||
Show All 37 Lines | |||||
#include "intro.moc" | #include "intro.moc" | ||||
FreespaceChecker::FreespaceChecker(Intro *_intro) { | FreespaceChecker::FreespaceChecker(Intro *_intro) { | ||||
this->intro = _intro; | this->intro = _intro; | ||||
} | } | ||||
void FreespaceChecker::check() { | void FreespaceChecker::check() { | ||||
namespace fs = boost::filesystem; | |||||
QString dataDirStr = intro->getPathToCheck(); | QString dataDirStr = intro->getPathToCheck(); | ||||
fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr); | fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr); | ||||
uint64_t freeBytesAvailable = 0; | uint64_t freeBytesAvailable = 0; | ||||
int replyStatus = ST_OK; | int replyStatus = ST_OK; | ||||
QString replyMessage = tr("A new data directory will be created."); | QString replyMessage = tr("A new data directory will be created."); | ||||
/* Find first parent that exists, so that fs::space does not fail */ | /* Find first parent that exists, so that fs::space does not fail */ | ||||
fs::path parentDir = dataDir; | fs::path parentDir = dataDir; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | void Intro::setDataDirectory(const QString &dataDir) { | ||||
} | } | ||||
} | } | ||||
QString Intro::getDefaultDataDirectory() { | QString Intro::getDefaultDataDirectory() { | ||||
return GUIUtil::boostPathToQString(GetDefaultDataDir()); | return GUIUtil::boostPathToQString(GetDefaultDataDir()); | ||||
} | } | ||||
bool Intro::pickDataDirectory() { | bool Intro::pickDataDirectory() { | ||||
namespace fs = boost::filesystem; | |||||
QSettings settings; | QSettings settings; | ||||
/* If data directory provided on command line, no need to look at settings | /* If data directory provided on command line, no need to look at settings | ||||
or show a picking dialog */ | or show a picking dialog */ | ||||
if (!GetArg("-datadir", "").empty()) return true; | if (!GetArg("-datadir", "").empty()) return true; | ||||
/* 1) Default data directory for operating system */ | /* 1) Default data directory for operating system */ | ||||
QString dataDir = getDefaultDataDirectory(); | QString dataDir = getDefaultDataDirectory(); | ||||
/* 2) Allow QSettings to override default dir */ | /* 2) Allow QSettings to override default dir */ | ||||
dataDir = settings.value("strDataDir", dataDir).toString(); | dataDir = settings.value("strDataDir", dataDir).toString(); | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |