summaryrefslogtreecommitdiff
path: root/include/egg/core/eggArchive.h
blob: 69e8ec01b9e7ab755640d4c6f895468302dc5f86 (plain)
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
#ifndef EGG_ARCHIVE_H
#define EGG_ARCHIVE_H

#include "common.h"
#include "egg/core/eggDisposer.h"
#include "rvl/ARC.h"  // IWYU pragma: export
#include "rvl/NAND.h" // IWYU pragma: export


typedef void (*FileCallbackFunc)(void *, void *, const ARCDirEntry *, const char *);

namespace EGG {

class Archive : public Disposer {
public:
    struct FileInfo {
        u32 mArcStartOffset;
        u32 mArcLength;
    };
    enum MountType { // enum name is correct, values arent official
        MOUNT_NONE,
        MOUNT_MEM,
        MOUNT_NAND,
    };
    /* 0x10 */ MountType mMountType;
    /* 0x14 */ u32 mRefCount;
    /* 0x18 */ ARCHandle mHandle;
    /* 0x34 */ s32 mDvdEntryNum;        // gets put into first param of DVDFastOpen
    /* 0x38 */ NANDFileInfo *mNandFile; // pointer to NANDFileInfo (was allocated)
    /* 0x3C */ nw4r::ut::Node mLink;

public:
    virtual ~Archive();

public:
    Archive();
    bool initHandle(void *data, MountType mountType);
    static Archive *findArchive(void *data);
    static Archive *findArchive(NANDFileInfo *file);
    static Archive *mount(void *data, Heap *pHeap, int align);
    static Archive *mountFST(void *data, Heap *pHeap, int align);          // name assumed
    static Archive *mountNAND(NANDFileInfo *, Heap *pHeap, int align);     // name assumed
    static Archive *loadFST(const char *fileName, Heap *pHeap, int align); // name assumed
    void unmount();
    void *getFile(const char *name, FileInfo *out);
    s32 convertPathToEntryID(const char *path);
    void *getFileFast(s32 entryId, FileInfo *fileinfo);
    void *getFileFast(s32 entryId, Heap *pHeap, int align);
    s32 countFile();
    void searchInside(FileCallbackFunc, void *);

    static void *loadNAND(NANDFileInfo *fileInfo, Heap *pHeap, int align);

    static nw4r::ut::List sArchiveList;

private:
    static bool sIsArchiveListInitialized;
    static void appendList(Archive *);
    static void removeList(Archive *);
};
} // namespace EGG

#endif