mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-23 11:31:43 +00:00
624af11ca1
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@264 aa027e90-d47c-11dd-86d7-074df07e0730
95 lines
1.7 KiB
C++
95 lines
1.7 KiB
C++
#ifndef __DISKIMAGE_H__
|
|
#define __DISKIMAGE_H__
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <ProFUSE/Exception.h>
|
|
|
|
#include <Device/BlockDevice.h>
|
|
|
|
#include <Device/Adaptor.h>
|
|
|
|
#include <File/MappedFile.h>
|
|
|
|
namespace Device {
|
|
|
|
|
|
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:
|
|
|
|
|
|
DiskImage(MappedFile *file = 0);
|
|
DiskImage(const char *name, bool readOnly);
|
|
|
|
|
|
void setBlocks(unsigned blocks) { _blocks = blocks; }
|
|
|
|
void setAdaptor(Adaptor *);
|
|
|
|
void *address() const { return _file.address(); }
|
|
size_t length() const { return _file.length(); }
|
|
|
|
MappedFile *file() { return &_file; }
|
|
|
|
private:
|
|
|
|
MappedFile _file;
|
|
Adaptor *_adaptor;
|
|
|
|
bool _readOnly;
|
|
unsigned _blocks;
|
|
};
|
|
|
|
|
|
class ProDOSOrderDiskImage : public DiskImage {
|
|
public:
|
|
|
|
|
|
static ProDOSOrderDiskImage *Create(const char *name, size_t blocks);
|
|
static ProDOSOrderDiskImage *Open(MappedFile *);
|
|
|
|
|
|
virtual BlockCache *createBlockCache();
|
|
|
|
private:
|
|
ProDOSOrderDiskImage(const char *name, bool readOnly);
|
|
|
|
|
|
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:
|
|
DOSOrderDiskImage(const char *name, bool readOnly);
|
|
|
|
DOSOrderDiskImage(MappedFile *);
|
|
static void Validate(MappedFile *);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif |