utimens
This commit is contained in:
parent
7ddf6d0672
commit
31aa6228bb
@ -180,17 +180,13 @@ int CryFuse::ftruncate(const path &path, off_t size, fuse_file_info *fileinfo) {
|
||||
|
||||
//TODO
|
||||
int CryFuse::utimens(const path &path, const timespec times[2]) {
|
||||
UNUSED(times);
|
||||
printf("NOT IMPLEMENTED: utimens(%s, _)\n", path.c_str());
|
||||
//auto real_path = _device->RootDir() / path;
|
||||
//struct timeval tv[2];
|
||||
//tv[0].tv_sec = times[0].tv_sec;
|
||||
//tv[0].tv_usec = times[0].tv_nsec / 1000;
|
||||
//tv[1].tv_sec = times[1].tv_sec;
|
||||
//tv[1].tv_usec = times[1].tv_nsec / 1000;
|
||||
//int retstat = ::lutimes(real_path.c_str(), tv);
|
||||
//return errcode_map(retstat);
|
||||
return 0;
|
||||
//printf("utimens(%s, _)\n", path.c_str());
|
||||
try {
|
||||
_device->utimens(path, times);
|
||||
return 0;
|
||||
} catch (CryErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
}
|
||||
|
||||
int CryFuse::open(const path &path, fuse_file_info *fileinfo) {
|
||||
|
@ -144,3 +144,7 @@ void CryDevice::closeDir(int descriptor) {
|
||||
_open_dirs.close(descriptor);
|
||||
}
|
||||
|
||||
void CryDevice::utimens(const bf::path &path, const timespec times[2]) {
|
||||
auto node = Load(path);
|
||||
node->utimens(times);
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ public:
|
||||
void rmdir(const bf::path &path);
|
||||
void unlink(const bf::path &path);
|
||||
void rename(const bf::path &from, const bf::path &to);
|
||||
|
||||
int openDir(const bf::path &path);
|
||||
std::unique_ptr<std::vector<std::string>> readDir(int descriptor);
|
||||
void closeDir(int descriptor);
|
||||
void utimens(const bf::path &path, const timespec times[2]);
|
||||
|
||||
const bf::path &RootDir() const;
|
||||
private:
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "CryNode.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "CryDevice.h"
|
||||
#include "CryErrnoException.h"
|
||||
|
||||
@ -29,4 +31,11 @@ void CryNode::rename(const bf::path &to) {
|
||||
_path = to;
|
||||
}
|
||||
|
||||
void CryNode::utimens(const timespec times[2]) {
|
||||
struct timeval timevals[2];
|
||||
TIMESPEC_TO_TIMEVAL(&timevals[0], ×[0]);
|
||||
TIMESPEC_TO_TIMEVAL(&timevals[1], ×[1]);
|
||||
::lutimes(base_path().c_str(), timevals);
|
||||
}
|
||||
|
||||
} /* namespace cryfs */
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
void stat(struct ::stat *result) const;
|
||||
void access(int mask) const;
|
||||
void rename(const bf::path &to);
|
||||
void utimens(const timespec times[2]);
|
||||
|
||||
protected:
|
||||
bf::path base_path() const;
|
||||
|
Loading…
Reference in New Issue
Block a user