Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc594704

Browse files
committed
[Issue#62] Replace pgwin32_safestat with fio_safestat
1 parent84c6fd4 commitc594704

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

‎src/utils/file.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,41 @@ static bool fio_is_remote_fd(int fd)
5151
}
5252

5353
#ifdefWIN32
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+
staticint
63+
fio_safestat(constchar*path,structstat*buf)
64+
{
65+
intr;
66+
WIN32_FILE_ATTRIBUTE_DATAattr;
67+
68+
r=stat(path,buf);
69+
if (r<0)
70+
returnr;
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+
return0;
85+
}
86+
87+
#definestat(x) fio_safestat(x)
88+
5489
staticssize_tpread(intfd,void*buf,size_tsize,off_toff)
5590
{
5691
off_trc=lseek(fd,off,SEEK_SET);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp