22 virtual bool read(
char* buffer, int64_t size) = 0;
33 static bool write(
const char* filePath,
34 std::pair<const void*, size_t> cacheInfo);
36 bool valid()
const {
return mFile !=
nullptr; }
37 inline size_t size()
const {
return mTotalSize; }
38 inline std::string
path()
const {
return mFilePath; }
44 bool read(
char* buffer, int64_t size);
48 std::vector<std::pair<size_t, void*>> mBlocks;
49 FILE* mFile =
nullptr;
50 static const int gCacheSize = 4096;
51 size_t mTotalSize = 0;
52 std::string mFilePath;
59 virtual bool read(
char* dst, int64_t size)
override {
60 ::memcpy(dst, buffer_, size);
66 unsigned char* buffer_ =
nullptr;
virtual ~BaseLoader()=default
virtual bool read(char *buffer, int64_t size)=0
int offset(int64_t offset)
static bool write(const char *filePath, std::pair< const void *, size_t > cacheInfo)
bool read(char *buffer, int64_t size)
FileLoader(const char *file, bool init=false)
MemoryLoader(unsigned char *ptr)
virtual bool read(char *dst, int64_t size) override
#define NNDEPLOY_CC_API
api