mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-22 14:30:29 +00:00
Permit a mass-storage device to be returned, in theory.
This commit is contained in:
parent
4df2a29a1f
commit
20d685ec5c
@ -80,6 +80,8 @@
|
|||||||
// Target Platform Types
|
// Target Platform Types
|
||||||
#include "../../Storage/TargetPlatforms.hpp"
|
#include "../../Storage/TargetPlatforms.hpp"
|
||||||
|
|
||||||
|
template<class> inline constexpr bool always_false_v = false;
|
||||||
|
|
||||||
using namespace Analyser::Static;
|
using namespace Analyser::Static;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -123,7 +125,21 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
|||||||
if(extension == "2mg") {
|
if(extension == "2mg") {
|
||||||
// 2MG uses a factory method; defer to it.
|
// 2MG uses a factory method; defer to it.
|
||||||
try {
|
try {
|
||||||
InsertInstance(result.disks, Storage::Disk::Disk2MG::open(file_name), TargetPlatform::DiskII)
|
const auto media = Storage::Disk::Disk2MG::open(file_name);
|
||||||
|
std::visit([&result, &potential_platforms](auto &&arg) {
|
||||||
|
using Type = typename std::decay<decltype(arg)>::type;
|
||||||
|
|
||||||
|
if constexpr (std::is_same<Type, nullptr_t>::value) {
|
||||||
|
// It's valid for no media to be returned.
|
||||||
|
} else if constexpr (std::is_same<Type, Storage::Disk::DiskImageHolderBase *>::value) {
|
||||||
|
InsertInstance(result.disks, arg, TargetPlatform::DiskII);
|
||||||
|
} else if constexpr (std::is_same<Type, Storage::MassStorage::MassStorageDevice *>::value) {
|
||||||
|
// TODO: or is it Apple IIgs?
|
||||||
|
InsertInstance(result.mass_storage_devices, arg, TargetPlatform::AppleII);
|
||||||
|
} else {
|
||||||
|
static_assert(always_false_v<Type>, "Unexpected type encountered.");
|
||||||
|
}
|
||||||
|
}, media);
|
||||||
} catch(...) {}
|
} catch(...) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
DiskImageHolderBase *Disk2MG::open(const std::string &file_name) {
|
Disk2MG::DiskOrMassStorageDevice Disk2MG::open(const std::string &file_name) {
|
||||||
FileHolder file(file_name);
|
FileHolder file(file_name);
|
||||||
|
|
||||||
// Check the signature.
|
// Check the signature.
|
||||||
|
@ -10,8 +10,12 @@
|
|||||||
#define _MG_hpp
|
#define _MG_hpp
|
||||||
|
|
||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
|
#include "../../../MassStorage/MassStorageDevice.hpp"
|
||||||
|
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -26,7 +30,8 @@ namespace Disk {
|
|||||||
|
|
||||||
class Disk2MG {
|
class Disk2MG {
|
||||||
public:
|
public:
|
||||||
static DiskImageHolderBase *open(const std::string &file_name);
|
using DiskOrMassStorageDevice = std::variant<nullptr_t, DiskImageHolderBase *, Storage::MassStorage::MassStorageDevice *>;
|
||||||
|
static DiskOrMassStorageDevice open(const std::string &file_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user