CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cvmfs::PathSink Class Reference

#include <sink_path.h>

Inheritance diagram for cvmfs::PathSink:
Collaboration diagram for cvmfs::PathSink:

Public Member Functions

 PathSink (const std::string &destination_path)
 
virtual ~PathSink ()
 
virtual int64_t Write (const void *buf, uint64_t sz)
 
virtual int Reset ()
 
virtual int Purge ()
 
virtual bool IsValid ()
 
virtual int Flush ()
 
virtual bool Reserve (size_t size)
 
virtual bool RequiresReserve ()
 
virtual std::string Describe ()
 
const std::string path ()
 
- Public Member Functions inherited from cvmfs::Sink
virtual ~Sink ()
 
void Release ()
 

Private Attributes

FILE * file_
 
UniquePtr< FileSinksink_
 
const std::string path_
 

Additional Inherited Members

- Protected Member Functions inherited from cvmfs::Sink
 Sink (bool is_owner)
 
- Protected Attributes inherited from cvmfs::Sink
bool is_owner_
 

Detailed Description

PathSink is a data sink that writes to a file given by a path.

Internally it uses a FileSink that has ownership of the file. (Though as PathSink is owner of the FileSink, to the outside also PathSink is considered to be the owner.)

Like FileSink, PathSink does not require to reserve space. Contrary to FileSink, PathSink does not allow to adopt and write to a different file path.

Definition at line 30 of file sink_path.h.

Constructor & Destructor Documentation

cvmfs::PathSink::PathSink ( const std::string &  destination_path)
explicit

Definition at line 15 of file sink_path.cc.

virtual cvmfs::PathSink::~PathSink ( )
inlinevirtual

Definition at line 34 of file sink_path.h.

Member Function Documentation

std::string cvmfs::PathSink::Describe ( )
virtual

Return a string representation describing the type of sink and its status

Implements cvmfs::Sink.

Definition at line 46 of file sink_path.cc.

Here is the call graph for this function:

virtual int cvmfs::PathSink::Flush ( )
inlinevirtual

Commit data to the sink

Returns
success = 0 failure = -errno

Implements cvmfs::Sink.

Definition at line 70 of file sink_path.h.

virtual bool cvmfs::PathSink::IsValid ( )
inlinevirtual
Returns
true if the object is correctly initialized.

Implements cvmfs::Sink.

Definition at line 61 of file sink_path.h.

Referenced by Describe().

Here is the caller graph for this function:

const std::string cvmfs::PathSink::path ( )
inline

Definition at line 109 of file sink_path.h.

Referenced by download::PrepareDownloadDestination().

Here is the caller graph for this function:

int cvmfs::PathSink::Purge ( )
virtual

Purges all resources leaving the sink in an invalid state. More aggressive version of Reset(). For some sinks and depending on owner status it might do the same as Reset().

Returns
Success = 0 Failure = -errno

Implements cvmfs::Sink.

Definition at line 30 of file sink_path.cc.

virtual bool cvmfs::PathSink::RequiresReserve ( )
inlinevirtual

Returns if the specific sink type needs reservation of (data) space

Returns
true - reservation is needed false - no reservation is needed

Implements cvmfs::Sink.

Definition at line 100 of file sink_path.h.

virtual bool cvmfs::PathSink::Reserve ( size_t  size)
inlinevirtual

Reserves new space in sinks that require reservation (see RequiresReserve)

Successful if the requested size is smaller than already space reserved, or if the sink is the owner of the data and can allocate enough new space.

Note
If successful, always resets the current position to 0.

Fails if 1) sink is not the owner of the data and more than the current size is requested 2) more space is requested than allowed (max_size_)

Returns
success = true failure = false

Implements cvmfs::Sink.

Definition at line 90 of file sink_path.h.

virtual int cvmfs::PathSink::Reset ( )
inlinevirtual

Truncate all written data and start over at position zero.

Returns
Success = 0 Failure = -errno

Implements cvmfs::Sink.

Definition at line 52 of file sink_path.h.

virtual int64_t cvmfs::PathSink::Write ( const void *  buf,
uint64_t  sz 
)
inlinevirtual

Appends data to the sink

Returns
on success: number of bytes written (can be less than requested) on failure: -errno.

Implements cvmfs::Sink.

Definition at line 42 of file sink_path.h.

Member Data Documentation

FILE* cvmfs::PathSink::file_
private

Definition at line 112 of file sink_path.h.

Referenced by PathSink().

const std::string cvmfs::PathSink::path_
private

Definition at line 114 of file sink_path.h.

Referenced by Describe(), path(), and Purge().

UniquePtr<FileSink> cvmfs::PathSink::sink_
private

Definition at line 113 of file sink_path.h.

Referenced by Flush(), IsValid(), PathSink(), Purge(), RequiresReserve(), Reserve(), Reset(), and Write().


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