mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-08 04:52:10 -05:00
tst: memfs-fuse3: accurately compute current time
This commit is contained in:
parent
b04266e0fe
commit
79be3e445a
@ -20,8 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <chrono>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -124,8 +124,12 @@ private:
|
|||||||
|
|
||||||
static fuse_timespec now()
|
static fuse_timespec now()
|
||||||
{
|
{
|
||||||
fuse_timespec ts = { static_cast<decltype(ts.tv_sec)>(std::time(0)) };
|
using namespace std::chrono;
|
||||||
return ts;
|
auto now = system_clock::now();
|
||||||
|
auto sec = floor<seconds>(now);
|
||||||
|
auto nsec = floor<nanoseconds>(now) - floor<nanoseconds>(sec);
|
||||||
|
return fuse_timespec{ sec.time_since_epoch().count(), nsec.count() };
|
||||||
|
/* std::chrono epoch is UNIX epoch in C++20 */
|
||||||
}
|
}
|
||||||
|
|
||||||
static memfs *getself()
|
static memfs *getself()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user