Commit 58f270df by Jonathan Wakely Committed by Jonathan Wakely

ops.cc (last_write_time): Set timespec members explicitly instead of with a braced-init-list.

	* src/filesystem/ops.cc (last_write_time) [_GLIBCXX_USE_UTIMENSAT]:
	Set timespec members explicitly instead of with a braced-init-list.
	[_GLIBCXX_HAVE_UTIME_H]: Use lambda to handle st_atime being a macro.

From-SVN: r222718
parent 4afeb6fc
2015-05-02 Jonathan Wakely <jwakely@redhat.com>
* src/filesystem/ops.cc (last_write_time) [_GLIBCXX_USE_UTIMENSAT]:
Set timespec members explicitly instead of with a braced-init-list.
[_GLIBCXX_HAVE_UTIME_H]: Use lambda to handle st_atime being a macro.
2015-05-02 Edward Smith-Rowland <3dw4rd@verizon.net> 2015-05-02 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/experimental/deque: Add feature-test macro. * include/experimental/deque: Add feature-test macro.
......
...@@ -871,20 +871,22 @@ fs::last_write_time(const path& p __attribute__((__unused__)), ...@@ -871,20 +871,22 @@ fs::last_write_time(const path& p __attribute__((__unused__)),
{ {
auto d = new_time.time_since_epoch(); auto d = new_time.time_since_epoch();
auto s = chrono::duration_cast<chrono::seconds>(d); auto s = chrono::duration_cast<chrono::seconds>(d);
#if _GLIBCXX_USE_UTIMENSAT
auto ns = chrono::duration_cast<chrono::nanoseconds>(d - s); auto ns = chrono::duration_cast<chrono::nanoseconds>(d - s);
#ifdef _GLIBCXX_USE_UTIMENSAT struct ::timespec ts[2];
struct ::timespec ts[2] = { ts[0].tv_sec = 0;
{ 0, UTIME_OMIT }, ts[0].tv_nsec = UTIME_OMIT;
{ static_cast<std::time_t>(s.count()), static_cast<long>(ns.count()) } ts[1].tv_sec = static_cast<std::time_t>(s.count());
}; ts[1].tv_nsec = static_cast<long>(ns.count());
if (utimensat(AT_FDCWD, p.c_str(), ts, 0)) if (::utimensat(AT_FDCWD, p.c_str(), ts, 0))
ec.assign(errno, std::generic_category()); ec.assign(errno, std::generic_category());
else else
ec.clear(); ec.clear();
#elif _GLIBCXX_HAVE_UTIME_H #elif _GLIBCXX_HAVE_UTIME_H
::utimbuf times; ::utimbuf times;
times.modtime = s.count(); times.modtime = s.count();
times.actime = do_stat(p, ec, std::mem_fn(&stat::st_atime), times.modtime); times.actime = do_stat(p, ec, [](const auto& st) { return st.st_atime; },
times.modtime);
if (::utime(p.c_str(), &times)) if (::utime(p.c_str(), &times))
ec.assign(errno, std::generic_category()); ec.assign(errno, std::generic_category());
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment