mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 04:19:10 -04:00
Make mmap work with std::filesystem::path
This commit is contained in:
parent
b2a7a12159
commit
4898c553a8
@ -22,6 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include <boost/iostreams/device/mapped_file.hpp>
|
||||
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user