63std::unique_ptr<ROOT::Internal::RRawFile>
77 "RRawFileDavix" :
"RRawFileNetXNG";
79 FindHandler(
"ROOT::Internal::RRawFile", std::string(
url).c_str())) {
80 if (
h->LoadPlugin() == 0) {
81 return std::unique_ptr<RRawFile>(
reinterpret_cast<RRawFile *
>(
h->ExecPlugin(2, &
url, &options)));
83 throw std::runtime_error(
"Cannot load plugin handler for " +
plgclass);
85 throw std::runtime_error(
"Cannot find plugin handler for " +
plgclass);
87 throw std::runtime_error(
"Unsupported transport protocol: " +
transport);
101 for (
unsigned i = 0; i <
nReq; ++i) {
109 if (idx == std::string_view::npos)
110 return std::string(
url);
116 if (fFileSize != kUnknownFileSize)
120 fFileSize = GetSizeImpl();
131 if (idx == std::string_view::npos)
140 size_t res = ReadAt(buffer,
nbytes, fFilePos);
154 if (!fIsBuffering ||
nbytes >
static_cast<unsigned int>(fOptions.fBlockSize))
158 fBufferSpace.reset(
new unsigned char[kNumBlockBuffers * fOptions.fBlockSize]);
159 for (
unsigned int i = 0; i < kNumBlockBuffers; ++i) {
160 fBlockBuffers[i].fBuffer = fBufferSpace.get() + i * fOptions.fBlockSize;
161 fBlockBuffers[i].fBufferSize = 0;
168 for (
unsigned int idx = fBlockBufferIdx; idx < fBlockBufferIdx + kNumBlockBuffers; ++idx) {
170 buffer =
reinterpret_cast<unsigned char *
>(buffer) +
copiedBytes;
175 fBlockBufferIdx = idx;
202 fIsBuffering =
value;
204 fBufferSpace.reset();
209 if (fOptions.fLineBreak == ELineBreaks::kAuto) {
211 fOptions.fLineBreak = ELineBreaks::kUnix;
212 bool res = Readln(
line);
213 if ((
line.length() > 0) && (*
line.rbegin() ==
'\r')) {
214 fOptions.fLineBreak = ELineBreaks::kWindows;
224 nbytes = Read(buffer,
sizeof(buffer));
227 if (idx != std::string_view::npos) {
229 line.append(buffer, idx);
237 return !
line.empty();
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
The RRawFileUnix class uses POSIX calls to read from a mounted file system.
The RRawFileWin class uses portable C I/O calls to read from a drive.
The RRawFile provides read-only access to local and remote files.
static std::string GetLocation(std::string_view url)
Returns only the file location, e.g. "server/file" for http://server/file.
RRawFile(std::string_view url, ROptions options)
virtual void ReadVImpl(RIOVec *ioVec, unsigned int nReq)
By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX impleme...
static std::string GetTransport(std::string_view url)
Returns only the transport protocol in lower case, e.g. "http" for HTTP://server/file.
std::uint64_t GetSize()
Returns the size of the file.
static std::unique_ptr< RRawFile > Create(std::string_view url, ROptions options=ROptions())
Factory method that returns a suitable concrete implementation according to the transport in the url.
void Seek(std::uint64_t offset)
Change the cursor fFilePos.
size_t ReadAt(void *buffer, size_t nbytes, std::uint64_t offset)
Buffered read from a random position.
bool Readln(std::string &line)
Read the next line starting from the current value of fFilePos. Returns false if the end of the file ...
void EnsureOpen()
Open the file if not already open. Otherwise noop.
void ReadV(RIOVec *ioVec, unsigned int nReq)
Opens the file if necessary and calls ReadVImpl.
size_t Read(void *buffer, size_t nbytes)
Read from fFilePos offset. Returns the actual number of bytes read.
void SetBuffering(bool value)
Turn off buffered reads; all scalar read requests go directly to the implementation.
std::string GetUrl() const
Returns the url of the file.
const_iterator begin() const
const_iterator end() const
std::uint64_t fBufferOffset
Where in the open file does fBuffer start.
unsigned char * fBuffer
Points into the I/O buffer with data from the file, not owned.
size_t CopyTo(void *buffer, size_t nbytes, std::uint64_t offset)
Tries to copy up to nbytes starting at offset from fBuffer into buffer. Returns number of bytes copie...
size_t fBufferSize
The number of currently buffered bytes in fBuffer.
Used for vector reads from multiple offsets into multiple buffers.
On construction, an ROptions parameter can customize the RRawFile behavior.