mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 16:31:31 +00:00
Adds a trivial mass-storage device, for Macintosh HFV volumes.
This commit is contained in:
parent
7d61df238a
commit
404b088199
33
Storage/MassStorage/Formats/HFV.cpp
Normal file
33
Storage/MassStorage/Formats/HFV.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// HFV.cpp
|
||||||
|
// Clock Signal
|
||||||
|
//
|
||||||
|
// Created by Thomas Harte on 25/08/2019.
|
||||||
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "HFV.hpp"
|
||||||
|
|
||||||
|
using namespace Storage::MassStorage;
|
||||||
|
|
||||||
|
HFV::HFV(const std::string &file_name) : file_(file_name) {
|
||||||
|
// Is the file a multiple of 512 bytes in size and larger than a floppy disk?
|
||||||
|
const auto file_size = file_.stats().st_size;
|
||||||
|
if(file_size & 511 || file_size <= 800*1024) throw std::exception();
|
||||||
|
|
||||||
|
// TODO: check filing system for MFS, HFS or HFS+.
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HFV::get_block_size() {
|
||||||
|
return 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HFV::get_number_of_blocks() {
|
||||||
|
return size_t(file_.stats().st_size) / get_block_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> HFV::get_block(size_t address) {
|
||||||
|
const long file_offset = long(get_block_size() * address);
|
||||||
|
file_.seek(file_offset, SEEK_SET);
|
||||||
|
return file_.read(get_block_size());
|
||||||
|
}
|
38
Storage/MassStorage/Formats/HFV.hpp
Normal file
38
Storage/MassStorage/Formats/HFV.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// HFV.hpp
|
||||||
|
// Clock Signal
|
||||||
|
//
|
||||||
|
// Created by Thomas Harte on 25/08/2019.
|
||||||
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef HFV_hpp
|
||||||
|
#define HFV_hpp
|
||||||
|
|
||||||
|
#include "../MassStorageDevice.hpp"
|
||||||
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
|
namespace Storage {
|
||||||
|
namespace MassStorage {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Provides a @c MassStorageDevice containing an HFV image, which is a sector dump of
|
||||||
|
a Macintosh drive that is not the correct size to be a floppy disk.
|
||||||
|
*/
|
||||||
|
class HFV: public MassStorageDevice {
|
||||||
|
public:
|
||||||
|
HFV(const std::string &file_name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
FileHolder file_;
|
||||||
|
|
||||||
|
size_t get_block_size() final;
|
||||||
|
size_t get_number_of_blocks() final;
|
||||||
|
std::vector<uint8_t> get_block(size_t address) final;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HFV_hpp */
|
Loading…
Reference in New Issue
Block a user