7 using namespace IOFlags;
14 throwStorageError (
"FileDuplicateError",
"Calling File::sysduplicate()",
"dup()", errno);
21 IOFD &newfd,
unsigned int& )
28 else if (flags & OpenRead)
29 openflags |= O_RDONLY;
30 else if (flags & OpenWrite)
31 openflags |= O_WRONLY;
37 openflags |= O_APPEND;
43 if (flags & OpenUnbuffered)
57 openflags |= O_NOCTTY;
59 if ((newfd = ::open (name, openflags, perms)) == -1)
70 s = ::pread (
fd (), into, n, pos);
71 while (s == -1 && errno == EINTR);
86 s = ::pwrite (
fd (), from, n, pos);
87 while (s == -1 && errno == EINTR);
106 if (fstat (fd, &info) == -1)
117 assert (whence == CURRENT || whence == SET || whence == END);
120 int mywhence = (whence == SET ? SEEK_SET
121 : whence == CURRENT ? SEEK_CUR
123 if ((result = ::lseek (fd, offset, mywhence)) == -1)
124 throwStorageError(
"FilePositionError",
"Calling File::position()",
"lseek()", errno);
135 if (ftruncate (fd, size) == -1)
136 throwStorageError(
"FileResizeError",
"Calling File::resize()",
"ftruncate()", errno);
145 #if _POSIX_SYNCHRONIZED_IO > 0
146 if (fdatasync (fd) == -1)
147 throwStorageError(
"FileFlushError",
"Calling File::flush()",
"fdatasync()", errno);
148 #elif _POSIX_FSYNC > 0
149 if (fsync (fd) == -1)
157 int ret = ::close (fd);
158 if (error) *error = errno;
tuple ret
prodAgent to be discontinued
static bool sysclose(IOFD fd, int *error=0)
void throwStorageError(const char *category, const char *context, const char *call, int error)
static void sysopen(const char *name, int flags, int perms, IOFD &newfd, unsigned &newflags)
std::vector< Variable::Flags > flags
virtual IOOffset size(void) const
virtual IOOffset position(void) const
static IOFD sysduplicate(IOFD fd)
virtual IOSize write(const void *from, IOSize n)
virtual void resize(IOOffset size)
tuple size
Write out results.