Files
Aerofoil/PortabilityLayer/ResourceManager.h

68 lines
1.7 KiB
C
Raw Normal View History

2019-11-11 00:11:59 -05:00
#pragma once
#include "VirtualDirectory.h"
#include "PLErrorCodes.h"
2019-12-29 23:14:37 -05:00
#include "PLHandle.h"
2019-11-11 00:11:59 -05:00
class PLPasStr;
namespace PortabilityLayer
{
class IOStream;
2019-11-11 00:11:59 -05:00
struct MMHandleBlock;
2019-12-29 22:12:11 -05:00
struct ResourceCompiledRef;
2020-01-04 01:19:01 -05:00
class ResourceFile;
2019-11-11 00:11:59 -05:00
class ResTypeID;
class ZipFileProxy;
struct ResourceArchiveRef
{
ResourceArchiveRef();
MMHandleBlock *m_handle;
size_t m_size;
int16_t m_resID;
};
class ResourceArchive final
{
public:
static ResourceArchive *Create(ZipFileProxy *zipFileProxy, IOStream *stream);
void Destroy();
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
private:
ResourceArchive(ZipFileProxy *zipFileProxy, IOStream *stream, ResourceArchiveRef *resourceHandles);
~ResourceArchive();
ZipFileProxy *m_zipFileProxy;
IOStream *m_stream;
ResourceArchiveRef *m_resourceHandles;
};
2019-11-11 00:11:59 -05:00
class ResourceManager
{
public:
virtual void Init() = 0;
virtual void Shutdown() = 0;
virtual void SetResLoad(bool load) = 0;
virtual ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const = 0;
2019-12-29 06:38:18 -05:00
virtual short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
2019-12-29 22:12:11 -05:00
virtual void CloseResFile(short ref) = 0;
virtual PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
2019-12-29 22:12:11 -05:00
2019-12-29 23:14:37 -05:00
virtual THandle<void> GetResource(const ResTypeID &resType, int id) = 0;
2019-11-11 00:11:59 -05:00
virtual short GetCurrentResFile() const = 0;
virtual void SetCurrentResFile(short ref) = 0;
2019-12-29 22:12:11 -05:00
virtual void DissociateHandle(MMHandleBlock *hdl) const = 0;
virtual const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const = 0;
2019-12-29 22:12:11 -05:00
2019-11-11 00:11:59 -05:00
static ResourceManager *GetInstance();
};
}