MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / getArchive

Method getArchive

TheForceEngine/TFE_Archive/archive.cpp:40–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40Archive* Archive::getArchive(ArchiveType type, const char* name, const char* path)
41{
42 ArchiveMap::iterator iArchive = s_archives[type].find(path);
43 if (iArchive != s_archives[type].end())
44 {
45 return iArchive->second;
46 }
47 if (!FileUtil::exists(path))
48 {
49 return nullptr;
50 }
51
52 Archive* archive = nullptr;
53 switch (type)
54 {
55 case ARCHIVE_GOB:
56 {
57 archive = new GobArchive();
58 }
59 break;
60 case ARCHIVE_LFD:
61 {
62 archive = new LfdArchive();
63 }
64 break;
65 case ARCHIVE_LAB:
66 {
67 archive = new LabArchive();
68 }
69 break;
70 case ARCHIVE_ZIP:
71 {
72 archive = new ZipArchive();
73 }
74 break;
75 default:
76 assert(0);
77 break;
78 };
79
80 if (archive)
81 {
82 strcpy(archive->m_name, name);
83 if (!archive->open(path))
84 {
85 delete archive;
86 return nullptr;
87 }
88 archive->m_type = type;
89 (s_archives[type])[path] = archive;
90 }
91 return archive;
92}
93
94void Archive::freeArchive(Archive* archive)
95{

Callers

nothing calls this directly

Calls 3

existsFunction · 0.50
endMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected