mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-02 20:24:27 +02:00
Replace realpath with readlink
* Appears to be more modern and Debian Stretch requires it.
This commit is contained in:
18
src/tz.cpp
18
src/tz.cpp
@@ -337,11 +337,11 @@ discover_tz_dir()
|
|||||||
if (!(lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0))
|
if (!(lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0))
|
||||||
throw runtime_error("discover_tz_dir failed\n");
|
throw runtime_error("discover_tz_dir failed\n");
|
||||||
string result;
|
string result;
|
||||||
char rp[PATH_MAX];
|
char rp[PATH_MAX+1] = {};
|
||||||
if (realpath(timezone, rp))
|
if (readlink(timezone, rp, sizeof(rp)-1) > 0)
|
||||||
result = string(rp);
|
result = string(rp);
|
||||||
else
|
else
|
||||||
throw system_error(errno, system_category(), "realpath() failed");
|
throw system_error(errno, system_category(), "readlink() failed");
|
||||||
auto i = result.find("zoneinfo");
|
auto i = result.find("zoneinfo");
|
||||||
if (i == string::npos)
|
if (i == string::npos)
|
||||||
throw runtime_error("discover_tz_dir failed to find zoneinfo\n");
|
throw runtime_error("discover_tz_dir failed to find zoneinfo\n");
|
||||||
@@ -3652,11 +3652,11 @@ tzdb::current_zone() const
|
|||||||
if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) {
|
if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
string result;
|
string result;
|
||||||
char rp[PATH_MAX];
|
char rp[PATH_MAX+1] = {};
|
||||||
if (realpath(timezone, rp))
|
if (readlink(timezone, rp, sizeof(rp)-1) > 0)
|
||||||
result = string(rp);
|
result = string(rp);
|
||||||
else
|
else
|
||||||
throw system_error(errno, system_category(), "realpath() failed");
|
throw system_error(errno, system_category(), "readlink() failed");
|
||||||
|
|
||||||
const size_t pos = result.find(tz_dir);
|
const size_t pos = result.find(tz_dir);
|
||||||
if (pos != result.npos)
|
if (pos != result.npos)
|
||||||
@@ -3680,11 +3680,11 @@ tzdb::current_zone() const
|
|||||||
if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) {
|
if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
string result;
|
string result;
|
||||||
char rp[PATH_MAX];
|
char rp[PATH_MAX+1] = {};
|
||||||
if (realpath(timezone, rp))
|
if (readlink(timezone, rp, sizeof(rp)-1) > 0)
|
||||||
result = string(rp);
|
result = string(rp);
|
||||||
else
|
else
|
||||||
throw system_error(errno, system_category(), "realpath() failed");
|
throw system_error(errno, system_category(), "readlink() failed");
|
||||||
|
|
||||||
const size_t pos = result.find(tz_dir);
|
const size_t pos = result.find(tz_dir);
|
||||||
if (pos != result.npos)
|
if (pos != result.npos)
|
||||||
|
Reference in New Issue
Block a user