28 <<
"' but the file is still open";
50 if ((
name ==
nullptr) || (*
name == 0)) {
52 ex <<
"Cannot open a file without a name";
59 ex <<
"Must open file '" <<
name <<
"' at least for read or write";
74 openflags |= O_RDONLY;
76 openflags |= O_WRONLY;
82 openflags |= O_APPEND;
95 if ((newfd = dc_open(
name, openflags, perms)) == -1) {
97 ex <<
"dc_open(name='" <<
name <<
"', flags=0x" << std::hex << openflags <<
", permissions=0" << std::oct << perms
98 <<
std::dec <<
") => error '" << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
113 dc_noBuffering(
m_fd);
115 dc_setBufferSize(
m_fd, 64000);
124 edm::LogError(
"DCacheFileError") <<
"DCacheFile::close(name='" <<
m_name <<
"') called but the file is not open";
130 if (dc_close(
m_fd) == -1)
132 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
172 ex <<
"dc_read(name='" <<
m_name <<
"', n=" << (
n -
done) <<
") failed with error '" << dc_strerror(dc_errno)
173 <<
"' (dc_errno=" << dc_errno <<
")";
179 else if (
s < ssize_t(
n -
done))
181 <<
") returned a short read of " <<
s <<
" bytes; "
182 <<
"please report a bug in dCache referencing the "
183 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
197 ex <<
"dc_write(name='" <<
m_name <<
"', n=" << (
n -
done) <<
") failed with error '" << dc_strerror(dc_errno)
198 <<
"' (dc_errno=" << dc_errno <<
")";
201 }
else if (
s < ssize_t(
n -
done))
203 <<
") returned a short write of " <<
s <<
" bytes; "
204 <<
"please report a bug in dCache referencing the "
205 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
220 std::vector<iovec> bufs(buffers);
222 bufs[
i].iov_len = into[
i].
size();
223 bufs[
i].iov_base = (caddr_t)into[
i].
data();
228 ssize_t
n = dc_readv(
m_fd, &bufs[0], buffers);
233 ex <<
"dc_readv(name='" <<
m_name <<
"', iov[" << buffers <<
"]) failed with error '" << dc_strerror(dc_errno)
234 <<
"' (dc_errno=" << dc_errno <<
")";
251 std::vector<iovec2> bufs(buffers);
255 bufs[
i].len = into[
i].
size();
256 bufs[
i].buf = (
char *)into[
i].
data();
262 ssize_t
n = dc_readv2(
m_fd, &bufs[0], buffers);
267 ex <<
"dc_readv2(name='" <<
m_name <<
"', iov2[" << buffers <<
"]) failed with error '" << dc_strerror(dc_errno)
268 <<
"' (dc_errno=" << dc_errno <<
")";
273 return (
n == 0) ?
total : 0;
282 ex <<
"DCacheFile::position() called on a closed file";
287 ex <<
"DCacheFile::position() called with incorrect 'whence' parameter";
291 int mywhence = (whence ==
SET ? SEEK_SET : whence ==
CURRENT ? SEEK_CUR : SEEK_END);
296 ex <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" <<
offset <<
", whence=" << mywhence <<
") failed with error '"
297 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
298 ex.
addContext(
"Calling DCacheFile::position()");
303 if (whence == SEEK_END && (
result = dc_lseek64(
m_fd,
result, SEEK_SET)) == -1) {
305 ex <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" <<
offset <<
", whence=" << SEEK_SET <<
") failed with error '"
306 << dc_strerror(dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
307 ex.
addContext(
"Calling DCacheFile::position()");
315 ex <<
"DCacheFile::resize(name='" <<
m_name <<
"') not implemented";