2010-03-23 03:02:06 +00:00
|
|
|
#ifndef __DISKIMAGE_H__
|
|
|
|
#define __DISKIMAGE_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <ProFUSE/Exception.h>
|
|
|
|
|
|
|
|
#include <Device/BlockDevice.h>
|
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
#include <Device/Adaptor.h>
|
2010-03-23 03:02:06 +00:00
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
#include <File/MappedFile.h>
|
2010-03-23 03:02:06 +00:00
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
namespace Device {
|
2010-03-23 03:02:06 +00:00
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
|
2010-03-23 03:02:06 +00:00
|
|
|
class DiskImage : public BlockDevice {
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~DiskImage();
|
|
|
|
|
|
|
|
virtual void read(unsigned block, void *bp);
|
|
|
|
virtual void write(unsigned block, const void *bp);
|
|
|
|
virtual void sync();
|
|
|
|
|
|
|
|
virtual bool readOnly();
|
|
|
|
virtual unsigned blocks();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2010-05-29 19:29:59 +00:00
|
|
|
DiskImage();
|
2010-03-23 03:02:06 +00:00
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
DiskImage(MappedFile *file = 0);
|
2010-03-23 03:02:06 +00:00
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
void setBlocks(unsigned blocks) { _blocks = blocks; }
|
|
|
|
|
|
|
|
void setAdaptor(Adaptor *);
|
|
|
|
|
|
|
|
void *address() const { return _file.address(); }
|
2010-05-19 17:50:18 +00:00
|
|
|
size_t length() const { return _file.length(); }
|
|
|
|
|
2010-05-18 02:58:26 +00:00
|
|
|
MappedFile *file() { return &_file; }
|
2010-03-23 03:02:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MappedFile _file;
|
2010-05-18 02:58:26 +00:00
|
|
|
Adaptor *_adaptor;
|
2010-03-23 03:02:06 +00:00
|
|
|
|
|
|
|
bool _readOnly;
|
|
|
|
unsigned _blocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ProDOSOrderDiskImage : public DiskImage {
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
static ProDOSOrderDiskImage *Create(const char *name, size_t blocks);
|
|
|
|
static ProDOSOrderDiskImage *Open(MappedFile *);
|
2010-05-18 19:59:18 +00:00
|
|
|
|
|
|
|
|
2010-05-23 18:35:23 +00:00
|
|
|
virtual BlockCache *createBlockCache();
|
2010-03-23 03:02:06 +00:00
|
|
|
|
|
|
|
private:
|
2010-05-29 19:29:59 +00:00
|
|
|
ProDOSOrderDiskImage();
|
2010-05-18 02:58:26 +00:00
|
|
|
|
|
|
|
|
2010-03-23 03:02:06 +00:00
|
|
|
ProDOSOrderDiskImage(MappedFile *);
|
|
|
|
static void Validate(MappedFile *);
|
|
|
|
};
|
|
|
|
|
|
|
|
class DOSOrderDiskImage : public DiskImage {
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
static DOSOrderDiskImage *Create(const char *name, size_t blocks);
|
|
|
|
static DOSOrderDiskImage *Open(MappedFile *);
|
|
|
|
|
|
|
|
private:
|
2010-05-29 19:29:59 +00:00
|
|
|
DOSOrderDiskImage();
|
2010-05-18 02:58:26 +00:00
|
|
|
|
2010-03-23 03:02:06 +00:00
|
|
|
DOSOrderDiskImage(MappedFile *);
|
|
|
|
static void Validate(MappedFile *);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|