blob: d8dcc0c44ce472dd2c7753b4afec4d146f496577 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <stdio.h>
#include <io.h>
#include <errno.h>
int __cdecl
fseeko64 (FILE* stream, off64_t offset, int whence)
{
fpos_t pos;
if (whence == SEEK_CUR)
{
/* If stream is invalid, fgetpos sets errno. */
if (fgetpos (stream, &pos))
return (-1);
pos += (fpos_t) offset;
}
else if (whence == SEEK_END)
{
/* If writing, we need to flush before getting file length. */
fflush (stream);
pos = (fpos_t) (_filelengthi64 (_fileno (stream)) + offset);
}
else if (whence == SEEK_SET)
pos = (fpos_t) offset;
else
{
errno = EINVAL;
return (-1);
}
return fsetpos (stream, &pos);
}
|