12 throwStorageError(
"FileDuplicateError",
"Calling File::sysduplicate()",
"dup()", errno);
23 else if (flags & OpenRead)
24 openflags |= O_RDONLY;
25 else if (flags & OpenWrite)
26 openflags |= O_WRONLY;
32 openflags |= O_APPEND;
38 if (flags & OpenUnbuffered)
52 openflags |= O_NOCTTY;
54 if ((newfd = ::open(name, openflags, perms)) == -1)
63 s = ::pread(
fd(), into, n, pos);
64 while (s == -1 && errno == EINTR);
77 s = ::pwrite(
fd(), from, n, pos);
78 while (s == -1 && errno == EINTR);
95 if (fstat(fd, &info) == -1)
104 assert(whence == CURRENT || whence ==
SET || whence == END);
107 int mywhence = (whence ==
SET ? SEEK_SET : whence == CURRENT ? SEEK_CUR : SEEK_END);
108 if ((result = ::lseek(fd, offset, mywhence)) == -1)
109 throwStorageError(
"FilePositionError",
"Calling File::position()",
"lseek()", errno);
118 if (ftruncate(fd, size) == -1)
119 throwStorageError(
"FileResizeError",
"Calling File::resize()",
"ftruncate()", errno);
126 #if _POSIX_SYNCHRONIZED_IO > 0 127 if (fdatasync(fd) == -1)
128 throwStorageError(
"FileFlushError",
"Calling File::flush()",
"fdatasync()", errno);
129 #elif _POSIX_FSYNC > 0 136 int ret = ::close(fd);
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)
ret
prodAgent to be discontinued
IOSize write(const void *from, IOSize n) override
IOOffset size(void) const override
static bool sysclose(IOFD fd, int *error=nullptr)
virtual IOOffset position(void) const
static IOFD sysduplicate(IOFD fd)
void flush(void) override
void resize(IOOffset size) override