Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Internal::RRawFileUnix Class Reference

The RRawFileUnix class uses POSIX calls to read from a mounted file system.

Thus the path name can refer, for instance, to a named pipe instead of a regular file.

Definition at line 31 of file RRawFileUnix.hxx.

Public Member Functions

 RRawFileUnix (std::string_view url, RRawFile::ROptions options)
 
 ~RRawFileUnix () override
 
std::unique_ptr< RRawFileClone () const final
 Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
 
int GetFd () const
 
int GetFeatures () const final
 Derived classes shall inform the user about the supported functionality, which can possibly depend on the file at hand.
 
- Public Member Functions inherited from ROOT::Internal::RRawFile
 RRawFile (const RRawFile &)=delete
 
 RRawFile (std::string_view url, ROptions options)
 
virtual ~RRawFile ()
 
std::uint64_t GetFilePos () const
 Returns the offset for the next Read/Readln call.
 
virtual RIOVecLimits GetReadVLimits ()
 Returns the limits regarding the ioVec input to ReadV for this specific file; may open the file as a side-effect.
 
std::uint64_t GetSize ()
 Returns the size of the file.
 
std::string GetUrl () const
 Returns the url of the file.
 
bool IsOpen () const
 Once opened, the file stay open until destruction of the RRawFile object.
 
void * Map (size_t nbytes, std::uint64_t offset, std::uint64_t &mapdOffset)
 Memory mapping according to POSIX standard; in particular, new mappings of the same range replace older ones.
 
RRawFileoperator= (const RRawFile &)=delete
 
size_t Read (void *buffer, size_t nbytes)
 Read from fFilePos offset. Returns the actual number of bytes read.
 
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 is reached.
 
void ReadV (RIOVec *ioVec, unsigned int nReq)
 Opens the file if necessary and calls ReadVImpl.
 
void Seek (std::uint64_t offset)
 Change the cursor fFilePos.
 
void Unmap (void *region, size_t nbytes)
 Receives a pointer returned by Map() and should have nbytes set to the full length of the mapping.
 

Protected Member Functions

std::uint64_t GetSizeImpl () final
 Derived classes should return the file size or kUnknownFileSize.
 
void * MapImpl (size_t nbytes, std::uint64_t offset, std::uint64_t &mapdOffset) final
 If a derived class supports mmap, the MapImpl and UnmapImpl calls are supposed to be implemented, too The default implementation throws an error.
 
void OpenImpl () final
 OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
 
size_t ReadAtImpl (void *buffer, size_t nbytes, std::uint64_t offset) final
 Derived classes should implement low-level reading without buffering.
 
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 implementations.
 
void UnmapImpl (void *region, size_t nbytes) final
 Derived classes with mmap support must be able to unmap the memory area handed out by Map()
 
- Protected Member Functions inherited from ROOT::Internal::RRawFile
void EnsureOpen ()
 Open the file if not already open. Otherwise noop.
 

Private Attributes

int fFileDes
 

Additional Inherited Members

- Public Types inherited from ROOT::Internal::RRawFile
enum class  ELineBreaks { kAuto , kSystem , kUnix , kWindows }
 kAuto detects the line break from the first line, kSystem picks the system's default More...
 
- Static Public Member Functions inherited from ROOT::Internal::RRawFile
static std::unique_ptr< RRawFileCreate (std::string_view url, ROptions options=ROptions())
 Factory method that returns a suitable concrete implementation according to the transport in the url.
 
static std::string GetLocation (std::string_view url)
 Returns only the file location, e.g. "server/file" for http://server/file.
 
static std::string GetTransport (std::string_view url)
 Returns only the transport protocol in lower case, e.g. "http" for HTTP://server/file.
 
- Static Public Attributes inherited from ROOT::Internal::RRawFile
static constexpr int kFeatureHasAsyncIo = 0x04
 File supports async IO.
 
static constexpr int kFeatureHasMmap = 0x02
 Map() and Unmap() are implemented.
 
static constexpr int kFeatureHasSize = 0x01
 GetSize() does not return kUnknownFileSize.
 
static constexpr std::uint64_t kUnknownFileSize = std::uint64_t(-1)
 Derived classes do not necessarily need to provide file size information but they can return "not known" instead.
 
