mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-05 05:29:37 +00:00
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@135 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
2675797136
commit
982b754713
7
auto.h
7
auto.h
@ -17,6 +17,13 @@ public:
|
|||||||
operator T*() const { return _t; }
|
operator T*() const { return _t; }
|
||||||
T& operator[](int index) { return _t[index]; }
|
T& operator[](int index) { return _t[index]; }
|
||||||
|
|
||||||
|
void reset(T *t)
|
||||||
|
{
|
||||||
|
if (t == _t) return;
|
||||||
|
if (_t) delete[] _t;
|
||||||
|
_t = t;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T *_t;
|
T *_t;
|
||||||
};
|
};
|
||||||
|
@ -48,7 +48,7 @@ VolumeEntry::VolumeEntry()
|
|||||||
_fileNameLength = 0;
|
_fileNameLength = 0;
|
||||||
std::memset(_fileName, 0, 8);
|
std::memset(_fileName, 0, 8);
|
||||||
_lastVolumeBlock = 0;
|
_lastVolumeBlock = 0;
|
||||||
_numberOfFiles = 0;
|
_fileCount = 0;
|
||||||
_accessTime = 0;
|
_accessTime = 0;
|
||||||
|
|
||||||
setInode(1);
|
setInode(1);
|
||||||
@ -65,7 +65,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
|
|||||||
|
|
||||||
device->read(2, buffer.get());
|
device->read(2, buffer.get());
|
||||||
|
|
||||||
init(tmp);
|
init(buffer.get());
|
||||||
|
|
||||||
// todo -- verify reasonable values.
|
// todo -- verify reasonable values.
|
||||||
blockCount = blocks();
|
blockCount = blocks();
|
||||||
@ -84,7 +84,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (unsigned i = 1; i < _numberFiles; ++i)
|
for (unsigned i = 1; i < _fileCount; ++i)
|
||||||
{
|
{
|
||||||
std::auto_ptr<FileEntry> child;
|
std::auto_ptr<FileEntry> child;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::vector<FileEntry *>iterator iter;
|
std::vector<FileEntry *>::iterator iter;
|
||||||
for(iter = _files.begin(); iter != _files.end(); ++iter)
|
for(iter = _files.begin(); iter != _files.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (*iter) delete *iter;
|
if (*iter) delete *iter;
|
||||||
@ -109,7 +109,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
|
|||||||
|
|
||||||
VolumeEntry::~VolumeEntry()
|
VolumeEntry::~VolumeEntry()
|
||||||
{
|
{
|
||||||
std::vector<FileEntry *>iterator iter;
|
std::vector<FileEntry *>::iterator iter;
|
||||||
for(iter = _files.begin(); iter != _files.end(); ++iter)
|
for(iter = _files.begin(); iter != _files.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (*iter) delete *iter;
|
if (*iter) delete *iter;
|
||||||
@ -128,9 +128,9 @@ void VolumeEntry::init(void *vp)
|
|||||||
std::memcpy(_fileName, 7 + (uint8_t *)vp, _fileNameLength);
|
std::memcpy(_fileName, 7 + (uint8_t *)vp, _fileNameLength);
|
||||||
|
|
||||||
_lastVolumeBlock = Read16(vp, 0x0e);
|
_lastVolumeBlock = Read16(vp, 0x0e);
|
||||||
_numberFile = Read16(vp, 0x10);
|
_fileCount = Read16(vp, 0x10);
|
||||||
_accessTime = Read16(vp, 0x12);
|
_accessTime = Read16(vp, 0x12);
|
||||||
_bootDate = DateRec(Read16(vp, 0x14);
|
_lastBoot = DateRec(Read16(vp, 0x14));
|
||||||
|
|
||||||
setInode(1);
|
setInode(1);
|
||||||
_inodeGenerator = 1;
|
_inodeGenerator = 1;
|
||||||
@ -139,10 +139,10 @@ void VolumeEntry::init(void *vp)
|
|||||||
|
|
||||||
FileEntry *VolumeEntry::fileAtIndex(unsigned i) const
|
FileEntry *VolumeEntry::fileAtIndex(unsigned i) const
|
||||||
{
|
{
|
||||||
return i < _files.length() ? _files[i] : NULL;
|
return i < _files.size() ? _files[i] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark FileEntry
|
#pragma mark FileEntry
|
||||||
@ -356,4 +356,6 @@ void TextFile::init()
|
|||||||
_fileSize += size;
|
_fileSize += size;
|
||||||
_pageSize.push_back(size);
|
_pageSize.push_back(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace ProFUSE {
|
namespace ProFUSE {
|
||||||
class BlockDevice;
|
class BlockDevice;
|
||||||
};
|
}
|
||||||
|
|
||||||
namespace Pascal {
|
namespace Pascal {
|
||||||
|
|
||||||
@ -19,9 +19,10 @@ public:
|
|||||||
|
|
||||||
virtual ~Entry();
|
virtual ~Entry();
|
||||||
|
|
||||||
|
unsigned blocks() const { return _firstBlock - _lastBlock; }
|
||||||
|
|
||||||
unsigned firstBlock() const { return _firstBlock; }
|
unsigned firstBlock() const { return _firstBlock; }
|
||||||
unsigned lastBlock() const { return _lastBlock; }
|
unsigned lastBlock() const { return _lastBlock; }
|
||||||
unsigned blocks() const { return _firstBlock - lastBlock; }
|
|
||||||
|
|
||||||
unsigned fileKind() const { return _fileKind; }
|
unsigned fileKind() const { return _fileKind; }
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ protected:
|
|||||||
unsigned _fileKind;
|
unsigned _fileKind;
|
||||||
|
|
||||||
unsigned _inode;
|
unsigned _inode;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
class VolumeEntry : public Entry {
|
class VolumeEntry : public Entry {
|
||||||
@ -50,18 +51,21 @@ public:
|
|||||||
virtual ~VolumeEntry();
|
virtual ~VolumeEntry();
|
||||||
|
|
||||||
const char *name() const { return _fileName; }
|
const char *name() const { return _fileName; }
|
||||||
unsigned fileCount() const { return _numberFiles; }
|
unsigned fileCount() const { return _fileCount; }
|
||||||
|
|
||||||
Pascal::DateRec lastBoot() const { return _lastBoot; }
|
Pascal::DateRec lastBoot() const { return _lastBoot; }
|
||||||
|
|
||||||
FileEntry *fileAtIndex(unsigned i) const;
|
FileEntry *fileAtIndex(unsigned i) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
VolumeEntry();
|
||||||
|
|
||||||
|
void init(void *);
|
||||||
|
|
||||||
unsigned _fileNameLength;
|
unsigned _fileNameLength;
|
||||||
char _fileName[8];
|
char _fileName[8];
|
||||||
unsigned _lastVolumeBlock;
|
unsigned _lastVolumeBlock;
|
||||||
unsigned _numberFiles;
|
unsigned _fileCount;
|
||||||
unsigned _accessTime;
|
unsigned _accessTime;
|
||||||
Pascal::DateRec _lastBoot;
|
Pascal::DateRec _lastBoot;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user