Addition to prev. revision [#METR-9578].

This commit is contained in:
Alexey Milovidov 2014-01-03 06:31:32 +00:00
parent 5d7fb8ecce
commit af3d957de1
4 changed files with 10 additions and 8 deletions

View File

@ -16,8 +16,9 @@ private:
std::string file_name;
public:
ReadBufferFromFile(const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = NULL)
: ReadBufferFromFileDescriptor(-1, buf_size, existing_memory), file_name(file_name_)
ReadBufferFromFile(const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
char * existing_memory = NULL, size_t alignment = 0)
: ReadBufferFromFileDescriptor(-1, buf_size, existing_memory, alignment), file_name(file_name_)
{
fd = open(file_name.c_str(), O_RDONLY);

View File

@ -55,8 +55,8 @@ protected:
}
public:
ReadBufferFromFileDescriptor(int fd_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = NULL)
: BufferWithOwnMemory<ReadBuffer>(buf_size, existing_memory), fd(fd_), pos_in_file(0) {}
ReadBufferFromFileDescriptor(int fd_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = NULL, size_t alignment = 0)
: BufferWithOwnMemory<ReadBuffer>(buf_size, existing_memory, alignment), fd(fd_), pos_in_file(0) {}
int getFD()
{

View File

@ -18,8 +18,9 @@ private:
std::string file_name;
public:
WriteBufferFromFile(const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1, mode_t mode = 0666)
: WriteBufferFromFileDescriptor(-1, buf_size), file_name(file_name_)
WriteBufferFromFile(const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1, mode_t mode = 0666,
char * existing_memory = NULL, size_t alignment = 0)
: WriteBufferFromFileDescriptor(-1, buf_size, existing_memory, alignment), file_name(file_name_)
{
fd = open(file_name.c_str(), flags == -1 ? O_WRONLY | O_TRUNC | O_CREAT : flags, mode);

View File

@ -46,8 +46,8 @@ protected:
}
public:
WriteBufferFromFileDescriptor(int fd_ = -1, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, size_t alignment = 0)
: BufferWithOwnMemory<WriteBuffer>(buf_size, NULL, alignment), fd(fd_) {}
WriteBufferFromFileDescriptor(int fd_ = -1, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = NULL, size_t alignment = 0)
: BufferWithOwnMemory<WriteBuffer>(buf_size, existing_memory, alignment), fd(fd_) {}
/** Можно вызывать для инициализации, если нужный fd не был передан в конструктор.
* Менять fd во время работы нельзя.