- Protected Attributes inherited from ROOT::Internal::RRawFile
std::uint64_t fFilePos
 The current position in the file, which can be changed by Seek, Read, and Readln.
 
ROptions fOptions
 
std::string fUrl
 

#include <ROOT/RRawFileUnix.hxx>

Inheritance diagram for ROOT::Internal::RRawFileUnix:
[legend]

Constructor & Destructor Documentation

◆ RRawFileUnix()

ROOT::Internal::RRawFileUnix::RRawFileUnix ( std::string_view  url,
RRawFile::ROptions  options 
)

Definition at line 38 of file RRawFileUnix.cxx.

◆ ~RRawFileUnix()

ROOT::Internal::RRawFileUnix::~RRawFileUnix ( )
override

Definition at line 43 of file RRawFileUnix.cxx.

Member Function Documentation

◆ Clone()

std::unique_ptr< ROOT::Internal::RRawFile > ROOT::Internal::RRawFileUnix::Clone ( ) const
finalvirtual

Create a new RawFile that accesses the same resource. The file pointer is reset to zero.

Implements ROOT::Internal::RRawFile.

Definition at line 49 of file RRawFileUnix.cxx.

◆ GetFd()

int ROOT::Internal::RRawFileUnix::GetFd ( ) const
inline

Definition at line 48 of file RRawFileUnix.hxx.

◆ GetFeatures()

int ROOT::Internal::RRawFileUnix::GetFeatures ( ) const
finalvirtual

Derived classes shall inform the user about the supported functionality, which can possibly depend on the file at hand.

Implements ROOT::Internal::RRawFile.

Definition at line 54 of file RRawFileUnix.cxx.

◆ GetSizeImpl()

std::uint64_t ROOT::Internal::RRawFileUnix::GetSizeImpl ( )
finalprotectedvirtual

Derived classes should return the file size or kUnknownFileSize.

Implements ROOT::Internal::RRawFile.

Definition at line 58 of file RRawFileUnix.cxx.

◆ MapImpl()

void * ROOT::Internal::RRawFileUnix::MapImpl ( size_t  nbytes,
std::uint64_t  offset,
std::uint64_t &  mapdOffset 
)
finalprotectedvirtual

If a derived class supports mmap, the MapImpl and UnmapImpl calls are supposed to be implemented, too The default implementation throws an error.

Reimplemented from ROOT::Internal::RRawFile.

Definition at line 72 of file RRawFileUnix.cxx.

◆ OpenImpl()

void ROOT::Internal::RRawFileUnix::OpenImpl ( )
finalprotectedvirtual

OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.

If fOptions.fBlocksize is negative, derived classes are responsible to set a sensible value. After a call to OpenImpl(), fOptions.fBlocksize must be larger or equal to zero.

Implements ROOT::Internal::RRawFile.

Definition at line 84 of file RRawFileUnix.cxx.

◆ ReadAtImpl()

size_t ROOT::Internal::RRawFileUnix::ReadAtImpl ( void *  buffer,
size_t  nbytes,
std::uint64_t  offset 
)
finalprotectedvirtual

Derived classes should implement low-level reading without buffering.

Short reads indicate the end of the file, therefore derived classes should return nbytes bytes if available.

Implements ROOT::Internal::RRawFile.

Definition at line 149 of file RRawFileUnix.cxx.

◆ ReadVImpl()

void ROOT::Internal::RRawFileUnix::ReadVImpl ( RIOVec ioVec,
unsigned int  nReq 
)
finalprotectedvirtual

By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX implementations.

Reimplemented from ROOT::Internal::RRawFile.

Definition at line 115 of file RRawFileUnix.cxx.

◆ UnmapImpl()

void ROOT::Internal::RRawFileUnix::UnmapImpl ( void *  region,
size_t  nbytes 
)
finalprotectedvirtual

Derived classes with mmap support must be able to unmap the memory area handed out by Map()

Reimplemented from ROOT::Internal::RRawFile.

Definition at line 174 of file RRawFileUnix.cxx.

Member Data Documentation

◆ fFileDes

int ROOT::Internal::RRawFileUnix::fFileDes
private

Definition at line 33 of file RRawFileUnix.hxx.

Libraries for ROOT::Internal::RRawFileUnix:

The documentation for this class was generated from the following files: