-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPakItem.cpp
executable file
·69 lines (56 loc) · 1.3 KB
/
CPakItem.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
/*
CFileArchiveItem.cpp
Author: Tom Naughton
Description: <describe the CFileArchiveItem class here>
*/
#include "CFileArchive.h"
#include "CFileArchiveItem.h"
#include "utilities.h"
CFileArchiveItem::CFileArchiveItem(FSSpec inFileSpec)
{
LFileStream *file = new LFileStream(inFileSpec);
file->OpenDataFork(fsRdWrPerm);
long pakSize = file->GetLength();
char *pakData = (char*)malloc(pakSize);
file->GetBytes(pakData, pakSize);
file->CloseDataFork();
delete file;
_pak = nil;
_name = p2cstr(inFileSpec.name);
_index = -1;
_data = pakData;
_size = pakSize;
}
CFileArchiveItem::CFileArchiveItem(CFileArchive *inPak, string inName, long inIndex, char *inData, long inSize)
{
_pak = inPak;
_name = inName;
_index = inIndex;
_data = inData;
_size = inSize;
}
CFileArchiveItem::~CFileArchiveItem()
{
}
string CFileArchiveItem::pathName()
{
string path;
if (_pak)
path += _pak->pathName();
path += _name;
dprintf("CFileArchiveItem::pathName %s\n", path.c_str());
return path;
}
static char _pTitle[1024];
StringPtr CFileArchiveItem::itemTitle()
{
string title = pathName();
strcpy(_pTitle, title.c_str());
return (StringPtr) c2pstr(_pTitle);
}
string CFileArchiveItem::dataType()
{
string package, file, extension;
decomposeEntryName(_name, package, file, extension);
return extension;
}