fishbowl/engine/include/fishbone/resource.h

48 lines
1.1 KiB
C
Raw Normal View History

#ifndef __FISHBONE_RESOURCE_H__
#define __FISHBONE_RESOURCE_H__
2026-05-30 22:41:58 +09:00
2026-06-01 13:50:35 +09:00
#include <fishbone/pre.h>
2026-05-30 22:41:58 +09:00
namespace fishbone {
class Resource;
class BaseEngine;
2026-05-30 22:41:58 +09:00
}; // namespace fishbone
#include <fishbone/file.h>
namespace fishbone {
class ResourceResolver {
public:
virtual bool exists(std::string path) = 0;
virtual size_t getSize(std::string path) = 0;
virtual bool copyData(std::string path, char* buffer, size_t maxSize) = 0;
};
class DirectoryResourceResolver : public ResourceResolver {
std::vector<std::string> searchPaths;
std::string findAbsolutePath(std::string path);
public:
DirectoryResourceResolver(std::vector<std::string> searchPaths);
bool exists(std::string path) override;
size_t getSize(std::string path) override;
bool copyData(std::string path, char* buffer, size_t maxSize) override;
};
2026-05-30 22:41:58 +09:00
class Resource {
char* buffer;
size_t bufferSize;
2026-05-30 22:41:58 +09:00
public:
fishbone::File* open(std::string path);
Resource(BaseEngine* engine, std::string path);
2026-05-30 22:41:58 +09:00
~Resource();
char* getBuffer();
size_t getSize();
2026-05-30 22:41:58 +09:00
};
}; // namespace fishbone
#endif