mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-18 01:30:56 +00:00
Revokes direct visibility of is_read_only_ to subclasses of FileHolder.
This commit is contained in:
parent
35705c5345
commit
7b01c1bee6
@ -45,11 +45,6 @@ unsigned int CPCDSK::get_head_count() {
|
|||||||
return head_count_;
|
return head_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPCDSK::get_is_read_only() {
|
|
||||||
// TODO: allow writing.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Track> CPCDSK::get_track_at_position(unsigned int head, unsigned int position) {
|
std::shared_ptr<Track> CPCDSK::get_track_at_position(unsigned int head, unsigned int position) {
|
||||||
// Given that thesea are interleaved images, determine which track, chronologically, is being requested.
|
// Given that thesea are interleaved images, determine which track, chronologically, is being requested.
|
||||||
unsigned int chronological_track = (position * head_count_) + head;
|
unsigned int chronological_track = (position * head_count_) + head;
|
||||||
|
@ -37,7 +37,7 @@ class CPCDSK: public DiskImage, public Storage::FileHolder {
|
|||||||
// implemented to satisfy @c Disk
|
// implemented to satisfy @c Disk
|
||||||
unsigned int get_head_position_count();
|
unsigned int get_head_position_count();
|
||||||
unsigned int get_head_count();
|
unsigned int get_head_count();
|
||||||
bool get_is_read_only();
|
using DiskImage::get_is_read_only;
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -34,6 +34,7 @@ class D64: public DiskImage, public Storage::FileHolder {
|
|||||||
|
|
||||||
// implemented to satisfy @c Disk
|
// implemented to satisfy @c Disk
|
||||||
unsigned int get_head_position_count();
|
unsigned int get_head_position_count();
|
||||||
|
using DiskImage::get_is_read_only;
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -38,6 +38,7 @@ class G64: public DiskImage, public Storage::FileHolder {
|
|||||||
// implemented to satisfy @c Disk
|
// implemented to satisfy @c Disk
|
||||||
unsigned int get_head_position_count();
|
unsigned int get_head_position_count();
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
using DiskImage::get_is_read_only;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t number_of_tracks_;
|
uint8_t number_of_tracks_;
|
||||||
|
@ -36,6 +36,7 @@ class HFE: public DiskImage, public Storage::FileHolder {
|
|||||||
// implemented to satisfy @c Disk
|
// implemented to satisfy @c Disk
|
||||||
unsigned int get_head_position_count();
|
unsigned int get_head_position_count();
|
||||||
unsigned int get_head_count();
|
unsigned int get_head_count();
|
||||||
|
using Storage::FileHolder::get_is_read_only;
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -20,10 +20,6 @@ void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, boo
|
|||||||
is_double_density_ = is_double_density;
|
is_double_density_ = is_double_density;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MFMSectorDump::get_is_read_only() {
|
|
||||||
return is_read_only_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Track> MFMSectorDump::get_track_at_position(unsigned int head, unsigned int position) {
|
std::shared_ptr<Track> MFMSectorDump::get_track_at_position(unsigned int head, unsigned int position) {
|
||||||
uint8_t sectors[(128 << sector_size_)*sectors_per_track_];
|
uint8_t sectors[(128 << sector_size_)*sectors_per_track_];
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class MFMSectorDump: public DiskImage, public Storage::FileHolder {
|
|||||||
MFMSectorDump(const char *file_name);
|
MFMSectorDump(const char *file_name);
|
||||||
void set_geometry(int sectors_per_track, uint8_t sector_size, bool is_double_density);
|
void set_geometry(int sectors_per_track, uint8_t sector_size, bool is_double_density);
|
||||||
|
|
||||||
bool get_is_read_only();
|
using Storage::FileHolder::get_is_read_only;
|
||||||
void set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track);
|
void set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track);
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
|
||||||
|
@ -37,10 +37,6 @@ unsigned int OricMFMDSK::get_head_count() {
|
|||||||
return head_count_;
|
return head_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OricMFMDSK::get_is_read_only() {
|
|
||||||
return is_read_only_;
|
|
||||||
}
|
|
||||||
|
|
||||||
long OricMFMDSK::get_file_offset_for_position(unsigned int head, unsigned int position) {
|
long OricMFMDSK::get_file_offset_for_position(unsigned int head, unsigned int position) {
|
||||||
long seek_offset = 0;
|
long seek_offset = 0;
|
||||||
switch(geometry_type_) {
|
switch(geometry_type_) {
|
||||||
|
@ -34,7 +34,7 @@ class OricMFMDSK: public DiskImage, public Storage::FileHolder {
|
|||||||
// implemented to satisfy @c Disk
|
// implemented to satisfy @c Disk
|
||||||
unsigned int get_head_position_count();
|
unsigned int get_head_position_count();
|
||||||
unsigned int get_head_count();
|
unsigned int get_head_count();
|
||||||
bool get_is_read_only();
|
using Storage::FileHolder::get_is_read_only;
|
||||||
void set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track);
|
void set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track);
|
||||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ uint16_t FileHolder::fgetc16be() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileHolder::get_is_read_only() {
|
||||||
|
return is_read_only_;
|
||||||
|
}
|
||||||
|
|
||||||
void FileHolder::ensure_file_is_at_least_length(long length) {
|
void FileHolder::ensure_file_is_at_least_length(long length) {
|
||||||
fseek(file_, 0, SEEK_END);
|
fseek(file_, 0, SEEK_END);
|
||||||
long bytes_to_write = length - ftell(file_);
|
long bytes_to_write = length - ftell(file_);
|
||||||
|
@ -79,6 +79,11 @@ class FileHolder {
|
|||||||
*/
|
*/
|
||||||
void ensure_file_is_at_least_length(long length);
|
void ensure_file_is_at_least_length(long length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@returns @c true if this file is read-only; @c false otherwise.
|
||||||
|
*/
|
||||||
|
bool get_is_read_only();
|
||||||
|
|
||||||
class BitStream {
|
class BitStream {
|
||||||
public:
|
public:
|
||||||
BitStream(FILE *f, bool lsb_first) :
|
BitStream(FILE *f, bool lsb_first) :
|
||||||
@ -124,10 +129,11 @@ class FileHolder {
|
|||||||
|
|
||||||
FILE *file_;
|
FILE *file_;
|
||||||
struct stat file_stats_;
|
struct stat file_stats_;
|
||||||
bool is_read_only_;
|
|
||||||
std::mutex file_access_mutex_;
|
std::mutex file_access_mutex_;
|
||||||
|
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
|
private:
|
||||||
|
bool is_read_only_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user