#include "wimlib/error.h"
#include "wimlib/file_io.h"
#include "wimlib/util.h"
-#include "wimlib/win32.h" /* For pread(), pwrite() replacements */
+
+#ifdef __WIN32__
+# include "wimlib/win32.h"
+# define read win32_read
+# define write win32_write
+# define pread win32_pread
+# define pwrite win32_pwrite
+#endif
/*
* Wrapper around read() that checks for errors and keeps retrying until all
* Return values:
* WIMLIB_ERR_SUCCESS (0)
* WIMLIB_ERR_READ (errno set)
- * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to 0)
+ * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to EINVAL)
*/
int
full_read(struct filedes *fd, void *buf, size_t count)
ssize_t ret = read(fd->fd, buf, count);
if (unlikely(ret <= 0)) {
if (ret == 0) {
- errno = 0;
+ errno = EINVAL;
return WIMLIB_ERR_UNEXPECTED_END_OF_FILE;
}
if (errno == EINTR)
* Return values:
* WIMLIB_ERR_SUCCESS (0)
* WIMLIB_ERR_READ (errno set)
- * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to 0)
+ * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to EINVAL)
* WIMLIB_ERR_RESOURCE_ORDER (errno set to ESPIPE)
*/
int
ssize_t ret = pread(fd->fd, buf, count, offset);
if (unlikely(ret <= 0)) {
if (ret == 0) {
- errno = 0;
+ errno = EINVAL;
return WIMLIB_ERR_UNEXPECTED_END_OF_FILE;
}
if (errno == EINTR)
return 0;
}
-ssize_t
-raw_pread(struct filedes *fd, void *buf, size_t count, off_t offset)
-{
- return pread(fd->fd, buf, count, offset);
-}
-
-ssize_t
-raw_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset)
-{
- return pwrite(fd->fd, buf, count, offset);
-}
-
off_t filedes_seek(struct filedes *fd, off_t offset)
{
if (fd->is_pipe) {