File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,41 @@ static bool fio_is_remote_fd(int fd)
5151}
5252
5353#ifdef WIN32
54+
55+ #undef stat
56+
57+ /*
58+ * The stat() function in win32 is not guaranteed to update the st_size
59+ * field when run. So we define our own version that uses the Win32 API
60+ * to update this field.
61+ */
62+ static int
63+ fio_safestat (const char * path , struct stat * buf )
64+ {
65+ int r ;
66+ WIN32_FILE_ATTRIBUTE_DATA attr ;
67+
68+ r = stat (path , buf );
69+ if (r < 0 )
70+ return r ;
71+
72+ if (!GetFileAttributesEx (path , GetFileExInfoStandard , & attr ))
73+ {
74+ errno = ENOENT ;
75+ return -1 ;
76+ }
77+
78+ /*
79+ * XXX no support for large files here, but we don't do that in general on
80+ * Win32 yet.
81+ */
82+ buf -> st_size = attr .nFileSizeLow ;
83+
84+ return 0 ;
85+ }
86+
87+ #define stat (x ) fio_safestat(x)
88+
5489static ssize_t pread (int fd , void * buf , size_t size , off_t off )
5590{
5691 off_t rc = lseek (fd , off , SEEK_SET );
You can’t perform that action at this time.
0 commit comments