1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Revokes direct visibility of is_read_only_ to subclasses of FileHolder.

This commit is contained in:
Thomas Harte 2017-10-03 19:36:06 -04:00
parent 35705c5345
commit 7b01c1bee6
11 changed files with 17 additions and 17 deletions

View File

@ -45,11 +45,6 @@ unsigned int CPCDSK::get_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) {
// Given that thesea are interleaved images, determine which track, chronologically, is being requested.
unsigned int chronological_track = (position * head_count_) + head;

View File

@ -37,7 +37,7 @@ class CPCDSK: public DiskImage, public Storage::FileHolder {
// implemented to satisfy @c Disk
unsigned int get_head_position_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);
private:

View File

@ -34,6 +34,7 @@ class D64: public DiskImage, public Storage::FileHolder {
// implemented to satisfy @c Disk
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);
private:

View File

@ -38,6 +38,7 @@ class G64: public DiskImage, public Storage::FileHolder {
// implemented to satisfy @c Disk
unsigned int get_head_position_count();
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
using DiskImage::get_is_read_only;
private:
uint8_t number_of_tracks_;

View File

@ -36,6 +36,7 @@ class HFE: public DiskImage, public Storage::FileHolder {
// implemented to satisfy @c Disk
unsigned int get_head_position_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);
private:

View File

@ -20,10 +20,6 @@ void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, boo
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) {
uint8_t sectors[(128 << sector_size_)*sectors_per_track_];

View File

@ -23,7 +23,7 @@ class MFMSectorDump: public DiskImage, public Storage::FileHolder {
MFMSectorDump(const char *file_name);
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);
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);

View File

@ -37,10 +37,6 @@ unsigned int OricMFMDSK::get_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 seek_offset = 0;
switch(geometry_type_) {

View File

@ -34,7 +34,7 @@ class OricMFMDSK: public DiskImage, public Storage::FileHolder {
// implemented to satisfy @c Disk
unsigned int get_head_position_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);
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);

View File

@ -77,6 +77,10 @@ uint16_t FileHolder::fgetc16be() {
return result;
}
bool FileHolder::get_is_read_only() {
return is_read_only_;
}
void FileHolder::ensure_file_is_at_least_length(long length) {
fseek(file_, 0, SEEK_END);
long bytes_to_write = length - ftell(file_);

View File

@ -79,6 +79,11 @@ class FileHolder {
*/
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 {
public:
BitStream(FILE *f, bool lsb_first) :
@ -124,10 +129,11 @@ class FileHolder {
FILE *file_;
struct stat file_stats_;
bool is_read_only_;
std::mutex file_access_mutex_;
const std::string name_;
private:
bool is_read_only_;
};
}