mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 23:00:42 +00:00
File system refactor, bug fixes
This commit is contained in:
@@ -16,6 +16,7 @@ namespace PortabilityLayer
|
||||
class ResourceFile;
|
||||
class ResTypeID;
|
||||
class ZipFileProxy;
|
||||
class CompositeFile;
|
||||
|
||||
struct ResourceArchiveRef
|
||||
{
|
||||
@@ -42,52 +43,10 @@ namespace PortabilityLayer
|
||||
static const char *GetFileExtensionForResType(const ResTypeID &resTypeID, int &outValidationRule);
|
||||
};
|
||||
|
||||
class ResourceArchiveDirectory final : public ResourceArchiveBase
|
||||
{
|
||||
public:
|
||||
static ResourceArchiveDirectory *Create(VirtualDirectory_t directory, const PLPasStr &subdirectory);
|
||||
void Destroy() override;
|
||||
|
||||
THandle<void> LoadResource(const ResTypeID &resTypeID, int id) override;
|
||||
|
||||
bool HasAnyResourcesOfType(const ResTypeID &resTypeID) const override;
|
||||
bool FindFirstResourceOfType(const ResTypeID &resTypeID, int16_t &outID) const override;
|
||||
|
||||
bool Init();
|
||||
|
||||
private:
|
||||
ResourceArchiveDirectory(VirtualDirectory_t directory, const PLPasStr &subdirectory);
|
||||
~ResourceArchiveDirectory();
|
||||
|
||||
struct ResTypeEntry
|
||||
{
|
||||
int32_t m_resTypeID;
|
||||
size_t m_firstRes;
|
||||
size_t m_lastRes;
|
||||
};
|
||||
|
||||
bool IndexResource(const ResTypeID &resTypeID, int id, size_t &outIndex) const;
|
||||
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
||||
|
||||
static int ResTypeSearchPredicate(int32_t resTypeID, const ResTypeEntry &entry);
|
||||
static int ResIDSearchPredicate(int16_t resTypeID, int16_t entry);
|
||||
static bool ResTypeEntrySortPredicate(const ResTypeEntry &a, const ResTypeEntry &b);
|
||||
|
||||
VirtualDirectory_t m_directory;
|
||||
char m_subdirectory[256];
|
||||
|
||||
THandle<ResTypeEntry> m_resTypes;
|
||||
size_t m_numResourceTypes;
|
||||
|
||||
THandle<int16_t> m_resIDs;
|
||||
ResourceArchiveRef *m_resourceHandles;
|
||||
size_t m_numResources;
|
||||
};
|
||||
|
||||
class ResourceArchiveZipFile final : public ResourceArchiveBase
|
||||
{
|
||||
public:
|
||||
static ResourceArchiveZipFile *Create(ZipFileProxy *zipFileProxy, GpIOStream *stream);
|
||||
static ResourceArchiveZipFile *Create(ZipFileProxy *zipFileProxy, bool proxyIsShared, GpIOStream *stream);
|
||||
void Destroy() override;
|
||||
|
||||
THandle<void> LoadResource(const ResTypeID &resTypeID, int id) override;
|
||||
@@ -96,7 +55,7 @@ namespace PortabilityLayer
|
||||
bool FindFirstResourceOfType(const ResTypeID &resTypeID, int16_t &outID) const override;
|
||||
|
||||
private:
|
||||
ResourceArchiveZipFile(ZipFileProxy *zipFileProxy, GpIOStream *stream, ResourceArchiveRef *resourceHandles);
|
||||
ResourceArchiveZipFile(ZipFileProxy *zipFileProxy, bool proxyIsShared, GpIOStream *stream, ResourceArchiveRef *resourceHandles);
|
||||
~ResourceArchiveZipFile();
|
||||
|
||||
bool IndexResource(const ResTypeID &resTypeID, int id, size_t &outIndex, int &outValidationRule) const;
|
||||
@@ -104,8 +63,9 @@ namespace PortabilityLayer
|
||||
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
||||
|
||||
ZipFileProxy *m_zipFileProxy;
|
||||
GpIOStream *m_stream;
|
||||
GpIOStream *m_stream; // This may be null, i.e. a composite file may own it instead
|
||||
ResourceArchiveRef *m_resourceHandles;
|
||||
bool m_proxyIsShared;
|
||||
};
|
||||
|
||||
class ResourceManager
|
||||
@@ -117,7 +77,7 @@ namespace PortabilityLayer
|
||||
virtual THandle<void> GetAppResource(const ResTypeID &resTypeID, int16_t resID) const = 0;
|
||||
virtual IResourceArchive *GetAppResourceArchive() const = 0;
|
||||
|
||||
virtual IResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const = 0;
|
||||
virtual IResourceArchive *LoadResFile(CompositeFile *file) const = 0;
|
||||
virtual PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||
|
||||
virtual void DissociateHandle(MMHandleBlock *hdl) const = 0;
|
||||
|
Reference in New Issue
Block a user