mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 20:12:56 -04:00
boost::system::system_error -> std::system_error
This commit is contained in:
parent
8ed2fceba3
commit
3053140e5c
@ -24,9 +24,7 @@
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <system_error>
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
@ -56,7 +54,7 @@ class runtime_error : public error {
|
||||
: error(s, file, line) {}
|
||||
};
|
||||
|
||||
class system_error : public boost::system::system_error {
|
||||
class system_error : public std::system_error {
|
||||
public:
|
||||
system_error(char const* file, int line) noexcept;
|
||||
system_error(std::string const& s, char const* file, int line) noexcept;
|
||||
|
@ -38,9 +38,9 @@ class mmap : public mmif {
|
||||
void const* addr() const override;
|
||||
size_t size() const override;
|
||||
|
||||
boost::system::error_code lock(off_t offset, size_t size) override;
|
||||
boost::system::error_code release(off_t offset, size_t size) override;
|
||||
boost::system::error_code release_until(off_t offset) override;
|
||||
std::error_code lock(off_t offset, size_t size) override;
|
||||
std::error_code release(off_t offset, size_t size) override;
|
||||
std::error_code release_until(off_t offset) override;
|
||||
|
||||
private:
|
||||
int fd_;
|
||||
|
@ -22,9 +22,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <folly/Range.h>
|
||||
|
||||
@ -47,8 +47,8 @@ class mmif : public boost::noncopyable {
|
||||
virtual void const* addr() const = 0;
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
virtual boost::system::error_code lock(off_t offset, size_t size) = 0;
|
||||
virtual boost::system::error_code release(off_t offset, size_t size) = 0;
|
||||
virtual boost::system::error_code release_until(off_t offset) = 0;
|
||||
virtual std::error_code lock(off_t offset, size_t size) = 0;
|
||||
virtual std::error_code release(off_t offset, size_t size) = 0;
|
||||
virtual std::error_code release_until(off_t offset) = 0;
|
||||
};
|
||||
} // namespace dwarfs
|
||||
|
@ -43,13 +43,12 @@ system_error::system_error(std::string const& s, char const* file,
|
||||
|
||||
system_error::system_error(std::string const& s, int err, char const* file,
|
||||
int line) noexcept
|
||||
: boost::system::system_error(err, boost::system::generic_category(),
|
||||
s.c_str())
|
||||
: std::system_error(err, std::generic_category(), s.c_str())
|
||||
, file_(file)
|
||||
, line_(line) {}
|
||||
|
||||
system_error::system_error(int err, char const* file, int line) noexcept
|
||||
: boost::system::system_error(err, boost::system::generic_category())
|
||||
: std::system_error(err, std::generic_category())
|
||||
, file_(file)
|
||||
, line_(line) {}
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <folly/Range.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "dwarfs/error.h"
|
||||
@ -71,17 +69,17 @@ void* safe_mmap(int fd, size_t size) {
|
||||
|
||||
} // namespace
|
||||
|
||||
boost::system::error_code mmap::lock(off_t offset, size_t size) {
|
||||
boost::system::error_code ec;
|
||||
std::error_code mmap::lock(off_t offset, size_t size) {
|
||||
std::error_code ec;
|
||||
auto addr = reinterpret_cast<uint8_t*>(addr_) + offset;
|
||||
if (::mlock(addr, size) != 0) {
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, std::generic_category());
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
boost::system::error_code mmap::release(off_t offset, size_t size) {
|
||||
boost::system::error_code ec;
|
||||
std::error_code mmap::release(off_t offset, size_t size) {
|
||||
std::error_code ec;
|
||||
auto misalign = offset % page_size_;
|
||||
|
||||
offset -= misalign;
|
||||
@ -90,18 +88,18 @@ boost::system::error_code mmap::release(off_t offset, size_t size) {
|
||||
|
||||
auto addr = reinterpret_cast<uint8_t*>(addr_) + offset;
|
||||
if (::madvise(addr, size, MADV_DONTNEED) != 0) {
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, std::generic_category());
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
boost::system::error_code mmap::release_until(off_t offset) {
|
||||
boost::system::error_code ec;
|
||||
std::error_code mmap::release_until(off_t offset) {
|
||||
std::error_code ec;
|
||||
|
||||
offset -= offset % page_size_;
|
||||
|
||||
if (::madvise(addr_, offset, MADV_DONTNEED) != 0) {
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, std::generic_category());
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
@ -30,13 +30,12 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <folly/ExceptionString.h>
|
||||
#include <folly/container/F14Map.h>
|
||||
|
||||
@ -575,7 +574,7 @@ scanner_<LoggerPolicy>::scan_tree(const std::string& path, progress& prog,
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (const boost::system::system_error& e) {
|
||||
} catch (const std::system_error& e) {
|
||||
LOG_ERROR << "error reading entry: " << e.what();
|
||||
prog.errors++;
|
||||
}
|
||||
@ -584,7 +583,7 @@ scanner_<LoggerPolicy>::scan_tree(const std::string& path, progress& prog,
|
||||
queue.insert(queue.begin(), subdirs.begin(), subdirs.end());
|
||||
|
||||
prog.dirs_scanned++;
|
||||
} catch (const boost::system::system_error& e) {
|
||||
} catch (const std::system_error& e) {
|
||||
LOG_ERROR << "cannot open directory: " << e.what();
|
||||
prog.errors++;
|
||||
}
|
||||
|
@ -33,15 +33,9 @@ class mmap_mock : public mmif {
|
||||
|
||||
size_t size() const override { return m_data.size(); }
|
||||
|
||||
boost::system::error_code lock(off_t, size_t) override {
|
||||
return boost::system::error_code();
|
||||
}
|
||||
boost::system::error_code release(off_t, size_t) override {
|
||||
return boost::system::error_code();
|
||||
}
|
||||
boost::system::error_code release_until(off_t) override {
|
||||
return boost::system::error_code();
|
||||
}
|
||||
std::error_code lock(off_t, size_t) override { return std::error_code(); }
|
||||
std::error_code release(off_t, size_t) override { return std::error_code(); }
|
||||
std::error_code release_until(off_t) override { return std::error_code(); }
|
||||
|
||||
private:
|
||||
const std::string m_data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user