mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-10 07:30:09 +00:00
304164ecfa
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@386 aa027e90-d47c-11dd-86d7-074df07e0730
54 lines
888 B
C++
54 lines
888 B
C++
#ifndef __BITMAP_H__
|
|
#define __BITMAP_H__
|
|
|
|
#include <stdint.h>
|
|
#include <vector>
|
|
|
|
|
|
namespace Device
|
|
{
|
|
class BlockDevice;
|
|
class BlockCache;
|
|
}
|
|
|
|
|
|
namespace ProDOS {
|
|
|
|
|
|
class Bitmap {
|
|
public:
|
|
|
|
Bitmap(unsigned blocks);
|
|
Bitmap(Device::BlockCache *cache, unsigned keyPointer, unsigned blocks);
|
|
|
|
~Bitmap();
|
|
|
|
int allocBlock();
|
|
int allocBlock(unsigned block);
|
|
|
|
void freeBlock(unsigned block);
|
|
|
|
|
|
unsigned freeBlocks() const { return _freeBlocks; }
|
|
unsigned blocks() const { return _blocks; }
|
|
unsigned bitmapBlocks() const { return _bitmapBlocks; }
|
|
unsigned bitmapSize() const { return _bitmapBlocks * 512; }
|
|
const void *bitmap() const { return &_bitmap[0]; }
|
|
|
|
private:
|
|
|
|
unsigned _freeIndex;
|
|
unsigned _freeBlocks;
|
|
|
|
unsigned _blocks;
|
|
unsigned _bitmapBlocks;
|
|
|
|
std::vector<uint8_t> _bitmap;
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|