2#include "XrdVersion.hh"
8using namespace std::literals;
22 if (this->oss ==
nullptr)
25 const auto opt = oss->get_entry_write(
Path);
29 auto entry = opt.value();
31 const std::string_view name{Aname};
33 if (name ==
"U.open.return_code"sv)
34 entry->open.return_code = {};
35 else if (name ==
"U.close.return_code"sv)
36 entry->close.return_code = {};
37 else if (name ==
"U.read.return_code"sv)
38 entry->read.return_code = {};
39 else if (name ==
"U.read.return_position"sv)
40 entry->read.return_position = {};
41 else if (name ==
"U.write.return_code"sv)
42 entry->write.return_code = {};
43 else if (name ==
"U.write.return_position"sv)
44 entry->write.return_position = {};
45 else if (name ==
"U.pattern"sv)
59 if (this->oss ==
nullptr)
62 const auto opt = oss->get_entry_read(
Path);
66 const auto entry = opt.value();
68 const std::string_view name{Aname};
71 if (name ==
"U.open.return_code"sv)
72 value = std::to_string(entry.open.return_code);
73 else if (name ==
"U.close.return_code"sv)
74 value = std::to_string(entry.close.return_code);
75 else if (name ==
"U.read.return_code"sv)
76 value = std::to_string(entry.read.return_code);
77 else if (name ==
"U.read.return_position"sv)
78 value = std::to_string(entry.read.return_position);
79 else if (name ==
"U.write.return_code"sv)
80 value = std::to_string(entry.write.return_code);
81 else if (name ==
"U.write.return_position"sv)
82 value = std::to_string(entry.write.return_position);
83 else if (name ==
"U.pattern"sv)
84 value = entry.pattern;
88 const int num_bytes = std::min(
static_cast<std::size_t
>(Avsz), value.size());
89 std::copy_n(value.begin(), num_bytes,
static_cast<char *
>(Aval));
101 if (this->oss ==
nullptr)
104 const auto opt = oss->get_entry_write(
Path);
105 if (!opt.has_value())
108 auto entry = opt.value();
110 const std::string_view name{Aname};
111 const std::string value(
static_cast<const char *
>(Aval), Avsz);
115 constexpr static auto parse_return_code = [](
auto value) {
117 auto code = std::stoi(value);
119 throw std::invalid_argument(
"return code is negative");
124 constexpr static auto parse_return_position = [](
auto value) {
126 auto position = std::stoll(value);
128 throw std::invalid_argument(
"return position is negative");
130 throw std::invalid_argument(
"return position is greater than the max file size");
135 if (name ==
"U.open.return_code"sv)
136 entry->open.return_code = parse_return_code(value);
137 else if (name ==
"U.close.return_code"sv)
138 entry->close.return_code = parse_return_code(value);
139 else if (name ==
"U.read.return_code"sv)
140 entry->read.return_code = parse_return_code(value);
141 else if (name ==
"U.read.return_position"sv)
142 entry->read.return_position = parse_return_position(value);
143 else if (name ==
"U.write.return_code"sv)
144 entry->write.return_code = parse_return_code(value);
145 else if (name ==
"U.write.return_position"sv)
146 entry->write.return_position = parse_return_position(value);
147 else if (name ==
"U.pattern"sv)
148 entry->pattern = value;
152 catch(std::out_of_range &)
156 catch(std::invalid_argument &)
166 if (this->oss ==
nullptr)
XrdSysXAttr * XrdSysGetXAttrObject(XrdSysError *errP, const char *config_fn, const char *parms)
XrdSysXAttr * XrdSysGetXAttrObject(XrdSysError *errP, const char *config_fn, const char *parms)
XrdVERSIONINFO(XrdSysGetXAttrObject, XrdOssMirageXAttr)
void setOss(XrdOssMirage &oss)
virtual int Get(const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1) override
virtual int Del(const char *Aname, const char *Path, int fd=-1) override
virtual void Free(AList *aPL) override
virtual int List(AList **aPL, const char *Path, int fd=-1, int getSz=0) override
virtual int Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0) override
static constexpr std::uint64_t max_file_size