2015-03-30 15:39:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
2015-03-30 15:39:55 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class WriteBufferFromFileBase : public BufferWithOwnMemory<WriteBuffer>
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
WriteBufferFromFileBase(size_t buf_size, char * existing_memory, size_t alignment);
|
|
|
|
virtual ~WriteBufferFromFileBase();
|
2015-04-30 15:04:42 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
off_t seek(off_t off, int whence = SEEK_SET);
|
|
|
|
void truncate(off_t length = 0);
|
|
|
|
virtual off_t getPositionInFile() = 0;
|
|
|
|
virtual void sync() = 0;
|
|
|
|
virtual std::string getFileName() const = 0;
|
|
|
|
virtual int getFD() const = 0;
|
2015-04-03 13:45:44 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual off_t doSeek(off_t off, int whence) = 0;
|
|
|
|
virtual void doTruncate(off_t length) = 0;
|
2015-03-30 15:39:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|