30 <<
"' but the file is still open";
52 if ((
name ==
nullptr) || (*
name == 0)) {
54 ex <<
"Cannot open a file without a name";
61 ex <<
"Must open file '" <<
name <<
"' at least for read or write";
76 openflags |= O_RDONLY;
78 openflags |= O_WRONLY;
84 openflags |= O_APPEND;
97 if ((newfd = dc_open(
name, openflags, perms)) == -1) {
99 ex <<
"dc_open(name='" <<
name <<
"', flags=0x" << std::hex << openflags <<
", permissions=0" << std::oct << perms
100 <<
std::dec <<
") => error '" << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
115 dc_noBuffering(
m_fd);
117 dc_setBufferSize(
m_fd, 64000);
126 edm::LogError(
"DCacheFileError") <<
"DCacheFile::close(name='" <<
m_name <<
"') called but the file is not open";
132 if (dc_close(
m_fd) == -1)
134 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
174 ex <<
"dc_read(name='" <<
m_name <<
"', n=" << (
n -
done) <<
") failed with error '" << dc_strerror(dc_errno)
175 <<
"' (dc_errno=" << dc_errno <<
")";
181 else if (
s < ssize_t(
n -
done))
183 <<
") returned a short read of " <<
s <<
" bytes; " 184 <<
"please report a bug in dCache referencing the " 185 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
199 ex <<
"dc_write(name='" <<
m_name <<
"', n=" << (
n -
done) <<
") failed with error '" << dc_strerror(dc_errno)
200 <<
"' (dc_errno=" << dc_errno <<
")";
203 }
else if (
s < ssize_t(
n -
done))
205 <<
") returned a short write of " <<
s <<
" bytes; " 206 <<
"please report a bug in dCache referencing the " 207 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
222 std::vector<iovec> bufs(buffers);
224 bufs[
i].iov_len = into[
i].
size();
225 bufs[
i].iov_base = (caddr_t)into[
i].
data();
230 ssize_t
n = dc_readv(
m_fd, &bufs[0], buffers);
235 ex <<
"dc_readv(name='" <<
m_name <<
"', iov[" << buffers <<
"]) failed with error '" << dc_strerror(dc_errno)
236 <<
"' (dc_errno=" << dc_errno <<
")";
253 std::vector<iovec2> bufs(buffers);
257 bufs[
i].len = into[
i].
size();
258 bufs[
i].buf = (
char *)into[
i].
data();
264 ssize_t
n = dc_readv2(
m_fd, &bufs[0], buffers);
269 ex <<
"dc_readv2(name='" <<
m_name <<
"', iov2[" << buffers <<
"]) failed with error '" << dc_strerror(dc_errno)
270 <<
"' (dc_errno=" << dc_errno <<
")";
275 return (
n == 0) ?
total : 0;
284 ex <<
"DCacheFile::position() called on a closed file";
289 ex <<
"DCacheFile::position() called with incorrect 'whence' parameter";
293 int mywhence = (whence ==
SET ? SEEK_SET : whence ==
CURRENT ? SEEK_CUR : SEEK_END);
298 ex <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" <<
offset <<
", whence=" << mywhence <<
") failed with error '" 299 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
300 ex.
addContext(
"Calling DCacheFile::position()");
305 if (whence == SEEK_END && (
result = dc_lseek64(
m_fd,
result, SEEK_SET)) == -1) {
307 ex <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" <<
offset <<
", whence=" << SEEK_SET <<
") failed with error '" 308 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
309 ex.
addContext(
"Calling DCacheFile::position()");
317 ex <<
"DCacheFile::resize(name='" <<
m_name <<
"') not implemented";
void resize(IOOffset size) override
IOSize readv(IOBuffer *into, IOSize buffers) override
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Log< level::Error, false > LogError
~DCacheFile(void) override
virtual void create(const char *name, bool exclusive=false, int perms=0666)
IOSize write(const void *from, IOSize n) override
void close(void) override
Log< level::Info, false > LogInfo
void addContext(std::string const &context)
char data[epos_bytes_allocation]
constexpr int EDM_IOFD_INVALID
virtual IOOffset position() const
Log< level::Warning, false > LogWarning