26constexpr int kDefaultBlockSize = 4096;
47 throw std::runtime_error(
"Cannot tell position counter in '" +
fUrl +
48 "', error: " + std::string(strerror(errno)));
57 throw std::runtime_error(
"Cannot open '" +
fUrl +
"', error: " + std::string(strerror(errno)));
59 int res = setvbuf(
fFilePtr,
nullptr, _IONBF, 0);
61 if (
fOptions.fBlockSize == ROptions::kUseDefaultBlockSize)
62 fOptions.fBlockSize = kDefaultBlockSize;
67 Seek(offset, SEEK_SET);
68 size_t res = fread(buffer, 1, nbytes,
fFilePtr);
69 if ((res < nbytes) && (ferror(
fFilePtr) != 0)) {
71 throw std::runtime_error(
"Cannot read from '" +
fUrl +
"', error: " + std::string(strerror(errno)));
78 int res = fseek(
fFilePtr, offset, whence);
80 throw std::runtime_error(
"Cannot seek in '" +
fUrl +
"', error: " + std::string(strerror(errno)));
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
RRawFileWin(std::string_view url, RRawFile::ROptions options)
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.
std::uint64_t GetSizeImpl() final
Derived classes should return the file size.
void Seek(long offset, int whence)
void OpenImpl() final
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
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)
std::uint64_t fFilePos
The current position in the file, which can be changed by Seek, Read, and Readln.
On construction, an ROptions parameter can customize the RRawFile behavior.