25 {
open (name, flags, perms); }
38 <<
"Destructor called on dCache file '" <<
m_name
39 <<
"' but the file is still open";
79 if ((name == 0) || (*name == 0))
81 <<
"Cannot open a file without a name";
85 <<
"Must open file '" << name <<
"' at least for read or write";
96 else if (flags & IOFlags::OpenRead)
97 openflags |= O_RDONLY;
98 else if (flags & IOFlags::OpenWrite)
99 openflags |= O_WRONLY;
105 openflags |= O_APPEND;
108 openflags |= O_CREAT;
114 openflags |= O_TRUNC;
118 if ((newfd = dc_open (name, openflags, perms)) == -1)
120 <<
"dc_open(name='" << name
121 <<
"', flags=0x" << std::hex << openflags
122 <<
", permissions=0" << std::oct << perms << std::dec
123 <<
") => error '" << dc_strerror(dc_errno)
124 <<
"' (dc_errno=" << dc_errno <<
")";
135 dc_noBuffering(
m_fd);
137 dc_setBufferSize(
m_fd, 64000);
150 <<
"DCacheFile::close(name='" <<
m_name
151 <<
"') called but the file is not open";
157 if (dc_close (
m_fd) == -1)
159 <<
"dc_close(name='" <<
m_name
160 <<
"') failed with error '" << dc_strerror (dc_errno)
161 <<
"' (dc_errno=" << dc_errno <<
")";
203 ssize_t
s = dc_read (
m_fd, (
char *) into + done, n - done);
206 <<
"dc_read(name='" <<
m_name <<
"', n=" << (n-
done)
207 <<
") failed with error '" << dc_strerror(dc_errno)
208 <<
"' (dc_errno=" << dc_errno <<
")";
212 else if (s < ssize_t (n-done))
214 <<
"dc_read(name='" <<
m_name <<
"', n=" << (n-
done)
215 <<
") returned a short read of " << s <<
" bytes; "
216 <<
"please report a bug in dCache referencing the "
217 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
231 ssize_t
s = dc_write (
m_fd, (
const char *) from + done, n - done);
234 <<
"dc_write(name='" <<
m_name <<
"', n=" << (n-
done)
235 <<
") failed with error '" << dc_strerror(dc_errno)
236 <<
"' (dc_errno=" << dc_errno <<
")";
237 else if (s < ssize_t (n-done))
239 <<
"dc_write(name='" <<
m_name <<
"', n=" << (n-
done)
240 <<
") returned a short write of " << s <<
" bytes; "
241 <<
"please report a bug in dCache referencing the "
242 <<
"comment on line " <<
BUGLINE <<
" of " << __FILE__;
252 assert (! buffers || into);
259 std::vector<iovec> bufs (buffers);
262 bufs [
i].iov_len = into [
i].
size ();
263 bufs [
i].iov_base = (caddr_t) into [
i].
data ();
268 ssize_t
n = dc_readv (
m_fd, &bufs [0], buffers);
273 <<
"dc_readv(name='" <<
m_name <<
"', iov[" << buffers
274 <<
"]) failed with error '" << dc_strerror(dc_errno)
275 <<
"' (dc_errno=" << dc_errno <<
")";
284 assert (! buffers || into);
291 std::vector<iovec2> bufs (buffers);
294 bufs [
i].offset = into [
i].
offset ();
295 bufs [
i].len = into [
i].
size ();
296 bufs [
i].buf = (
char *) into [
i].
data ();
301 ssize_t
n = dc_readv2 (
m_fd, &bufs [0], buffers);
306 <<
"dc_readv2(name='" <<
m_name <<
"', iov2[" << buffers
307 <<
"]) failed with error '" << dc_strerror(dc_errno)
308 <<
"' (dc_errno=" << dc_errno <<
")";
322 <<
"DCacheFile::position() called on a closed file";
325 <<
"DCacheFile::position() called with incorrect 'whence' parameter";
328 int mywhence = (whence ==
SET ? SEEK_SET
333 if ((result = dc_lseek64 (
m_fd, offset, mywhence)) == -1)
335 <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" << offset
336 <<
", whence=" << mywhence <<
") failed with error '"
337 << dc_strerror (dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
341 if (whence == SEEK_END && (result = dc_lseek64 (
m_fd, result, SEEK_SET)) == -1)
343 <<
"dc_lseek64(name='" <<
m_name <<
"', offset=" << offset
344 <<
", whence=" << SEEK_SET <<
") failed with error '"
345 << dc_strerror (dc_errno) <<
"' (dc_errno=" << dc_errno <<
")";
354 <<
"DCacheFile::resize(name='" <<
m_name <<
"') not implemented";
std::vector< Variable::Flags > flags
virtual void resize(IOOffset size)
virtual IOSize write(const void *from, IOSize n)
virtual void create(const char *name, bool exclusive=false, int perms=0666)
virtual IOOffset position(void) const
virtual IOSize readv(IOBuffer *into, IOSize buffers)
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
unsigned int offset(bool)
IOOffset offset(void) const
static std::string from(" from ")