Fix current_zone not working on buildroot+glibc target - refs #846

The layout for timezones, on these targets, is
`/usr/share/zoneinfo/posix/Europe/Paris` instead of
`/usr/share/zoneinfo/Europe/Paris`.

`/usr/share/zoneinfo/Europe/Paris` exists and is a symlink to
`/usr/share/zoneinfo/posix/Europe/Paris`.

`/etc/localtime` correctly links to `/usr/share/zoneinfo/Europe/Paris`,
so `readlink` must be used instead of `realpath`.

Signed-off-by: Julien Blanc <julien.blanc@tgcm.eu>
This commit is contained in:
Julien Blanc 2024-10-01 12:00:00 +02:00 committed by Howard Hinnant
parent 510a05429f
commit dd8affc6de

View File

@ -4187,6 +4187,8 @@ sniff_realpath(const char* timezone)
if (rp.get() == nullptr) if (rp.get() == nullptr)
throw system_error(errno, system_category(), "realpath() failed"); throw system_error(errno, system_category(), "realpath() failed");
auto result = extract_tz_name(rp.get()); auto result = extract_tz_name(rp.get());
if (result.find("posix") == 0)
return false;
return result != "posixrules"; return result != "posixrules";
} }