mergerfs/src/branch.hpp

71 lines
1.6 KiB
C++
Raw Normal View History

/*
ISC License
2026-02-23 13:22:21 -06:00
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
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 appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "base_types.h"
#include "strvec.hpp"
#include "fs_path.hpp"
#include <atomic>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <variant>
class Branch final
{
public:
enum class Mode
{
RO,
RW,
NC
};
public:
// A default held by pointer can be changed at runtime while
// requests read it.
std::variant<u64,const std::atomic<u64>*> _minfreespace;
Mode mode;
fs::path path;
public:
Branch();
Branch(const Branch&);
Branch(const std::atomic<u64> &default_minfreespace);
public:
Branch& operator=(const Branch&) = default;
public:
bool ro(void) const;
2018-11-02 10:23:56 -04:00
bool nc(void) const;
2018-11-01 23:37:45 -04:00
bool ro_or_nc(void) const;
public:
std::string to_string(void) const;
public:
u64 minfreespace() const;
void set_minfreespace(const u64);
};