19 #ifndef FILEMANAGER_IMPL
20 #error "This file should not be included directly! Use FileManager.h instead"
25 #include <boost/filesystem/operations.hpp>
30 struct FileManager::FileMetadata {
31 boost::filesystem::path m_path;
34 uint64_t m_used_count;
37 FileMetadata(
const boost::filesystem::path&
path,
bool write)
38 : m_path(path), m_write(write), m_last_used(
Clock::now()), m_used_count(0) {}
41 template <
typename TFD>
44 notifyIntentToOpen(write);
46 auto meta = Euclid::make_unique<FileMetadata>(path, write);
47 FileId
id = meta.get();
48 meta->m_request_close = [id, request_close]() ->
bool {
return request_close(
id); };
61 template <
typename TFD>
static TFD open(const boost::filesystem::path &path, bool write)
Clock::time_point Timestamp
virtual void notifyClosedFile(FileId)=0
std::pair< FileId, TFD > open(const boost::filesystem::path &path, bool write, std::function< bool(FileId)> request_close)
std::map< FileId, std::unique_ptr< FileMetadata > > m_files
void close(FileId id, TFD &fd)
Elements::Path::Item path
std::chrono::steady_clock Clock