1#pragma once
2
3#include "filedevice/seadFileDevice.h"
4
5namespace sead
6{
7class ArchiveRes;
8
9class ArchiveFileDevice : public FileDevice
10{
11 SEAD_RTTI_OVERRIDE(ArchiveFileDevice, FileDevice)
12public:
13 explicit ArchiveFileDevice(ArchiveRes* archive_res);
14 ~ArchiveFileDevice() override = default;
15
16 u8* tryLoadWithEntryID(s32 id, LoadArg& arg);
17 FileDevice* tryOpenWithEntryID(FileHandle* handle, s32 id, FileOpenFlag flag, u32 div_size);
18 s32 tryConvertPathToEntryID(const SafeString& path);
19 bool setCurrentDirectory(const SafeString& dir);
20
21protected:
22 struct ArchiveFileHandle;
23
24 bool doIsAvailable_() const override { return true; }
25 u8* doLoad_(LoadArg& arg) override;
26 FileDevice* doOpen_(FileHandle* handle, const SafeString& path, FileOpenFlag flag) override;
27 bool doClose_(FileHandle* handle) override;
28 bool doFlush_(FileHandle* handle) override;
29 bool doRemove_(const SafeString& str) override;
30 bool doRead_(u32* bytesRead, FileHandle* handle, u8* outBuffer, u32 bytesToRead) override;
31 bool doWrite_(u32*, FileHandle*, const u8*, u32) override { return false; }
32 bool doSeek_(FileHandle* handle, s32 offset, SeekOrigin origin) override;
33 bool doGetCurrentSeekPos_(u32* seekPos, FileHandle* handle) override;
34 bool doGetFileSize_(u32* fileSize, const SafeString& path) override;
35 bool doGetFileSize_(u32* fileSize, FileHandle* handle) override;
36 bool doIsExistFile_(bool* exists, const SafeString& path) override;
37 bool doIsExistDirectory_(bool* exists, const SafeString& path) override;
38 FileDevice* doOpenDirectory_(DirectoryHandle* handle, const SafeString& path) override;
39 bool doCloseDirectory_(DirectoryHandle* handle) override;
40 bool doReadDirectory_(u32* entriesRead, DirectoryHandle* handle, DirectoryEntry* entry,
41 u32 entriesToRead) override;
42 bool doMakeDirectory_(const SafeString& path, u32 u_32) override;
43 s32 doGetLastRawError_() const override;
44
45 virtual u8* doLoadWithEntryID_(s32 id, LoadArg& arg);
46 virtual FileDevice* doOpenWithEntryID_(FileHandle* handle, s32 id, FileOpenFlag flag);
47 virtual s32 doConvertPathToEntryID_(const SafeString& path);
48 virtual bool doSetCurrentDirectory_(const SafeString& path);
49
50 ArchiveFileHandle* getArchiveFileHandle_(FileHandle* handle) const;
51 ArchiveFileHandle* constructArchiveFileHandle_(FileHandle* handle) const;
52
53 ArchiveRes* mArchive;
54};
55} // namespace sead
56