22#include <boost/filesystem/operations.hpp>
24#if BOOST_VERSION < 106000
30 auto iter =
path.end();
31 boost::filesystem::path head =
path;
33 for (; !head.empty(); --iter) {
34 if (boost::filesystem::exists(head)) {
37 head.remove_filename();
41 return boost::filesystem::absolute(
path);
42 head = boost::filesystem::canonical(head);
44 boost::filesystem::path tail;
45 for (; iter !=
path.end(); ++iter) {
52 return boost::filesystem::absolute(head / tail);
60 static auto default_manager = std::make_shared<LRUFileManager>();
61 return default_manager;
70 FileMetadata* f_ptr =
reinterpret_cast<FileMetadata*
>(id);
72 ++f_ptr->m_used_count;
86 for (
auto& fd : to_be_closed) {
87 auto req_close_copy = fd->m_request_close;
101 handler_ptr = i->second.lock();
106 auto handler_destroy = [this_weak, canonical](
FileHandler* obj) {
107 auto this_shared = this_weak.
lock();
110 this_shared->m_handlers.erase(canonical);
boost::filesystem::path weakly_canonical(const boost::filesystem::path &path)
T back_inserter(T... args)
virtual ~FileManager()
Destructor.
intptr_t FileId
Opaque FileId, its concrete type should only be assumed to be copyable and hashable.
std::map< boost::filesystem::path, std::weak_ptr< FileHandler > > m_handlers
static std::shared_ptr< FileManager > getDefault()
virtual void notifyUsed(FileId id)
std::map< FileId, std::unique_ptr< FileMetadata > > m_files
std::shared_ptr< FileHandler > getFileHandler(const boost::filesystem::path &path)
bool hasHandler(const boost::filesystem::path &path) const
FileManager()
Constructor.
T shared_from_this(T... args)