1#pragma once
2
3#include <string>
4#include <fcntl.h>
5
6#include <IO/WriteBuffer.h>
7#include <IO/BufferWithOwnMemory.h>
8
9namespace DB
10{
11
12class WriteBufferFromFileBase : public BufferWithOwnMemory<WriteBuffer>
13{
14public:
15 WriteBufferFromFileBase(size_t buf_size, char * existing_memory, size_t alignment);
16 ~WriteBufferFromFileBase() override = default;
17
18 off_t seek(off_t off, int whence = SEEK_SET);
19 void truncate(off_t length = 0);
20 virtual off_t getPositionInFile() = 0;
21 void sync() override = 0;
22 virtual std::string getFileName() const = 0;
23 virtual int getFD() const = 0;
24
25protected:
26 virtual off_t doSeek(off_t off, int whence) = 0;
27 virtual void doTruncate(off_t length) = 0;
28};
29
30}
31