diff --git a/src/gui/osdlang_setup.cpp b/src/gui/osdlang_setup.cpp index fc2b32a84..7659c9d18 100644 --- a/src/gui/osdlang_setup.cpp +++ b/src/gui/osdlang_setup.cpp @@ -128,10 +128,15 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems() if (!strcmp(xmlGetName(search), "zone")) { std::string name = xmlGetAttribute(search, "name"); -// std::string zone = xmlGetAttribute(search, "zone"); + std::string zone = xmlGetAttribute(search, "zone"); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); - tzSelect->addOption(name.c_str()); - found = true; + if (access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK)) + printf("[neutrino] timezone file '%s' not installed\n", zone.c_str()); + else + { + tzSelect->addOption(name.c_str()); + found = true; + } } search = search->xmlNextNode; } diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index eeb72a2a5..7f06634ce 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -875,7 +875,8 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) name = xmlGetAttribute(search, "name"); if(!strcmp(g_settings.timezone, name.c_str())) { zone = xmlGetAttribute(search, "zone"); - found = true; + if (!access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK)) + found = true; break; } } @@ -885,9 +886,12 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) } if(found) { printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); - std::string cmd = "cp /usr/share/zoneinfo/" + zone + " /etc/localtime"; - printf("exec %s\n", cmd.c_str()); - system(cmd.c_str()); + std::string cmd = "/usr/share/zoneinfo/" + zone; + printf("symlink %s to /etc/localtime\n", cmd.c_str()); + if (unlink("/etc/localtime")) + perror("unlink failed"); + if (symlink(cmd.c_str(), "/etc/localtime")) + perror("symlink failed"); cmd = ":" + zone; setenv("TZ", cmd.c_str(), 1); }