ewmscp  ..
Classes | Public Member Functions | Static Private Attributes | List of all members
inputHandler::posixFile Class Reference

#include <inputHandlerPosixFile.h>

Inheritance diagram for inputHandler::posixFile:
[legend]
Collaboration diagram for inputHandler::posixFile:
[legend]

Classes

class  PosixDirectory
 
class  readerPosixFile
 
class  regionType
 class for data or hole regions, needed for sparse file handling More...
 

Public Member Functions

 posixFile ()=default
 
 ~posixFile () override=default
 
std::unique_ptr< readernewReader (const std::string &aPath, copyRequest::stateType &state, const genericStat &inititalStat) override
 get a reader for the file at path More...
 
bool readLinkTarget (const std::string &path, std::vector< char > &target) override
 read link target from a symlink More...
 
std::unique_ptr< DirectorygetDirectory (const std::string &path) override
 
- Public Member Functions inherited from inputHandler::base
virtual ~base () override=default
 
virtual std::unique_ptr< acl::listgetAclData (const std::string &)
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 
- Public Member Functions inherited from posixFileCommon
bool pathExists (const std::string &path) override
 
std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink) override
 
std::string getXattr (const std::string &path, const std::string &name) override
 

Static Private Attributes

static factoryTemplate< posixFilefactory
 
static options::single< bool > preserveAtime
 

Additional Inherited Members

- Static Public Member Functions inherited from inputHandler::base
static basenewHandler (const std::string &name)
 create an instance of an inputHandler, select by name More...
 
template<class T >
static void addAllowedNamesToOption (T &option)
 
- Protected Member Functions inherited from inputHandler::base
 base ()=default
 
- Static Protected Member Functions inherited from inputHandler::base
static std::map< std::string, factoryClass * > & getFactoryMap ()
 

Detailed Description

Definition at line 15 of file inputHandlerPosixFile.h.

Constructor & Destructor Documentation

◆ posixFile()

inputHandler::posixFile::posixFile ( )
default

◆ ~posixFile()

inputHandler::posixFile::~posixFile ( )
overridedefault

Member Function Documentation

◆ getDirectory()

std::unique_ptr< base::Directory > inputHandler::posixFile::getDirectory ( const std::string &  path)
overridevirtual

Implements inputHandler::base.

Definition at line 312 of file inputHandlerPosixFile.cpp.

312  {
313  return std::unique_ptr<Directory>(new PosixDirectory(path));
314  }

Referenced by inputHandler::dummy::getDirectory().

Here is the caller graph for this function:

◆ newReader()

std::unique_ptr< base::reader > inputHandler::posixFile::newReader ( const std::string &  path,
copyRequest::stateType state,
const genericStat inititalStat 
)
overridevirtual

get a reader for the file at path

Returns
unique ptr to a file reader.
Exceptions
std::system_errorif file can't be opened File will be closed when the pointer goes out of scope.
Parameters
[in]path[in] path to the file to be opened for reading
[in,out]state[in,out] state may be set to vanished if the file does not exist
[in]inititalStat[in] genericStat data of the file encountered before reading, needed for checking unchangedness at the end

Implements inputHandler::base.

Definition at line 18 of file inputHandlerPosixFile.cpp.

20  {
21  return std::unique_ptr<base::reader>(new readerPosixFile(aPath,
22  state,
23  inititalStat));
24  }

◆ readLinkTarget()

bool inputHandler::posixFile::readLinkTarget ( const std::string &  ,
std::vector< char > &   
)
overridevirtual

read link target from a symlink

Parameters
[in]pathis the path to the link
[in,out]targetis a vector that the link target gets written into, must be large enough
Returns
true if link could be read, false if the link does not exist
Exceptions
std::system_errorif the link could not be read
std::runtime_errorif the target size is larger than target.size()

Reimplemented from inputHandler::base.

Definition at line 27 of file inputHandlerPosixFile.cpp.

28  {
29  timerInst(readlink);
30  auto linklength = readlink(path.c_str(), target.data(), target.size());
31  if (linklength == -1 && errno == ENOENT) {
32  return false;
33  }
34  throwcall::badval(linklength, -1, "could not read link ", path);
35  if (linklength >= static_cast<ssize_t>(target.size())) {
36  throw std::runtime_error("link size increased after stat for " + path);
37  }
38  target[linklength] = '\0';
39  return true;
40  }

References throwcall::badval(), and timerInst.

Here is the call graph for this function:

Member Data Documentation

◆ factory

factoryTemplate<posixFile> inputHandler::posixFile::factory
staticprivate

Definition at line 16 of file inputHandlerPosixFile.h.

◆ preserveAtime

options::single<bool> inputHandler::posixFile::preserveAtime
staticprivate

The documentation for this class was generated from the following files:
throwcall::badval
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
Definition: throwcall.h:54
timerInst
#define timerInst(subfunc)
Definition: timer.h:157