// // BehaviacFileManager.hpp // redream_runtime_mac // // Created by zhu on 2023/2/14. // #ifndef BehaviacFileManager_hpp #define BehaviacFileManager_hpp #include "behaviac/common/file/filemanager.h" namespace behaviac { class BEHAVIAC_API BehaviacFileManager : public behaviac::CFileManager { public: BEHAVIAC_DECLARE_MEMORY_OPERATORS(BehaviacFileManager); BehaviacFileManager(); virtual ~BehaviacFileManager(); virtual behaviac::IFile* FileOpen(const char* fileName, behaviac::CFileSystem::EOpenMode iOpenAccess = behaviac::CFileSystem::EOpenMode_Read); virtual void FileClose(behaviac::IFile* file); virtual bool FileExists(const char* fileName); virtual uint64_t FileGetSize(const char* fileName); void setRootPath(std::string path); private: std::string _rootPath; }; class BEHAVIAC_API CCBehaviacFile : public behaviac::IFile { public: BEHAVIAC_DECLARE_MEMORY_OPERATORS(CCBehaviacFile); BEHAVIAC_DECLARE_DYNAMIC_TYPE(CCBehaviacFile, IFile); public: CCBehaviacFile(const char* filePath, uint32_t size, const uint8_t* data); ~CCBehaviacFile(); virtual uint32_t Read(void* pBuffer, uint32_t numberOfBytesToRead) override; virtual uint32_t Write(const void* pBuffer, uint32_t numberOfBytesToWrite) override; virtual int64_t Seek(int64_t distanceToMove, behaviac::CFileSystem::ESeekMode moveMethod) override; virtual uint64_t GetSize() override; private: std::string _filePath; std::vector _buffer; uint32_t _bufferSize = 0; uint32_t _currentPosition = 0; }; }; #endif /* BehaviacFileManager_hpp */