mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
MacOS < 10.13 has an issue with std::get, use std::get_if instead
This commit is contained in:
parent
ba6e0b72a7
commit
2e25675296
@ -70,7 +70,7 @@ bool fs_oric_jasmin::can_write() const
|
||||
std::vector<fs_meta_description> fs_oric_jasmin::volume_meta_description() const
|
||||
{
|
||||
std::vector<fs_meta_description> res;
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "UNTITLED", false, [](const fs_meta &m) { std::string n = std::get<std::string>(m); return n.size() <= 8; }, "Volume name, up to 8 characters"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "UNTITLED", false, [](const fs_meta &m) { return m.as_string().size() <= 8; }, "Volume name, up to 8 characters"));
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -99,8 +99,8 @@ bool fs_oric_jasmin::validate_filename(std::string name)
|
||||
std::vector<fs_meta_description> fs_oric_jasmin::file_meta_description() const
|
||||
{
|
||||
std::vector<fs_meta_description> res;
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "", false, [](const fs_meta &m) { std::string n = std::get<std::string>(m); return validate_filename(n); }, "File name, 8.3"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::loading_address, fs_meta_type::number, 0x501, false, [](const fs_meta &m) { uint64_t n = std::get<uint64_t>(m); return n < 0x10000; }, "Loading address of the file"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "", false, [](const fs_meta &m) { return validate_filename(m.as_string()); }, "File name, 8.3"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::loading_address, fs_meta_type::number, 0x501, false, [](const fs_meta &m) { return m.as_number() < 0x10000; }, "Loading address of the file"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::length, fs_meta_type::number, 0, true, nullptr, "Size of the file in bytes"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::size_in_blocks, fs_meta_type::number, 0, true, nullptr, "Number of blocks used by the file"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::locked, fs_meta_type::flag, false, false, nullptr, "File locked"));
|
||||
@ -111,7 +111,7 @@ std::vector<fs_meta_description> fs_oric_jasmin::file_meta_description() const
|
||||
|
||||
void fs_oric_jasmin::impl::format(const fs_meta_data &meta)
|
||||
{
|
||||
std::string volume_name = std::get<std::string>(meta.find(fs_meta_name::name)->second);
|
||||
std::string volume_name = meta.find(fs_meta_name::name)->second.as_string();
|
||||
u32 blocks = m_blockdev.block_count();
|
||||
|
||||
m_blockdev.fill(0x6c);
|
||||
|
@ -78,9 +78,9 @@ char fs_prodos::directory_separator() const
|
||||
std::vector<fs_meta_description> fs_prodos::volume_meta_description() const
|
||||
{
|
||||
std::vector<fs_meta_description> res;
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "UNTITLED", false, [](const fs_meta &m) { std::string n = std::get<std::string>(m); return n.size() <= 15; }, "Volume name, up to 15 characters"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::os_version, fs_meta_type::number, 5, false, [](const fs_meta &m) { return std::get<uint64_t>(m) <= 255; }, "Creator OS version"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::os_minimum_version, fs_meta_type::number, 5, false, [](const fs_meta &m) { return std::get<uint64_t>(m) <= 255; }, "Minimum OS version"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::name, fs_meta_type::string, "UNTITLED", false, [](const fs_meta &m) { return m.as_string().size() <= 15; }, "Volume name, up to 15 characters"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::os_version, fs_meta_type::number, 5, false, [](const fs_meta &m) { return m.as_number() <= 255; }, "Creator OS version"));
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::os_minimum_version, fs_meta_type::number, 5, false, [](const fs_meta &m) { return m.as_number() <= 255; }, "Minimum OS version"));
|
||||
|
||||
auto now = util::arbitrary_datetime::now();
|
||||
res.emplace_back(fs_meta_description(fs_meta_name::creation_date, fs_meta_type::date, now, false, nullptr, "Creation time"));
|
||||
@ -102,7 +102,7 @@ std::vector<fs_meta_description> fs_prodos::directory_meta_description() const
|
||||
|
||||
void fs_prodos::impl::format(const fs_meta_data &meta)
|
||||
{
|
||||
std::string volume_name = std::get<std::string>(meta.find(fs_meta_name::name)->second);
|
||||
std::string volume_name = meta.find(fs_meta_name::name)->second.as_string();
|
||||
u32 blocks = m_blockdev.block_count();
|
||||
|
||||
// Maximum usable partition size = 32M - 512 bytes (65535 blocks)
|
||||
|
@ -279,11 +279,11 @@ const char *fs_meta_get_name(fs_meta_name name)
|
||||
std::string fs_meta_to_string(fs_meta_type type, const fs_meta &m)
|
||||
{
|
||||
switch(type) {
|
||||
case fs_meta_type::string: return std::get<std::string>(m);
|
||||
case fs_meta_type::number: return util::string_format("0x%x", std::get<uint64_t>(m));
|
||||
case fs_meta_type::flag: return std::get<bool>(m) ? "t" : "f";
|
||||
case fs_meta_type::string: return m.as_string();
|
||||
case fs_meta_type::number: return util::string_format("0x%x", m.as_number());
|
||||
case fs_meta_type::flag: return m.as_flag() ? "t" : "f";
|
||||
case fs_meta_type::date: {
|
||||
auto dt = std::get<util::arbitrary_datetime>(m);
|
||||
auto dt = m.as_date();
|
||||
return util::string_format("%04d-%02d-%02d %02d:%02d:%02d",
|
||||
dt.year, dt.month, dt.day_of_month,
|
||||
dt.hour, dt.minute, dt.second);
|
||||
|
@ -40,7 +40,24 @@ enum class fs_dir_entry_type {
|
||||
system_file,
|
||||
};
|
||||
|
||||
using fs_meta = std::variant<std::string, uint64_t, bool, util::arbitrary_datetime>;
|
||||
class fs_meta {
|
||||
public:
|
||||
fs_meta() { value = false; }
|
||||
fs_meta(std::string str) { value = str; }
|
||||
fs_meta(bool b) { value = b; }
|
||||
fs_meta(uint64_t num) { value = num; }
|
||||
fs_meta(int64_t num) { value = uint64_t(num); }
|
||||
fs_meta(util::arbitrary_datetime dt) { value = dt; }
|
||||
|
||||
util::arbitrary_datetime as_date() const { return *std::get_if<util::arbitrary_datetime>(&value); }
|
||||
bool as_flag() const { return *std::get_if<bool>(&value); }
|
||||
uint64_t as_number() const { return *std::get_if<uint64_t>(&value); }
|
||||
std::string as_string() const { return *std::get_if<std::string>(&value); }
|
||||
|
||||
private:
|
||||
std::variant<std::string, uint64_t, bool, util::arbitrary_datetime> value;
|
||||
};
|
||||
|
||||
using fs_meta_data = std::unordered_map<fs_meta_name, fs_meta>;
|
||||
|
||||
const char *fs_meta_get_name(fs_meta_name name);
|
||||
|
Loading…
Reference in New Issue
Block a user