mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 13:04:15 -04:00
Make mmap work with std::filesystem::path
This commit is contained in:
parent
b2a7a12159
commit
4898c553a8
@ -22,6 +22,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/iostreams/device/mapped_file.hpp>
|
#include <boost/iostreams/device/mapped_file.hpp>
|
||||||
@ -32,8 +33,10 @@ namespace dwarfs {
|
|||||||
|
|
||||||
class mmap : public mmif {
|
class mmap : public mmif {
|
||||||
public:
|
public:
|
||||||
explicit mmap(const std::string& path);
|
explicit mmap(std::filesystem::path const& path);
|
||||||
mmap(const std::string& path, size_t size);
|
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;
|
void const* addr() const override;
|
||||||
size_t size() 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(); }
|
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)
|
: mf_(path, boost::iostreams::mapped_file::readonly)
|
||||||
, page_size_(get_page_size()) {
|
, page_size_(get_page_size()) {
|
||||||
assert(mf_.is_open());
|
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)
|
: mf_(path, boost::iostreams::mapped_file::readonly, size)
|
||||||
, page_size_(get_page_size()) {
|
, page_size_(get_page_size()) {
|
||||||
assert(mf_.is_open());
|
assert(mf_.is_open());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mmap::mmap(std::filesystem::path const& path, size_t size)
|
||||||
|
: mmap(path.string(), size) {}
|
||||||
|
|
||||||
} // namespace dwarfs
|
} // namespace dwarfs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user