1#include "MultiDvdArchive.hh"
7static size_t SUFFIX_SIZE = 8;
10MultiDvdArchive::MultiDvdArchive(
u16 archiveCount) : m_archiveCount(archiveCount) {
11 m_archives =
new DvdArchive[archiveCount];
12 m_fileStarts =
new void *[archiveCount];
13 m_fileSizes =
new size_t[archiveCount];
14 m_suffixes =
new char *[archiveCount];
15 m_formats =
new Format[archiveCount];
17 for (
u16 i = 0; i < m_archiveCount; i++) {
18 m_fileStarts[i] =
nullptr;
20 m_suffixes[i] =
new char[SUFFIX_SIZE];
21 strncpy(m_suffixes[i], SZS_EXTENSION, SUFFIX_SIZE);
22 m_formats[i] = Format::Double;
27MultiDvdArchive::~MultiDvdArchive() {
30 delete[] m_fileStarts;
38void *MultiDvdArchive::getFile(
const char *filename,
size_t *size)
const {
41 for (
u16 i = m_archiveCount; i-- > 0;) {
42 const DvdArchive &archive = m_archives[i];
44 if (!archive.isLoaded()) {
48 file = archive.getFile(filename, size);
58void MultiDvdArchive::load(
const char *filename) {
61 for (
u16 i = 0; i < m_archiveCount; i++) {
62 switch (m_formats[i]) {
64 snprintf(buffer,
sizeof(buffer),
"%s%s", filename, m_suffixes[i]);
67 snprintf(buffer,
sizeof(buffer),
"%s", filename);
75 if (m_formats[i] == Format::None) {
76 m_archives[i].load(m_fileStarts[i], m_fileSizes[i],
true);
78 m_archives[i].load(buffer,
true);
84void MultiDvdArchive::load(
const MultiDvdArchive *other) {
85 for (
u16 i = 0; i < m_archiveCount; i++) {
86 m_archives[i].load(&other->m_archives[i]);
91void MultiDvdArchive::rip(
const char *filename) {
94 for (
u16 i = 0; i < m_archiveCount; i++) {
95 switch (m_formats[i]) {
97 snprintf(buffer,
sizeof(buffer),
"%s%s", filename, m_suffixes[i]);
100 snprintf(buffer,
sizeof(buffer),
"%s", filename);
107 m_archives[i].rip(buffer);
112void MultiDvdArchive::clear() {
113 for (
u16 i = 0; i < m_archiveCount; i++) {
114 m_archives[i].clear();
119void MultiDvdArchive::unmount() {
120 for (
u16 i = 0; i < m_archiveCount; i++) {
121 m_archives[i].unmount();
126bool MultiDvdArchive::isLoaded()
const {
127 for (
u16 i = 0; i < m_archiveCount; i++) {
128 if (m_archives[i].isLoaded()) {
137u16 MultiDvdArchive::rippedArchiveCount()
const {
139 for (
u16 i = 0; i < m_archiveCount; i++) {
140 if (m_archives[i].isRipped()) {
High-level handling for generic system operations, such as input reading, race configuration,...