Move fsblobstore::now() to cpputils

This commit is contained in:
Sebastian Messmer 2016-05-27 15:46:05 -07:00
parent 40c64a879c
commit f6545bbcc3
5 changed files with 27 additions and 30 deletions

View File

@ -0,0 +1,19 @@
#pragma once
#ifndef MESSMER_CPPUTILS_SYSTEM_TIME_H
#define MESSMER_CPPUTILS_SYSTEM_TIME_H
#include <sys/types.h>
#include "clock_gettime.h"
namespace cpputils {
namespace time {
// TODO Test
inline timespec now() {
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
return now;
}
}
}
#endif

View File

@ -9,7 +9,7 @@
#include "CryDevice.h"
#include "CryFile.h"
#include "CryOpenFile.h"
#include "fsblobstore/utils/time.h"
#include <cpp-utils/system/time.h>
//TODO Get rid of this in favor of exception hierarchy
using fspp::fuse::CHECK_RETVAL;
@ -40,7 +40,7 @@ CryDir::~CryDir() {
unique_ref<fspp::OpenFile> CryDir::createAndOpenFile(const string &name, mode_t mode, uid_t uid, gid_t gid) {
device()->callFsActionCallbacks();
auto child = device()->CreateFileBlob();
auto now = fsblobstore::time::now();
auto now = cpputils::time::now();
auto dirBlob = LoadBlob();
dirBlob->AddChildFile(name, child->key(), mode, uid, gid, now, now);
return make_unique_ref<CryOpenFile>(device(), cpputils::to_unique_ptr(std::move(dirBlob)), std::move(child));
@ -50,7 +50,7 @@ void CryDir::createDir(const string &name, mode_t mode, uid_t uid, gid_t gid) {
device()->callFsActionCallbacks();
auto blob = LoadBlob();
auto child = device()->CreateDirBlob();
auto now = fsblobstore::time::now();
auto now = cpputils::time::now();
blob->AddChildDir(name, child->key(), mode, uid, gid, now, now);
}
@ -80,7 +80,7 @@ void CryDir::createSymlink(const string &name, const bf::path &target, uid_t uid
device()->callFsActionCallbacks();
auto blob = LoadBlob();
auto child = device()->CreateSymlinkBlob(target);
auto now = fsblobstore::time::now();
auto now = cpputils::time::now();
blob->AddChildSymlink(name, child->key(), uid, gid, now, now);
}

View File

@ -4,7 +4,7 @@
#include <blockstore/utils/Key.h>
#include <fspp/fs_interface/Dir.h>
#include "time.h"
#include <cpp-utils/system/time.h>
namespace cryfs {
namespace fsblobstore {
@ -166,7 +166,7 @@ namespace cryfs {
}
inline void DirEntry::_updateLastMetadataChangeTime() {
setLastMetadataChangeTime(time::now());
setLastMetadataChangeTime(cpputils::time::now());
}
}

View File

@ -1,6 +1,6 @@
#include "DirEntryList.h"
#include <limits>
#include "time.h"
#include <cpp-utils/system/time.h>
//TODO Get rid of that in favor of better error handling
#include <fspp/fuse/FuseErrnoException.h>
@ -59,7 +59,7 @@ void DirEntryList::add(const string &name, const Key &blobKey, fspp::Dir::EntryT
void DirEntryList::_add(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
auto insert_pos = _findUpperBound(blobKey);
_entries.emplace(insert_pos, entryType, name, blobKey, mode, uid, gid, lastAccessTime, lastModificationTime, time::now());
_entries.emplace(insert_pos, entryType, name, blobKey, mode, uid, gid, lastAccessTime, lastModificationTime, cpputils::time::now());
}
void DirEntryList::addOrOverwrite(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,

View File

@ -1,22 +0,0 @@
#pragma once
#ifndef MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H
#define MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H
#include <sys/types.h>
#include <cpp-utils/system/clock_gettime.h>
namespace cryfs {
namespace fsblobstore {
namespace time {
inline timespec now() {
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
return now;
}
}
}
}
#endif