mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
generic: check more directories for zone info
fixes zone info detection on FreeBSD and possibly NetBSD (not tested) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e62863f60d
commit
dcbdbbeaa7
2 changed files with 36 additions and 26 deletions
|
@ -114,21 +114,26 @@ ClockHelper::CH_Error ClockHelper::tz( const QString& selectedzone )
|
|||
return TimezoneError;
|
||||
}
|
||||
|
||||
// from ktimezoned
|
||||
QString ZONE_INFO_DIR;
|
||||
// NOTE: keep in sync with ktimezoned/ktimezoned.cpp
|
||||
static const QStringList zoneDirs = QStringList()
|
||||
<< QLatin1String("/share/zoneinfo")
|
||||
<< QLatin1String("/lib/zoneinfo")
|
||||
<< QLatin1String("/usr/share/zoneinfo")
|
||||
<< QLatin1String("/usr/lib/zoneinfo")
|
||||
<< QLatin1String("/usr/local/share/zoneinfo")
|
||||
<< QLatin1String("/usr/local/lib/zoneinfo")
|
||||
<< (KStandardDirs::installPath("kdedir") + QLatin1String("/share/zoneinfo"))
|
||||
<< (KStandardDirs::installPath("kdedir") + QLatin1String("/lib/zoneinfo"));
|
||||
|
||||
if (QDir("/usr/share/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/usr/share/zoneinfo/";
|
||||
} else if (QDir("/usr/lib/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/usr/lib/zoneinfo/";
|
||||
} else if (QDir("/share/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/share/zoneinfo/";
|
||||
} else if (QDir("/lib/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/lib/zoneinfo/";
|
||||
} else {
|
||||
// /usr is kind of standard
|
||||
ZONE_INFO_DIR = "/usr/share/zoneinfo/";
|
||||
QString ZONE_INFO_DIR = "/usr/share/zoneinfo";
|
||||
|
||||
foreach (const QString &zonedir, zoneDirs) {
|
||||
if (QDir(zonedir).exists()) {
|
||||
ZONE_INFO_DIR = zonedir;
|
||||
}
|
||||
}
|
||||
|
||||
QString tz = ZONE_INFO_DIR + selectedzone;
|
||||
|
||||
QFile f("/etc/localtime");
|
||||
|
|
|
@ -175,20 +175,25 @@ void KTimeZoned::updateLocalZone()
|
|||
*/
|
||||
bool KTimeZoned::findZoneTab(QFile& f)
|
||||
{
|
||||
QString ZONE_TAB_FILE = "/zone.tab";
|
||||
QString ZONE_INFO_DIR;
|
||||
// NOTE: keep in sync with kcontrol/dateandtime/helper.cpp
|
||||
static const QStringList zoneDirs = QStringList()
|
||||
<< QLatin1String("/share/zoneinfo")
|
||||
<< QLatin1String("/lib/zoneinfo")
|
||||
<< QLatin1String("/usr/share/zoneinfo")
|
||||
<< QLatin1String("/usr/lib/zoneinfo")
|
||||
<< QLatin1String("/usr/local/share/zoneinfo")
|
||||
<< QLatin1String("/usr/local/lib/zoneinfo")
|
||||
<< (KStandardDirs::installPath("kdedir") + QLatin1String("/share/zoneinfo"))
|
||||
<< (KStandardDirs::installPath("kdedir") + QLatin1String("/lib/zoneinfo"));
|
||||
|
||||
if (QDir("/usr/share/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/usr/share/zoneinfo";
|
||||
} else if (QDir("/usr/lib/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/usr/lib/zoneinfo";
|
||||
} else if (QDir("/share/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/share/zoneinfo";
|
||||
} else if (QDir("/lib/zoneinfo").exists()) {
|
||||
ZONE_INFO_DIR = "/lib/zoneinfo";
|
||||
} else {
|
||||
QString ZONE_TAB_FILE = "/zone.tab";
|
||||
// /usr is kind of standard
|
||||
ZONE_INFO_DIR = "/usr/share/zoneinfo";
|
||||
QString ZONE_INFO_DIR = "/usr/share/zoneinfo";
|
||||
|
||||
foreach (const QString &zonedir, zoneDirs) {
|
||||
if (QDir(zonedir).exists()) {
|
||||
ZONE_INFO_DIR = zonedir;
|
||||
}
|
||||
}
|
||||
|
||||
// Find and open zone.tab - it's all easy except knowing where to look.
|
||||
|
|
Loading…
Add table
Reference in a new issue