mirror of
https://github.com/matrix-construct/construct
synced 2024-11-04 21:08:57 +01:00
58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
|
// The Construct
|
||
|
//
|
||
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
||
|
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
||
|
//
|
||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||
|
// purpose with or without fee is hereby granted, provided that the above
|
||
|
// copyright notice and this permission notice is present in all copies. The
|
||
|
// full license for this software is available in the LICENSE file.
|
||
|
|
||
|
#pragma once
|
||
|
#define HAVE_IRCD_FS_MAP_H
|
||
|
|
||
|
namespace ircd::fs
|
||
|
{
|
||
|
struct map;
|
||
|
}
|
||
|
|
||
|
/// Interface to map file into memory.
|
||
|
///
|
||
|
/// Note that this was created specifically for file maps and not intended to
|
||
|
/// be a generic mmap(2) interface, at least for now.
|
||
|
struct ircd::fs::map
|
||
|
:mutable_buffer
|
||
|
{
|
||
|
struct opts;
|
||
|
|
||
|
map() = default;
|
||
|
map(const fd &, const opts &opts, const size_t &size = 0UL);
|
||
|
map(map &&) noexcept;
|
||
|
map(const map &) = delete;
|
||
|
map &operator=(map &&) noexcept;
|
||
|
map &operator=(const map &) = delete;
|
||
|
~map() noexcept;
|
||
|
};
|
||
|
|
||
|
/// Descriptor options (open options)
|
||
|
struct ircd::fs::map::opts
|
||
|
:fd::opts
|
||
|
{
|
||
|
bool execute {false};
|
||
|
bool shared {false};
|
||
|
bool reserve {false};
|
||
|
bool populate {false};
|
||
|
|
||
|
opts(const fd::opts &opts = {std::ios::in})
|
||
|
:fd::opts(opts)
|
||
|
{}
|
||
|
};
|
||
|
|
||
|
inline
|
||
|
ircd::fs::map::map(map &&other)
|
||
|
noexcept
|
||
|
:mutable_buffer{other}
|
||
|
{
|
||
|
static_cast<mutable_buffer &>(other) = {};
|
||
|
}
|