ewmscp  ..
Public Member Functions | Static Public Member Functions | List of all members
dcapCommon Class Reference

#include <dcapCommon.h>

Inheritance diagram for dcapCommon:
[legend]
Collaboration diagram for dcapCommon:
[legend]

Public Member Functions

 dcapCommon ()
 
bool pathExists (const std::string &path) override
 
std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink) override
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 
virtual std::string getXattr (const std::string &, const std::string &)
 

Static Public Member Functions

static std::string fixPathUrl (const std::string &path)
 

Detailed Description

Definition at line 65 of file dcapCommon.h.

Constructor & Destructor Documentation

◆ dcapCommon()

dcapCommon::dcapCommon ( )

Definition at line 119 of file dcapCommon.cpp.

119  {
121 }

References dCapConfigParameter::apply().

Here is the call graph for this function:

Member Function Documentation

◆ fixPathUrl()

std::string dcapCommon::fixPathUrl ( const std::string &  path)
static

Definition at line 127 of file dcapCommon.cpp.

127  {
128  // example path: dcap://dcache-dot3:22125/pnfs/desy.de/dot/data_volatile/cards/A Display of My Dark Power.full.jpg
129  auto index = path.find("//"); //find host name start
130  if (index == std::remove_reference<decltype(path)>::type::npos) {
131  throw std::runtime_error("can't sanitize path \"" + path + "\"");
132  }
133  index = path.find('/', index + 2); // find start of real path part
134  std::string url(path.substr(0, index + 1));
135  static const auto escaper = escapism::newEscaper("Urlsoft");
136  escaper->escape(path.substr(index + 1), url);
137  if (url.back() == '/') {
138  url.pop_back();
139  }
140  return url;
141 }

References escapism::newEscaper().

Referenced by outputHandler::dcap::ensureParentDirs(), inputHandler::dcap::dcapDirectory::getNextEntry(), getStat(), pathExists(), outputHandler::dcap::remove(), and outputHandler::dcap::rename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStat()

std::unique_ptr< const genericStat > dcapCommon::getStat ( const std::string &  path,
bool  followLink 
)
overridevirtual

Implements pathHandler.

Definition at line 157 of file dcapCommon.cpp.

158  {
159  dCapLock extraOptionLock;
160  struct dcapStat statBuf;
161  std::string fixedPath(fixPathUrl(path));
162  int result;
163  if (followLink) {
164  result = dc_stat(fixedPath.c_str(), &statBuf);
165  } else {
166  result = dc_lstat(fixedPath.c_str(), &statBuf);
167  }
168  if (result && errno == ENOENT && (dc_errno == DEOK || dc_errno == DESRVMSG)) {
169  return nullptr;
170  }
171  throwcall::dcap::good0(result, "can't stat ", fixedPath);
172  if (statBuf.st_blksize == 0) { // we got nonsense
173  statBuf.st_blksize = 1024 * 1024; // use 1M as default
174  }
175  return std::unique_ptr<const genericStat>(new genericStat(statBuf, std::chrono::seconds(1)));
176 };

References dcapStat, fixPathUrl(), and throwcall::dcap::good0().

Here is the call graph for this function:

◆ pathExists()

bool dcapCommon::pathExists ( const std::string &  path)
overridevirtual

Implements pathHandler.

Definition at line 146 of file dcapCommon.cpp.

146  {
147  dCapLock extraOptionLock;
148  struct dcapStat statBuf;
149  std::string fixedPath(fixPathUrl(path));
150  auto result = dc_stat(fixedPath.c_str(), &statBuf);
151  if (result && errno == ENOENT) {
152  return false;
153  }
154  throwcall::dcap::good0(result, "can't stat ", fixedPath);
155  return true;
156 };

References dcapStat, fixPathUrl(), and throwcall::dcap::good0().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
dCapLock
Definition: dcapCommon.h:40
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
dcapStat
#define dcapStat
Definition: dcapCommon.h:7
dcapCommon::fixPathUrl
static std::string fixPathUrl(const std::string &path)
Definition: dcapCommon.cpp:127
dCapConfigParameter::apply
static void apply()
Definition: dcapCommon.cpp:20
escapism::newEscaper
static const escapism * newEscaper(const std::string &name)
Definition: escapism.cpp:25
throwcall::dcap::good0
void good0(T call, const Args &... args)
Definition: dcapCommon.h:21