2014-11-28 18:38:24 +01:00
|
|
|
#include "FuseUtimensTest.h"
|
2018-09-03 18:23:11 +02:00
|
|
|
#include <cpp-utils/system/filetime.h>
|
2014-11-28 18:38:24 +01:00
|
|
|
|
2016-02-09 09:36:07 +01:00
|
|
|
void FuseUtimensTest::Utimens(const char *filename, timespec lastAccessTime, timespec lastModificationTime) {
|
|
|
|
int error = UtimensReturnError(filename, lastAccessTime, lastModificationTime);
|
2014-12-06 15:33:01 +01:00
|
|
|
EXPECT_EQ(0, error);
|
2014-11-28 18:38:24 +01:00
|
|
|
}
|
|
|
|
|
2016-02-09 09:36:07 +01:00
|
|
|
int FuseUtimensTest::UtimensReturnError(const char *filename, timespec lastAccessTime, timespec lastModificationTime) {
|
2014-11-28 18:38:24 +01:00
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
|
|
|
|
2018-09-03 18:23:11 +02:00
|
|
|
return cpputils::set_filetime(realpath.string().c_str(), lastAccessTime, lastModificationTime);
|
2014-11-28 18:38:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct timespec FuseUtimensTest::makeTimespec(time_t tv_sec, long tv_nsec) {
|
2017-12-01 16:01:49 +01:00
|
|
|
struct timespec result{};
|
2014-11-28 18:38:24 +01:00
|
|
|
result.tv_sec = tv_sec;
|
|
|
|
result.tv_nsec = tv_nsec;
|
|
|
|
return result;
|
|
|
|
}
|