/* */ #ifndef _D_ABSTRACT_DISK_WRITER_H_ #define _D_ABSTRACT_DISK_WRITER_H_ #include "DiskWriter.h" #include "FileAllocator.h" #include "Logger.h" class AbstractDiskWriter : public DiskWriter { protected: string filename; int32_t fd; FileAllocatorHandle fileAllocator; const Logger* logger; void createFile(const string& filename, int32_t addFlags = 0); private: int32_t writeDataInternal(const char* data, int32_t len); int32_t readDataInternal(char* data, int32_t len); void seek(int64_t offset); public: AbstractDiskWriter(); virtual ~AbstractDiskWriter(); virtual void openFile(const string& filename, int64_t totalLength = 0); virtual void closeFile(); virtual void openExistingFile(const string& filename); #ifdef ENABLE_MESSAGE_DIGEST virtual string messageDigest(int64_t offset, int64_t length, const MessageDigestContext::DigestAlgo& algo); #endif // ENABLE_MESSAGE_DIGEST virtual void writeData(const char* data, int32_t len, int64_t offset); virtual int32_t readData(char* data, int32_t len, int64_t offset); void setFileAllocator(const FileAllocatorHandle& fileAllocator) { this->fileAllocator = fileAllocator; } }; #endif // _D_ABSTRACT_DISK_WRITER_H_