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

This commit is contained in:
ksherlock 2009-12-10 02:18:05 +00:00
parent 982b754713
commit 99321a3f93
2 changed files with 64 additions and 6 deletions

View File

@ -142,7 +142,7 @@ FileEntry *VolumeEntry::fileAtIndex(unsigned i) const
return i < _files.size() ? _files[i] : NULL; return i < _files.size() ? _files[i] : NULL;
} }
#if 0
#pragma mark - #pragma mark -
#pragma mark FileEntry #pragma mark FileEntry
@ -150,10 +150,49 @@ FileEntry *VolumeEntry::fileAtIndex(unsigned i) const
FileEntry::FileEntry(void *vp) : FileEntry::FileEntry(void *vp) :
Entry(vp) Entry(vp)
{ {
_status = Read8(vp, 0x05) & 0x01;
_fileNameLength = Read8(vp, 0x06);
std::memset(_fileName, 0, 16);
std::memcpy(_fileName, 0x07 + (uint8_t *)vp, _fileNameLength);
_lastByte = Read16(vp, 0x16);
_modification = DateRec(Read16(vp, 0x18));
} }
FileEntry::~FileEntry()
{
delete _pageLength;
}
unsigned FileEntry::fileSize()
{
switch(fileKind())
{
case kTextFile:
return textFileSize();
break;
default:
return dataFileSize();
break;
}
}
int FileEntry::read(uint8_t *buffer, unsigned size, unsigned offset)
{
switch(fileKind())
{
case kTextFile:
return textRead(buffer, size, offset);
break;
default:
return dataRead(buffer, size, offset);
break;
}
}
#if 0
unsigned File::fileSize() { unsigned File::fileSize() {
return (_lastBlock - _firstBlock - 1) * 512 + _lastByte; return (_lastBlock - _firstBlock - 1) * 512 + _lastByte;
} }

View File

@ -11,6 +11,19 @@ namespace ProFUSE {
namespace Pascal { namespace Pascal {
enum {
kUntypedFile,
kBadBlockFile,
kCodeFile,
kTextFile,
kInfoFile,
kDataFile,
kGrafFile,
kFotoFile,
kSecureDir
};
class FileEntry; class FileEntry;
class Entry { class Entry {
@ -97,13 +110,19 @@ class FileEntry : public Entry {
unsigned _lastByte; unsigned _lastByte;
DateRec _modification; DateRec _modification;
// non-text files
unsigned dataFileSize();
int dataRead(uint8_t *buffer, unsigned size, unsigned offset);
// for text files. // for text files.
unsigned textFileSize();
int textRead(uint8_t *buffer, unsigned size, unsigned offset);
unsigned readTextPage(unsigned block, uint8_t *in); unsigned textReadPage(unsigned block, uint8_t *in);
unsigned decodeTextPage(unsigned block, uint8_t *out); unsigned textDecodePage(unsigned block, uint8_t *out);
std::vector<unsigned> *_pageLengths; std::vector<unsigned> *_pageLength;
unsigned _fileSize; unsigned _fileSize;
}; };