48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#ifndef __FISHBONE_RESOURCE_H__
|
|
#define __FISHBONE_RESOURCE_H__
|
|
|
|
#include <fishbone/pre.h>
|
|
|
|
namespace fishbone {
|
|
class Resource;
|
|
class BaseEngine;
|
|
}; // 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;
|
|
};
|
|
|
|
class Resource {
|
|
char* buffer;
|
|
size_t bufferSize;
|
|
|
|
public:
|
|
fishbone::File* open(std::string path);
|
|
|
|
Resource(BaseEngine* engine, std::string path);
|
|
~Resource();
|
|
|
|
char* getBuffer();
|
|
size_t getSize();
|
|
};
|
|
}; // namespace fishbone
|
|
|
|
#endif
|