1 #ifndef _WIMLIB_FILE_IO_H
2 #define _WIMLIB_FILE_IO_H
8 /* Wrapper around a file descriptor that keeps track of offset (including in
9 * pipes, which don't support lseek()) and a cached flag that tells whether the
10 * file descriptor is a pipe or not. */
13 unsigned int is_pipe : 1;
18 full_read(struct filedes *fd, void *buf, size_t n);
21 full_pread(struct filedes *fd, void *buf, size_t nbyte, off_t offset);
24 full_write(struct filedes *fd, const void *buf, size_t n);
27 full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset);
30 raw_pread(struct filedes *fd, void *buf, size_t nbyte, off_t offset);
33 raw_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset);
49 filedes_seek(struct filedes *fd, off_t offset);
52 filedes_is_seekable(struct filedes *fd);
54 static inline void filedes_init(struct filedes *fd, int raw_fd)
61 static inline void filedes_invalidate(struct filedes *fd)
66 static inline void filedes_copy(struct filedes *dst, const struct filedes *src)
71 #define filedes_close(f) close((f)->fd)
74 filedes_valid(const struct filedes *fd)
79 #endif /* _WIMLIB_FILE_IO_H */