24constexpr int kDefaultBlockSize = 128 * 1024;
52 if (fFileDes->fd !=
nullptr)
53 fFileDes->pos.close(fFileDes->fd,
nullptr);
58 return std::make_unique<RRawFileDavix>(fUrl, fOptions);
64 Davix::DavixError *err =
nullptr;
65 if (fFileDes->pos.stat(
nullptr, fUrl, &buf, &err) == -1) {
66 throw std::runtime_error(
"Cannot determine size of '" + fUrl +
"', error: " + err->getErrMsg());
73 Davix::DavixError *err =
nullptr;
74 fFileDes->fd = fFileDes->pos.open(
nullptr, fUrl, O_RDONLY, &err);
75 if (fFileDes->fd ==
nullptr) {
76 throw std::runtime_error(
"Cannot open '" + fUrl +
"', error: " + err->getErrMsg());
78 if (fOptions.fBlockSize == ROptions::kUseDefaultBlockSize)
79 fOptions.fBlockSize = kDefaultBlockSize;
84 Davix::DavixError *err =
nullptr;
85 auto retval = fFileDes->pos.pread(fFileDes->fd, buffer, nbytes,
offset, &err);
87 throw std::runtime_error(
"Cannot read from '" + fUrl +
"', error: " + err->getErrMsg());
89 return static_cast<size_t>(retval);
94 Davix::DavixError *davixErr = NULL;
95 std::vector<Davix::DavIOVecInput> in(nReq);
96 std::vector<Davix::DavIOVecOuput> out(nReq);
98 for (
unsigned int i = 0; i < nReq; ++i) {
99 in[i].diov_buffer = ioVec[i].
fBuffer;
100 in[i].diov_offset = ioVec[i].
fOffset;
101 in[i].diov_size = ioVec[i].
fSize;
105 auto ret = fFileDes->pos.preadVec(fFileDes->fd, in.data(), out.data(), nReq, &davixErr);
107 throw std::runtime_error(
"Cannot do vector read from '" + fUrl +
"', error: " + davixErr->getErrMsg());
110 for (
unsigned int i = 0; i < nReq; ++i) {
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
void ReadVImpl(RIOVec *ioVec, unsigned int nReq) final
By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX impleme...
size_t ReadAtImpl(void *buffer, size_t nbytes, std::uint64_t offset) final
Derived classes should implement low-level reading without buffering.
std::unique_ptr< RRawFile > Clone() const final
Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
RRawFileDavix(std::string_view url, RRawFile::ROptions options)
std::uint64_t GetSizeImpl() final
Derived classes should return the file size.
void OpenImpl() final
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
The RRawFile provides read-only access to local and remote files.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
RDavixFileDes(const RDavixFileDes &)=delete
RDavixFileDes & operator=(const RDavixFileDes &)=delete
Used for vector reads from multiple offsets into multiple buffers.
std::size_t fOutBytes
The number of actually read bytes, set by ReadV()
std::size_t fSize
The number of desired bytes.
void * fBuffer
The destination for reading.
std::uint64_t fOffset
The file offset.
On construction, an ROptions parameter can customize the RRawFile behavior.