| 1 | #pragma once |
| 2 | |
| 3 | #include <prim/seadSafeString.hpp> |
| 4 | #include <thread/seadCriticalSection.h> |
| 5 | |
| 6 | namespace sead { |
| 7 | class ArchiveRes; |
| 8 | struct DirectoryEntry; |
| 9 | class FileDevice; |
| 10 | } // namespace sead |
| 11 | |
| 12 | namespace al { |
| 13 | class ArchiveEntry; |
| 14 | class ArchiveHolder; |
| 15 | class ByamlIter; |
| 16 | class FileEntryBase; |
| 17 | class FileLoaderThread; |
| 18 | class IAudioResourceLoader; |
| 19 | class SoundItemEntry; |
| 20 | class SoundItemHolder; |
| 21 | |
| 22 | class FileLoader { |
| 23 | public: |
| 24 | FileLoader(s32 threadPriority); |
| 25 | |
| 26 | static u32 listSubdirectories(sead::FixedSafeString<256> out[], s32 outSize, const char* path); |
| 27 | static u32 listFiles(sead::FixedSafeString<256> out[], s32 outSize, const char* path, |
| 28 | const char* suffix); |
| 29 | |
| 30 | bool isExistFile(const sead::SafeString& path, sead::FileDevice* device) const; |
| 31 | sead::FileDevice* getFileDevice(const sead::SafeString& path, sead::FileDevice* device) const; |
| 32 | bool isExistArchive(const sead::SafeString& path, sead::FileDevice* device) const; |
| 33 | bool isExistDirectory(const sead::SafeString& path, sead::FileDevice* device) const; |
| 34 | u32 getFileSize(const sead::SafeString& path, sead::FileDevice* device) const; |
| 35 | u8* loadFile(const sead::SafeString&, s32, sead::FileDevice*); |
| 36 | bool tryLoadFileToBuffer(const sead::SafeString& path, u8* buffer, u32 bufferSize, |
| 37 | s32 alignment, sead::FileDevice* device); |
| 38 | sead::ArchiveRes* loadArchive(const sead::SafeString& path, sead::FileDevice* device); |
| 39 | sead::ArchiveRes* loadArchiveLocal(const sead::SafeString& path, const char* suffix, |
| 40 | sead::FileDevice* device); |
| 41 | sead::ArchiveRes* loadArchiveWithExt(const sead::SafeString& path, const char* suffix, |
| 42 | sead::FileDevice* device); |
| 43 | bool tryRequestLoadArchive(const sead::SafeString& path, sead::Heap* heap, |
| 44 | sead::FileDevice* device); |
| 45 | ArchiveEntry* requestLoadArchive(const sead::SafeString& path, sead::Heap* heap, |
| 46 | sead::FileDevice* device); |
| 47 | // TODO: unknown parameter name |
| 48 | bool loadSoundItem(u32 itemId, u32 unknown, IAudioResourceLoader* loader); |
| 49 | // TODO: unknown parameter name |
| 50 | SoundItemEntry* requestLoadSoundItem(u32 itemId, u32 unknown, IAudioResourceLoader* loader); |
| 51 | bool tryRequestLoadSoundItem(u32 itemId, IAudioResourceLoader* loader); |
| 52 | void requestPreLoadFile(const ByamlIter& preLoadList, sead::Heap* heap, |
| 53 | IAudioResourceLoader* loader); |
| 54 | void waitLoadDoneAllFile(); |
| 55 | void clearAllEntry(); |
| 56 | void setThreadPriority(s32 priority); |
| 57 | |
| 58 | private: |
| 59 | FileLoaderThread* mLoaderThread = nullptr; |
| 60 | ArchiveHolder* mArchiveHolder = nullptr; |
| 61 | SoundItemHolder* mSoundItemHolder = nullptr; |
| 62 | bool mIsFilePreloaded = false; |
| 63 | sead::FileDevice* mFileDevice = nullptr; |
| 64 | sead::CriticalSection mCriticalSection; |
| 65 | }; |
| 66 | |
| 67 | static_assert(sizeof(FileLoader) == 0x68, "FileLoader size" ); |
| 68 | |
| 69 | } // namespace al |
| 70 | |