1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Switches away from C strings and allows Vic-20 region inference from filenames.

This commit is contained in:
Thomas Harte 2018-04-06 17:42:24 -04:00
parent cc49140f6f
commit e1c4035812
45 changed files with 151 additions and 123 deletions

View File

@ -39,7 +39,7 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
return vic20_cartridges;
}
void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std::unique_ptr<Analyser::Static::Target>> &destination) {
void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std::unique_ptr<Analyser::Static::Target>> &destination, const std::string &file_name) {
std::unique_ptr<Target> target(new Target);
target->machine = Machine::Vic20; // TODO: machine estimation
target->confidence = 0.5; // TODO: a proper estimation
@ -140,6 +140,14 @@ void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std
// }
}
if(!target->media.empty())
if(!target->media.empty()) {
// Inspect filename for a region hint.
std::string lowercase_name = file_name;
std::transform(lowercase_name.begin(), lowercase_name.end(), lowercase_name.begin(), ::tolower);
if(lowercase_name.find("ntsc") != std::string::npos) {
target->region = Analyser::Static::Commodore::Target::Region::American;
}
destination.push_back(std::move(target));
}
}

View File

@ -10,12 +10,13 @@
#define StaticAnalyser_Commodore_StaticAnalyser_hpp
#include "../StaticAnalyser.hpp"
#include <string>
namespace Analyser {
namespace Static {
namespace Commodore {
void AddTargets(const Media &media, std::vector<std::unique_ptr<Target>> &destination);
void AddTargets(const Media &media, std::vector<std::unique_ptr<Target>> &destination, const std::string &file_name);
}
}

View File

@ -52,21 +52,16 @@
using namespace Analyser::Static;
static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType &potential_platforms) {
static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::IntType &potential_platforms) {
Media result;
// Get the extension, if any; it will be assumed that extensions are reliable, so an extension is a broad-phase
// test as to file format.
const char *mixed_case_extension = strrchr(file_name, '.');
char *lowercase_extension = nullptr;
if(mixed_case_extension) {
lowercase_extension = strdup(mixed_case_extension+1);
char *parser = lowercase_extension;
while(*parser) {
*parser = (char)tolower(*parser);
parser++;
}
}
std::string::size_type final_dot = file_name.find_last_of(".");
if(final_dot == std::string::npos) return result;
std::string extension = file_name.substr(final_dot + 1);
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
Media result;
#define Insert(list, class, platforms) \
list.emplace_back(new Storage::class(file_name));\
potential_platforms |= platforms;\
@ -78,78 +73,72 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType
Insert(list, class, platforms) \
} catch(...) {}
#define Format(extension, list, class, platforms) \
if(!std::strcmp(lowercase_extension, extension)) { \
#define Format(ext, list, class, platforms) \
if(extension == ext) { \
TryInsert(list, class, platforms) \
}
if(lowercase_extension) {
Format("80", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 80
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
Format("adf", result.disks, Disk::DiskImageHolder<Storage::Disk::AcornADF>, TargetPlatform::Acorn) // ADF
Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN
Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS
Format("cdt", result.tapes, Tape::TZX, TargetPlatform::AmstradCPC) // CDT
Format("col", result.cartridges, Cartridge::BinaryDump, TargetPlatform::ColecoVision) // COL
Format("csw", result.tapes, Tape::CSW, TargetPlatform::AllTape) // CSW
Format("d64", result.disks, Disk::DiskImageHolder<Storage::Disk::D64>, TargetPlatform::Commodore) // D64
Format("dmk", result.disks, Disk::DiskImageHolder<Storage::Disk::DMK>, TargetPlatform::MSX) // DMK
Format("dsd", result.disks, Disk::DiskImageHolder<Storage::Disk::SSD>, TargetPlatform::Acorn) // DSD
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::CPCDSK>, TargetPlatform::AmstradCPC) // DSK (Amstrad CPC)
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::MSXDSK>, TargetPlatform::MSX) // DSK (MSX)
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::OricMFMDSK>, TargetPlatform::Oric) // DSK (Oric)
Format("g64", result.disks, Disk::DiskImageHolder<Storage::Disk::G64>, TargetPlatform::Commodore) // G64
Format( "hfe",
result.disks,
Disk::DiskImageHolder<Storage::Disk::HFE>,
TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore | TargetPlatform::Oric)
// HFE (TODO: switch to AllDisk once the MSX stops being so greedy)
Format("o", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // O
Format("p", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P
Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81
Format("80", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 80
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
Format("adf", result.disks, Disk::DiskImageHolder<Storage::Disk::AcornADF>, TargetPlatform::Acorn) // ADF
Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN
Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS
Format("cdt", result.tapes, Tape::TZX, TargetPlatform::AmstradCPC) // CDT
Format("col", result.cartridges, Cartridge::BinaryDump, TargetPlatform::ColecoVision) // COL
Format("csw", result.tapes, Tape::CSW, TargetPlatform::AllTape) // CSW
Format("d64", result.disks, Disk::DiskImageHolder<Storage::Disk::D64>, TargetPlatform::Commodore) // D64
Format("dmk", result.disks, Disk::DiskImageHolder<Storage::Disk::DMK>, TargetPlatform::MSX) // DMK
Format("dsd", result.disks, Disk::DiskImageHolder<Storage::Disk::SSD>, TargetPlatform::Acorn) // DSD
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::CPCDSK>, TargetPlatform::AmstradCPC) // DSK (Amstrad CPC)
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::MSXDSK>, TargetPlatform::MSX) // DSK (MSX)
Format("dsk", result.disks, Disk::DiskImageHolder<Storage::Disk::OricMFMDSK>, TargetPlatform::Oric) // DSK (Oric)
Format("g64", result.disks, Disk::DiskImageHolder<Storage::Disk::G64>, TargetPlatform::Commodore) // G64
Format( "hfe",
result.disks,
Disk::DiskImageHolder<Storage::Disk::HFE>,
TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore | TargetPlatform::Oric)
// HFE (TODO: switch to AllDisk once the MSX stops being so greedy)
Format("o", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // O
Format("p", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P
Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81
// PRG
if(!std::strcmp(lowercase_extension, "prg")) {
// try instantiating as a ROM; failing that accept as a tape
// PRG
if(extension == "prg") {
// try instantiating as a ROM; failing that accept as a tape
try {
Insert(result.cartridges, Cartridge::PRG, TargetPlatform::Commodore)
} catch(...) {
try {
Insert(result.cartridges, Cartridge::PRG, TargetPlatform::Commodore)
} catch(...) {
try {
Insert(result.tapes, Tape::PRG, TargetPlatform::Commodore)
} catch(...) {}
}
Insert(result.tapes, Tape::PRG, TargetPlatform::Commodore)
} catch(...) {}
}
}
Format( "rom",
result.cartridges,
Cartridge::BinaryDump,
TargetPlatform::AcornElectron | TargetPlatform::ColecoVision | TargetPlatform::MSX) // ROM
Format("ssd", result.disks, Disk::DiskImageHolder<Storage::Disk::SSD>, TargetPlatform::Acorn) // SSD
Format("tap", result.tapes, Tape::CommodoreTAP, TargetPlatform::Commodore) // TAP (Commodore)
Format("tap", result.tapes, Tape::OricTAP, TargetPlatform::Oric) // TAP (Oric)
Format("tsx", result.tapes, Tape::TZX, TargetPlatform::MSX) // TSX
Format("tzx", result.tapes, Tape::TZX, TargetPlatform::ZX8081) // TZX
Format("uef", result.tapes, Tape::UEF, TargetPlatform::Acorn) // UEF (tape)
Format( "rom",
result.cartridges,
Cartridge::BinaryDump,
TargetPlatform::AcornElectron | TargetPlatform::ColecoVision | TargetPlatform::MSX) // ROM
Format("ssd", result.disks, Disk::DiskImageHolder<Storage::Disk::SSD>, TargetPlatform::Acorn) // SSD
Format("tap", result.tapes, Tape::CommodoreTAP, TargetPlatform::Commodore) // TAP (Commodore)
Format("tap", result.tapes, Tape::OricTAP, TargetPlatform::Oric) // TAP (Oric)
Format("tsx", result.tapes, Tape::TZX, TargetPlatform::MSX) // TSX
Format("tzx", result.tapes, Tape::TZX, TargetPlatform::ZX8081) // TZX
Format("uef", result.tapes, Tape::UEF, TargetPlatform::Acorn) // UEF (tape)
#undef Format
#undef Insert
#undef TryInsert
// Filter potential platforms as per file preferences, if any.
free(lowercase_extension);
}
return result;
}
Media Analyser::Static::GetMedia(const char *file_name) {
Media Analyser::Static::GetMedia(const std::string &file_name) {
TargetPlatform::IntType throwaway;
return GetMediaAndPlatforms(file_name, throwaway);
}
std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const char *file_name) {
std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const std::string &file_name) {
std::vector<std::unique_ptr<Target>> targets;
// Collect all disks, tapes and ROMs as can be extrapolated from this file, forming the
@ -163,7 +152,7 @@ std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const char *fi
if(potential_platforms & TargetPlatform::AmstradCPC) AmstradCPC::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::Atari2600) Atari::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::ColecoVision) Coleco::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::Commodore) Commodore::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::Commodore) Commodore::AddTargets(media, targets, file_name);
if(potential_platforms & TargetPlatform::MSX) MSX::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::Oric) Oric::AddTargets(media, targets);
if(potential_platforms & TargetPlatform::ZX8081) ZX8081::AddTargets(media, targets, potential_platforms);

