feat: directory-based resource resolver
This commit is contained in:
parent
15e2abbada
commit
656549f039
12 changed files with 223 additions and 11 deletions
|
|
@ -1,21 +1,47 @@
|
|||
#ifndef __FISHBONE_THREAD_H__
|
||||
#define __FISHBONE_THREAD_H__
|
||||
#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(std::string path);
|
||||
Resource(BaseEngine* engine, std::string path);
|
||||
~Resource();
|
||||
|
||||
char* getBuffer();
|
||||
size_t getSize();
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue