This repository has been archived by the owner on Aug 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Directory.cpp
107 lines (70 loc) · 1.94 KB
/
Directory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <cstring>
#include <memory>
#include "Entry.h"
#include "Buffer.h"
#include "Endian.h"
#include "BlockDevice.h"
#include "Exception.h"
using namespace ProFUSE;
using namespace LittleEndian;
Directory::Directory(unsigned type, const char *name) :
Entry(type, name)
{
#undef __METHOD__
#define __METHOD__ "Directory::Directory"
_access = 0xe3;
_entryLength = 0x27;
_entriesPerBlock = 13;
_fileCount = 0;
_version = 5; // ProDOS FST uses 5, ProDOS uses 0.
_minVersion = 0;
}
Directory::Directory(const void *bp) :
Entry(4 + (const uint8_t *)bp),
_creation(0, 0)
{
#undef __METHOD__
#define __METHOD__ "Directory::Directory"
// input is a block pointer. To simplify,
// create a new pointer past the 4-byte linked list part.
const void *dp = 4 + (const uint8_t *)bp;
_creation = DateTime(Read16(dp, 0x18), Read16(dp, 0x1a));
_version = Read8(dp, 0x1c);
_minVersion = Read8(dp, 0x1d);
_access = Read8(dp, 0x1e);
_entryLength = Read8(dp, 0x1f);
_entriesPerBlock = Read8(dp, 0x20);
_fileCount = Read16(dp, 0x21);
// parse child file entries ... requires ability to read other blocks.
}
Directory::~Directory()
{
}
void Directory::setAccess(unsigned access)
{
#undef __METHOD__
#define __METHOD__ "Directory::setAccess"
_access = access;
// todo -- mark dirty? update block?
}
void Directory::loadChildren(BlockDevice *device, unsigned block)
{
uint8_t buffer[512];
unsigned next;
bool first = true;
unsigned offset;
// set of already-visited blocks?
while(block)
{
device->read(block, buffer);
next = Read16(buffer, 2);
_entryBlocks.push_back(block);
offset = 4;
if (!first)
{
// storage type 0 is deleted, don't load...
}
first = false;
block = next;
}
}