2018-10-20 23:40:02 -04:00
|
|
|
/*
|
|
|
|
|
ISC License
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2018, 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
|
|
|
|
|
|
2025-05-17 16:35:18 -05:00
|
|
|
#include "int_types.h"
|
2020-12-19 15:06:08 -05:00
|
|
|
#include "strvec.hpp"
|
|
|
|
|
#include "tofrom_string.hpp"
|
2025-09-24 00:51:21 -04:00
|
|
|
#include "fs_path.hpp"
|
2019-09-24 10:27:46 -04:00
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
#include <cstdint>
|
2025-05-17 16:35:18 -05:00
|
|
|
#include <memory>
|
|
|
|
|
#include <optional>
|
2018-10-20 23:40:02 -04:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2025-05-17 16:35:18 -05:00
|
|
|
#include <variant>
|
2018-10-20 23:40:02 -04:00
|
|
|
|
2019-09-24 10:27:46 -04:00
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
class Branch final : public ToFromString
|
2018-10-20 23:40:02 -04:00
|
|
|
{
|
2019-09-24 10:27:46 -04:00
|
|
|
public:
|
2025-05-17 16:35:18 -05:00
|
|
|
enum class Mode
|
|
|
|
|
{
|
|
|
|
|
INVALID,
|
|
|
|
|
RO,
|
|
|
|
|
RW,
|
|
|
|
|
NC
|
|
|
|
|
};
|
2020-08-20 18:47:04 -04:00
|
|
|
|
|
|
|
|
public:
|
2025-05-17 16:35:18 -05:00
|
|
|
std::variant<u64,const u64*> _minfreespace;
|
|
|
|
|
Mode mode;
|
2025-09-24 00:51:21 -04:00
|
|
|
fs::path path;
|
2020-08-20 18:47:04 -04:00
|
|
|
|
|
|
|
|
public:
|
2025-05-17 16:35:18 -05:00
|
|
|
Branch();
|
|
|
|
|
Branch(const Branch&);
|
|
|
|
|
Branch(const u64 &default_minfreespace);
|
2018-10-20 23:40:02 -04:00
|
|
|
|
2025-11-01 18:04:28 -05:00
|
|
|
public:
|
|
|
|
|
Branch& operator=(const Branch&) = default;
|
|
|
|
|
|
2020-08-20 18:47:04 -04:00
|
|
|
public:
|
2018-10-20 23:40:02 -04:00
|
|
|
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;
|
2020-08-20 18:47:04 -04:00
|
|
|
|
2019-09-24 10:27:46 -04:00
|
|
|
public:
|
2025-08-21 23:42:58 -04:00
|
|
|
int from_string(const std::string_view str) final;
|
2020-12-19 15:06:08 -05:00
|
|
|
std::string to_string(void) const final;
|
2019-09-24 10:27:46 -04:00
|
|
|
|
|
|
|
|
public:
|
2025-05-17 16:35:18 -05:00
|
|
|
u64 minfreespace() const;
|
|
|
|
|
void set_minfreespace(const u64);
|
2018-10-20 23:40:02 -04:00
|
|
|
};
|