diff --git a/include/dwarfs/mmap.h b/include/dwarfs/mmap.h index 4478028b..4331a494 100644 --- a/include/dwarfs/mmap.h +++ b/include/dwarfs/mmap.h @@ -22,6 +22,7 @@ #pragma once #include +#include #include #include @@ -32,8 +33,10 @@ namespace dwarfs { class mmap : public mmif { public: - explicit mmap(const std::string& path); - mmap(const std::string& path, size_t size); + explicit mmap(std::filesystem::path const& path); + explicit mmap(std::string const& path); + mmap(std::filesystem::path const& path, size_t size); + mmap(std::string const& path, size_t size); void const* addr() const override; size_t size() const override; diff --git a/src/dwarfs/mmap.cpp b/src/dwarfs/mmap.cpp index 47df43dd..8b51d01b 100644 --- a/src/dwarfs/mmap.cpp +++ b/src/dwarfs/mmap.cpp @@ -110,16 +110,22 @@ void const* mmap::addr() const { return mf_.const_data(); } size_t mmap::size() const { return mf_.size(); } -mmap::mmap(const std::string& path) +mmap::mmap(std::string const& path) : mf_(path, boost::iostreams::mapped_file::readonly) , page_size_(get_page_size()) { assert(mf_.is_open()); } -mmap::mmap(const std::string& path, size_t size) +mmap::mmap(std::filesystem::path const& path) + : mmap(path.string()) {} + +mmap::mmap(std::string const& path, size_t size) : mf_(path, boost::iostreams::mapped_file::readonly, size) , page_size_(get_page_size()) { assert(mf_.is_open()); } +mmap::mmap(std::filesystem::path const& path, size_t size) + : mmap(path.string(), size) {} + } // namespace dwarfs