git-svn-id: https://profuse.googlecode.com/svn/branches/v2@135 aa027e90-d47c-11dd-86d7-074df07e0730

This commit is contained in:
ksherlock 2009-12-10 02:04:54 +00:00
parent 2675797136
commit 982b754713
3 changed files with 29 additions and 16 deletions

7
auto.h
View File

@ -17,6 +17,13 @@ public:
operator T*() const { return _t; }
T& operator[](int index) { return _t[index]; }
void reset(T *t)
{
if (t == _t) return;
if (_t) delete[] _t;
_t = t;
}
private:
T *_t;
};

View File

@ -48,7 +48,7 @@ VolumeEntry::VolumeEntry()
_fileNameLength = 0;
std::memset(_fileName, 0, 8);
_lastVolumeBlock = 0;
_numberOfFiles = 0;
_fileCount = 0;
_accessTime = 0;
setInode(1);
@ -65,7 +65,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
device->read(2, buffer.get());
init(tmp);
init(buffer.get());
// todo -- verify reasonable values.
blockCount = blocks();
@ -84,7 +84,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
try
{
for (unsigned i = 1; i < _numberFiles; ++i)
for (unsigned i = 1; i < _fileCount; ++i)
{
std::auto_ptr<FileEntry> child;
@ -96,7 +96,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
}
catch (...)
{
std::vector<FileEntry *>iterator iter;
std::vector<FileEntry *>::iterator iter;
for(iter = _files.begin(); iter != _files.end(); ++iter)
{
if (*iter) delete *iter;
@ -109,7 +109,7 @@ VolumeEntry::VolumeEntry(ProFUSE::BlockDevice *device)
VolumeEntry::~VolumeEntry()
{
std::vector<FileEntry *>iterator iter;
std::vector<FileEntry *>::iterator iter;
for(iter = _files.begin(); iter != _files.end(); ++iter)
{
if (*iter) delete *iter;
@ -128,9 +128,9 @@ void VolumeEntry::init(void *vp)
std::memcpy(_fileName, 7 + (uint8_t *)vp, _fileNameLength);
_lastVolumeBlock = Read16(vp, 0x0e);
_numberFile = Read16(vp, 0x10);
_fileCount = Read16(vp, 0x10);
_accessTime = Read16(vp, 0x12);
_bootDate = DateRec(Read16(vp, 0x14);
_lastBoot = DateRec(Read16(vp, 0x14));
setInode(1);
_inodeGenerator = 1;
@ -139,10 +139,10 @@ void VolumeEntry::init(void *vp)
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 FileEntry
@ -356,4 +356,6 @@ void TextFile::init()
_fileSize += size;
_pageSize.push_back(size);
}
}
}
#endif

View File

@ -7,7 +7,7 @@
namespace ProFUSE {
class BlockDevice;
};
}
namespace Pascal {
@ -19,9 +19,10 @@ public:
virtual ~Entry();
unsigned blocks() const { return _firstBlock - _lastBlock; }
unsigned firstBlock() const { return _firstBlock; }
unsigned lastBlock() const { return _lastBlock; }
unsigned blocks() const { return _firstBlock - lastBlock; }
unsigned fileKind() const { return _fileKind; }
@ -39,7 +40,7 @@ protected:
unsigned _fileKind;
unsigned _inode;
}
};
class VolumeEntry : public Entry {
@ -50,18 +51,21 @@ public:
virtual ~VolumeEntry();
const char *name() const { return _fileName; }
unsigned fileCount() const { return _numberFiles; }
unsigned fileCount() const { return _fileCount; }
Pascal::DateRec lastBoot() const { return _lastBoot; }
FileEntry *fileAtIndex(unsigned i) const;
private:
VolumeEntry();
void init(void *);
unsigned _fileNameLength;
char _fileName[8];
unsigned _lastVolumeBlock;
unsigned _numberFiles;
unsigned _fileCount;
unsigned _accessTime;
Pascal::DateRec _lastBoot;