AeAssetFile.c++
1.96 KB
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
106
107
108
109
110
111
112
113
114
115
116
/*****************************************************************************
* File: AeAssetFile.c++
*
* File Manager
*
****************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <bstring.h>
#include "AeBankFile.h"
#include "AeWaveFile.h"
#include "AeInstFile.h"
#include "AeAsset.h"
AeAssetFile *
AeAssetFile::NewAssetFile (char * name)
{
AeAssetFile * file;
char * dirName;
char * fileName;
char * fileSuffix;
parseFileString (name, dirName, fileName, fileSuffix);
// current version only allows opening of .inst and .aifc files
switch (suffix2type (fileSuffix))
{
case kWaveType:
file = (AeAssetFile *)new AeWaveFile (name);
break;
case kBankFileType:
file = NULL;
break;
case kInstFileType:
default:
file = (AeAssetFile *)new AeInstFile (name);
break;
}
if (dirName) free (dirName);
if (fileName) free (fileName);
if (fileSuffix) free (fileSuffix);
return file;
}
AeAssetFile::AeAssetFile (char * name)
: AeFile (name)
{
}
AeAssetFile::~AeAssetFile()
{
}
AeErr
AeAssetFile::Read (AeAsset *&)
{
assert (False); // pure virtual function called
return kAeNoErr;
}
AeErr
AeAssetFile::ReadList (GList<AeAsset *> *&)
{
assert (False); // pure virtual function called
return kAeNoErr;
}
AeErr
AeAssetFile::Write (AeAssetBase *)
{
assert (False); // pure virtual function called
return kAeNoErr;
}
TAssetType
AeAssetFile::suffix2type (char * suffix)
{
// n64 bank files
if (strcmp (suffix, "ctl") == 0 ||
strcmp (suffix, "tbl") == 0 ||
strcmp (suffix, "sym") == 0)
{
return kBankFileType;
}
// n64 inst files
if (strcmp (suffix, "inst") == 0)
{
return kInstFileType;
}
// sound files
if (strcmp (suffix, "aifc") == 0 ||
strcmp (suffix, "aiff") == 0)
{
return kWaveType;
}
return kUnknownType;
}