Fix Geoip database embedding

Fix Geoip path issue on Win32
This commit is contained in:
Christophe Dumez
2010-05-30 15:19:40 +00:00
parent 4eb8be372e
commit cfc4e7c8f6
4 changed files with 22 additions and 14 deletions

View File

@@ -68,13 +68,19 @@ protected:
// Create geoip folder is necessary
QDir gfolder(geoipFolder(false));
if(!gfolder.exists()) {
if(!gfolder.mkpath(geoipFolder(false))) return;
if(!gfolder.mkpath(geoipFolder(false))) {
std::cerr << "Failed to create geoip folder at " << qPrintable(geoipFolder(false)) << std::endl;
return;
}
}
// Remove destination files
if(QFile::exists(geoipDBpath(false)))
QFile::remove(geoipDBpath(false));
// Copy from executable to hard disk
QFile::copy(geoipDBpath(true), geoipDBpath(false));
qDebug("%s -> %s", qPrintable(geoipDBpath(true)), qPrintable(geoipDBpath(false)));
if(!QFile::copy(geoipDBpath(true), geoipDBpath(false))) {
std::cerr << "ERROR: Failed to copy geoip.dat from executable to hard disk" << std::endl;
}
qDebug("Local Geoip database was updated");
}
}

View File

@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/" >
<qresource>
<file>geoip/GeoIP.dat</file>
</qresource>
</RCC>

View File

@@ -74,6 +74,8 @@ QString misc::QDesktopServicesDataLocation() {
result = QString::fromWCharArray(path);
if (!QCoreApplication::applicationName().isEmpty())
result = result + QLatin1String("\\") + qApp->applicationName();
if(!result.endsWith("\\"))
result += "\\";
return result;
#else
#ifdef Q_WS_MAC

View File

@@ -3,7 +3,7 @@ LANG_PATH = lang
ICONS_PATH = Icons
# Set the following variable to 1 to enable debug
DEBUG_MODE = 0
DEBUG_MODE = 1
# Global
TEMPLATE = app
@@ -177,6 +177,12 @@ os2:LIBS += -ltorrent-rasterbar \
}
unix:!macx:contains(DEFINES, WITH_GEOIP_EMBEDDED):message("You chose to embed GeoIP database in qBittorrent executable.")
# Resource files
RESOURCES = icons.qrc \
lang.qrc \
search.qrc \
webui.qrc
# Add GeoIP resource file if the GeoIP database
# should be embedded in qBittorrent executable
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
@@ -192,12 +198,6 @@ os2:LIBS += -ltorrent-rasterbar \
else:message("GeoIP database will not be embedded in qBittorrent executable.")
}
# Resource files
RESOURCES = icons.qrc \
lang.qrc \
search.qrc \
webui.qrc
# Translations
TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
$$LANG_PATH/qbittorrent_zh.ts \