2021-04-20 18:29:03 +00:00
|
|
|
#include <IO/ReadBufferFromFileDecorator.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-06-02 15:03:25 +00:00
|
|
|
ReadBufferFromFileDecorator::ReadBufferFromFileDecorator(std::unique_ptr<SeekableReadBuffer> impl_)
|
2021-10-21 12:17:43 +00:00
|
|
|
: ReadBufferFromFileDecorator(std::move(impl_), "")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ReadBufferFromFileDecorator::ReadBufferFromFileDecorator(std::unique_ptr<SeekableReadBuffer> impl_, const String & file_name_)
|
|
|
|
: impl(std::move(impl_)), file_name(file_name_)
|
2021-04-20 18:29:03 +00:00
|
|
|
{
|
|
|
|
swap(*impl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string ReadBufferFromFileDecorator::getFileName() const
|
|
|
|
{
|
2021-10-21 12:17:43 +00:00
|
|
|
if (!file_name.empty())
|
|
|
|
return file_name;
|
2021-06-08 12:00:28 +00:00
|
|
|
if (ReadBufferFromFileBase * buffer = dynamic_cast<ReadBufferFromFileBase *>(impl.get()))
|
2021-06-02 15:03:25 +00:00
|
|
|
return buffer->getFileName();
|
|
|
|
return std::string();
|
2021-04-20 18:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
off_t ReadBufferFromFileDecorator::getPosition()
|
|
|
|
{
|
|
|
|
swap(*impl);
|
|
|
|
auto position = impl->getPosition();
|
|
|
|
swap(*impl);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
off_t ReadBufferFromFileDecorator::seek(off_t off, int whence)
|
|
|
|
{
|
|
|
|
swap(*impl);
|
|
|
|
auto result = impl->seek(off, whence);
|
|
|
|
swap(*impl);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ReadBufferFromFileDecorator::nextImpl()
|
|
|
|
{
|
|
|
|
swap(*impl);
|
|
|
|
auto result = impl->next();
|
|
|
|
swap(*impl);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|