View File

@ -53,12 +53,12 @@ struct Target {
@returns The list of potential targets, sorted from most to least probable.
*/
std::vector<std::unique_ptr<Target>> GetTargets(const char *file_name);
std::vector<std::unique_ptr<Target>> GetTargets(const std::string &file_name);
/*!
Inspects the supplied file and determines the media included.
*/
Media GetMedia(const char *file_name);
Media GetMedia(const std::string &file_name);
}
}

View File

@ -44,7 +44,7 @@ void Analyser::Static::ZX8081::AddTargets(const Media &media, std::vector<std::u
break;
case TargetPlatform::ZX80: target->is_ZX81 = false; break;
case TargetPlatform::ZX81: target->is_ZX81 = true; break;
case TargetPlatform::ZX81: target->is_ZX81 = true; break;
}
/*if(files.front().data.size() > 16384) {

View File

@ -13,13 +13,13 @@
using namespace Storage::Cartridge;
BinaryDump::BinaryDump(const char *file_name) {
BinaryDump::BinaryDump(const std::string &file_name) {
// the file should be exactly 16 kb
struct stat file_stats;
stat(file_name, &file_stats);
stat(file_name.c_str(), &file_stats);
// grab contents
FILE *file = std::fopen(file_name, "rb");
FILE *file = std::fopen(file_name.c_str(), "rb");
if(!file) throw ErrorNotAccessible;
std::size_t data_length = static_cast<std::size_t>(file_stats.st_size);
std::vector<uint8_t> contents(data_length);

View File

@ -11,12 +11,14 @@
#include "../Cartridge.hpp"
#include <string>
namespace Storage {
namespace Cartridge {
class BinaryDump : public Cartridge {
public:
BinaryDump(const char *file_name);
BinaryDump(const std::string &file_name);
enum {
ErrorNotAccessible

View File

@ -15,16 +15,16 @@
using namespace Storage::Cartridge;
PRG::PRG(const char *file_name) {
PRG::PRG(const std::string &file_name) {
struct stat file_stats;
stat(file_name, &file_stats);
stat(file_name.c_str(), &file_stats);
// accept only files sized less than 8kb
if(file_stats.st_size > 0x2000 + 2)
throw ErrorNotROM;
// get the loading address, and the rest of the contents
FILE *file = std::fopen(file_name, "rb");
FILE *file = std::fopen(file_name.c_str(), "rb");
int loading_address = fgetc(file);
loading_address |= fgetc(file) << 8;

View File

@ -11,12 +11,14 @@
#include "../Cartridge.hpp"
#include <string>
namespace Storage {
namespace Cartridge {
class PRG : public Cartridge {
public:
PRG(const char *file_name);
PRG(const std::string &file_name);
enum {
ErrorNotROM

View File

@ -17,7 +17,7 @@ namespace {
using namespace Storage::Disk;
AcornADF::AcornADF(const char *file_name) : MFMSectorDump(file_name) {
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
// very loose validation: the file needs to be a multiple of 256 bytes
// and not ungainly large
if(file_.stats().st_size % static_cast<off_t>(128 << sector_size)) throw ErrorNotAcornADF;

View File

@ -11,6 +11,8 @@
#include "MFMSectorDump.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -25,7 +27,7 @@ class AcornADF: public MFMSectorDump {
@throws ErrorCantOpen if this file can't be opened.
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
*/
AcornADF(const char *file_name);
AcornADF(const std::string &file_name);
enum {
ErrorNotAcornADF,

View File

@ -17,7 +17,7 @@
using namespace Storage::Disk;
CPCDSK::CPCDSK(const char *file_name) :
CPCDSK::CPCDSK(const std::string &file_name) :
file_name_(file_name),
is_extended_(false) {
FileHolder file(file_name);

View File

@ -13,6 +13,7 @@
#include "../../../FileHolder.hpp"
#include "../../Encodings/MFM/Sector.hpp"
#include <string>
#include <vector>
namespace Storage {
@ -29,7 +30,7 @@ class CPCDSK: public DiskImage {
@throws ErrorCantOpen if this file can't be opened.
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
*/
CPCDSK(const char *file_name);
CPCDSK(const std::string &file_name);
enum {
ErrorNotCPCDSK,

View File

@ -17,7 +17,7 @@
using namespace Storage::Disk;
D64::D64(const char *file_name) :
D64::D64(const std::string &file_name) :
file_(file_name) {
// in D64, this is it for validation without imposing potential false-negative tests — check that
// the file size appears to be correct. Stone-age stuff.
@ -29,10 +29,9 @@ D64::D64(const char *file_name) :
// then, ostensibly, this is a valid file. Hmmm. Pick a disk ID as a function of the file_name,
// being the most stable thing available
disk_id_ = 0;
while(*file_name) {
disk_id_ ^= file_name[0];
for(const auto &character: file_name) {
disk_id_ ^= character;
disk_id_ = static_cast<uint16_t>((disk_id_ << 2) ^ (disk_id_ >> 13));
file_name++;
}
}

View File

@ -26,7 +26,7 @@ class D64: public DiskImage {
@throws ErrorCantOpen if this file can't be opened.
@throws ErrorNotD64 if the file doesn't appear to contain a .D64 format image.
*/
D64(const char *file_name);
D64(const std::string &file_name);
enum {
ErrorNotD64,

View File

@ -32,7 +32,7 @@ std::unique_ptr<Storage::Encodings::MFM::Encoder> new_encoder(Storage::Disk::PCM
}
DMK::DMK(const char *file_name) :
DMK::DMK(const std::string &file_name) :
file_(file_name) {
// Determine whether this DMK represents a read-only disk (whether intentionally,
// or by virtue of placement).

View File

@ -12,6 +12,8 @@
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -26,7 +28,7 @@ class DMK: public DiskImage {
@throws ErrorNotDMK if this file doesn't appear to be a DMK.
*/
DMK(const char *file_name);
DMK(const std::string &file_name);
enum {
ErrorNotDMK

View File

@ -16,7 +16,7 @@
using namespace Storage::Disk;
G64::G64(const char *file_name) :
G64::G64(const std::string &file_name) :
file_(file_name) {
// read and check the file signature
if(!file_.check_signature("GCR-1541")) throw ErrorNotG64;

View File

@ -12,6 +12,8 @@
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -27,7 +29,7 @@ class G64: public DiskImage {
@throws ErrorNotG64 if the file doesn't appear to contain a .G64 format image.
@throws ErrorUnknownVersion if this file appears to be a .G64 but has an unrecognised version number.
*/
G64(const char *file_name);
G64(const std::string &file_name);
enum {
ErrorCantOpen,

View File

@ -14,7 +14,7 @@
using namespace Storage::Disk;
HFE::HFE(const char *file_name) :
HFE::HFE(const std::string &file_name) :
file_(file_name) {
if(!file_.check_signature("HXCPICFE")) throw ErrorNotHFE;

View File

@ -12,6 +12,8 @@
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -26,7 +28,7 @@ class HFE: public DiskImage {
@throws ErrorCantOpen if this file can't be opened.
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
*/
HFE(const char *file_name);
HFE(const std::string &file_name);
~HFE();
enum {

View File

@ -12,7 +12,7 @@
using namespace Storage::Disk;
MFMSectorDump::MFMSectorDump(const char *file_name) : file_(file_name) {}
MFMSectorDump::MFMSectorDump(const std::string &file_name) : file_(file_name) {}
void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density) {
sectors_per_track_ = sectors_per_track;

View File

@ -12,6 +12,8 @@
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -20,7 +22,7 @@ namespace Disk {
*/
class MFMSectorDump: public DiskImage {
public:
MFMSectorDump(const char *file_name);
MFMSectorDump(const std::string &file_name);
void set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density);
bool get_is_read_only() override;

View File

@ -17,7 +17,7 @@ namespace {
using namespace Storage::Disk;
MSXDSK::MSXDSK(const char *file_name) :
MSXDSK::MSXDSK(const std::string &file_name) :
MFMSectorDump(file_name) {
// The only sanity check here is whether a sensible
// geometry can be guessed.

View File

@ -11,6 +11,8 @@
#include "MFMSectorDump.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -20,7 +22,7 @@ namespace Disk {
*/
class MSXDSK: public MFMSectorDump {
public:
MSXDSK(const char *file_name);
MSXDSK(const std::string &file_name);
enum {
ErrorNotMSXDSK,

View File

@ -16,7 +16,7 @@
using namespace Storage::Disk;
OricMFMDSK::OricMFMDSK(const char *file_name) :
OricMFMDSK::OricMFMDSK(const std::string &file_name) :
file_(file_name) {
if(!file_.check_signature("MFM_DISK"))
throw ErrorNotOricMFMDSK;

View File

@ -12,6 +12,8 @@
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Disk {
@ -25,7 +27,7 @@ class OricMFMDSK: public DiskImage {
@throws ErrorNotOricMFMDSK if the file doesn't appear to contain an Oric MFM format image.
*/
OricMFMDSK(const char *file_name);
OricMFMDSK(const std::string &file_name);
enum {
ErrorNotOricMFMDSK,

View File

@ -19,7 +19,7 @@ namespace {
using namespace Storage::Disk;
SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
SSD::SSD(const std::string &file_name) : MFMSectorDump(file_name) {
// very loose validation: the file needs to be a multiple of 256 bytes
// and not ungainly large
@ -28,7 +28,7 @@ SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
if(file_.stats().st_size > 800*256) throw ErrorNotSSD;
// this has two heads if the suffix is .dsd, one if it's .ssd
head_count_ = (tolower(file_name[std::strlen(file_name) - 3]) == 'd') ? 2 : 1;
head_count_ = (tolower(file_name[file_name.size() - 3]) == 'd') ? 2 : 1;
track_count_ = static_cast<int>(file_.stats().st_size / (256 * 10));
if(track_count_ < 40) track_count_ = 40;
else if(track_count_ < 80) track_count_ = 80;

View File

@ -25,7 +25,7 @@ class SSD: public MFMSectorDump {
@throws ErrorCantOpen if this file can't be opened.
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
*/
SSD(const char *file_name);
SSD(const std::string &file_name);
enum {
ErrorNotSSD,

View File

@ -17,7 +17,7 @@ namespace {
const uint8_t header_signature[8] = {0x1f, 0xa6, 0xde, 0xba, 0xcc, 0x13, 0x7d, 0x74};
}
CAS::CAS(const char *file_name) {
CAS::CAS(const std::string &file_name) {
Storage::FileHolder file(file_name);
uint8_t lookahead[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

View File

@ -13,6 +13,7 @@
#include "../../FileHolder.hpp"
#include <cstdint>
#include <string>
#include <vector>
namespace Storage {
@ -28,7 +29,7 @@ class CAS: public Tape {
@throws ErrorNotCAS if this file could not be opened and recognised as a valid CAS file.
*/
CAS(const char *file_name);
CAS(const std::string &file_name);
enum {
ErrorNotCAS

View File

@ -12,7 +12,7 @@
using namespace Storage::Tape;
CSW::CSW(const char *file_name) :
CSW::CSW(const std::string &file_name) :
source_data_pointer_(0) {
Storage::FileHolder file(file_name);
if(file.stats().st_size < 0x20) throw ErrorNotCSW;

View File

@ -12,8 +12,9 @@
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
#include <zlib.h>
#include <string>
#include <vector>
#include <zlib.h>
namespace Storage {
namespace Tape {
@ -28,7 +29,7 @@ class CSW: public Tape {
@throws ErrorNotCSW if this file could not be opened and recognised as a valid CSW file.
*/
CSW(const char *file_name);
CSW(const std::string &file_name);
enum class CompressionType {
RLE,

View File

@ -12,7 +12,7 @@
using namespace Storage::Tape;
CommodoreTAP::CommodoreTAP(const char *file_name) :
CommodoreTAP::CommodoreTAP(const std::string &file_name) :
file_(file_name)
{
if(!file_.check_signature("C64-TAPE-RAW"))

View File

@ -11,7 +11,9 @@
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
#include <cstdint>
#include <string>
namespace Storage {
namespace Tape {
@ -26,7 +28,7 @@ class CommodoreTAP: public Tape {
@throws ErrorNotCommodoreTAP if this file could not be opened and recognised as a valid Commodore-format TAP.
*/
CommodoreTAP(const char *file_name);
CommodoreTAP(const std::string &file_name);
enum {
ErrorNotCommodoreTAP

View File

@ -12,7 +12,7 @@
using namespace Storage::Tape;
OricTAP::OricTAP(const char *file_name) :
OricTAP::OricTAP(const std::string &file_name) :
file_(file_name)
{
// check the file signature

View File

@ -11,7 +11,9 @@
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
#include <cstdint>
#include <string>
namespace Storage {
namespace Tape {
@ -26,7 +28,7 @@ class OricTAP: public Tape {
@throws ErrorNotOricTAP if this file could not be opened and recognised as a valid Oric-format TAP.
*/
OricTAP(const char *file_name);
OricTAP(const std::string &file_name);
enum {
ErrorNotOricTAP

View File

@ -17,7 +17,7 @@ const unsigned int StandardTZXClock = 3500000;
const unsigned int TZXClockMSMultiplier = 3500;
}
TZX::TZX(const char *file_name) :
TZX::TZX(const std::string &file_name) :
file_(file_name),
current_level_(false) {

View File

@ -12,6 +12,8 @@
#include "../PulseQueuedTape.hpp"
#include "../../FileHolder.hpp"
#include <string>
namespace Storage {
namespace Tape {
@ -25,7 +27,7 @@ class TZX: public PulseQueuedTape {
@throws ErrorNotTZX if this file could not be opened and recognised as a valid TZX file.
*/
TZX(const char *file_name);
TZX(const std::string &file_name);
enum {
ErrorNotTZX

View File

@ -48,7 +48,7 @@
using namespace Storage::Tape;
PRG::PRG(const char *file_name) :
PRG::PRG(const std::string &file_name) :
file_(file_name)
{
// There's really no way to validate other than that if this file is larger than 64kb,

View File

@ -11,7 +11,9 @@
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
#include <cstdint>
#include <string>
namespace Storage {
namespace Tape {
@ -27,7 +29,7 @@ class PRG: public Tape {
@param file_name The name of the file to load.
@throws ErrorBadFormat if this file could not be opened and recognised as the specified type.
*/
PRG(const char *file_name);
PRG(const std::string &file_name);
enum {
ErrorBadFormat

View File

@ -68,8 +68,8 @@ static int gzget32(gzFile file) {
using namespace Storage::Tape;
UEF::UEF(const char *file_name) {
file_ = gzopen(file_name, "rb");
UEF::UEF(const std::string &file_name) {
file_ = gzopen(file_name.c_str(), "rb");
char identifier[10];
int bytes_read = gzread(file_, identifier, 10);

View File

@ -13,8 +13,9 @@
#include "../../TargetPlatforms.hpp"
#include <zlib.h>
#include <cstdint>
#include <string>
#include <zlib.h>
namespace Storage {
namespace Tape {
@ -29,7 +30,7 @@ class UEF : public PulseQueuedTape, public TargetPlatform::TypeDistinguisher {
@throws ErrorNotUEF if this file could not be opened and recognised as a valid UEF.
*/
UEF(const char *file_name);
UEF(const std::string &file_name);
~UEF();
enum {

View File

@ -11,7 +11,7 @@
using namespace Storage::Tape;
ZX80O81P::ZX80O81P(const char *file_name) {
ZX80O81P::ZX80O81P(const std::string &file_name) {
Storage::FileHolder file(file_name);
// Grab the actual file contents

View File

@ -15,6 +15,7 @@
#include "../../TargetPlatforms.hpp"
#include <cstdint>
#include <string>
#include <vector>
namespace Storage {
@ -30,7 +31,7 @@ class ZX80O81P: public Tape, public TargetPlatform::TypeDistinguisher {
@throws ErrorNotZX80O81P if this file could not be opened and recognised as a valid ZX80-format .O.
*/
ZX80O81P(const char *file_name);
ZX80O81P(const std::string &file_name);
enum {
ErrorNotZX80O81P