2014-11-28 18:38:24 +01:00
|
|
|
#include "FuseUtimensTest.h"
|
|
|
|
|
|
|
|
#include <utime.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
void FuseUtimensTest::Utimens(const char *filename, const timespec times[2]) {
|
2014-12-06 15:33:01 +01:00
|
|
|
int error = UtimensReturnError(filename, times);
|
|
|
|
EXPECT_EQ(0, error);
|
2014-11-28 18:38:24 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 15:33:01 +01:00
|
|
|
int FuseUtimensTest::UtimensReturnError(const char *filename, const timespec times[2]) {
|
2014-11-28 18:38:24 +01:00
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
|
|
|
|
|
|
|
struct timeval casted_times[2];
|
|
|
|
TIMESPEC_TO_TIMEVAL(&casted_times[0], ×[0]);
|
|
|
|
TIMESPEC_TO_TIMEVAL(&casted_times[1], ×[1]);
|
2014-12-06 15:33:01 +01:00
|
|
|
int retval = ::utimes(realpath.c_str(), casted_times);
|
|
|
|
if (0 == retval) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return errno;
|
|
|
|
}
|
2014-11-28 18:38:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct timespec FuseUtimensTest::makeTimespec(time_t tv_sec, long tv_nsec) {
|
|
|
|
struct timespec result;
|
|
|
|
result.tv_sec = tv_sec;
|
|
|
|
result.tv_nsec = tv_nsec;
|
|
|
|
return result;
|
|
|
|
}
|