ReactOS 0.4.16-dev-927-g467dec4
eof.cpp File Reference
Include dependency graph for eof.cpp:

Go to the source code of this file.

Functions

int __cdecl _eof (int const fh)
 

Function Documentation

◆ _eof()

int __cdecl _eof ( int const  fh)

Definition at line 16 of file eof.cpp.

17{
19 _VALIDATE_CLEAR_OSSERR_RETURN((fh >= 0 && (unsigned)fh < (unsigned)_nhandle), EBADF, -1);
21
22 return __acrt_lowio_lock_fh_and_call(fh, [&]()
23 {
24 if ((_osfile(fh) & FOPEN) == 0)
25 {
26 errno = EBADF;
27 _doserrno = 0;
28 _ASSERTE(("Invalid file descriptor. File possibly closed by a different thread",0));
29 return -1;
30 }
31
32 __int64 const here = _lseeki64_nolock(fh, 0ll, SEEK_CUR);
33 if (here == -1ll)
34 return -1;
35
36
37 __int64 const end = _lseeki64_nolock(fh, 0ll, SEEK_END);
38 if (end == -1ll)
39 return -1;
40
41 // Now we can test if we're at the end:
42 if (here == end)
43 return 1;
44
45 // If we aren't at the end, we need to reset the stream to its original
46 // state before we return:
47 _lseeki64_nolock(fh, here, SEEK_SET);
48 return 0;
49 });
50}
#define EBADF
Definition: acclib.h:82
#define __int64
Definition: basetyps.h:16
w ll
Definition: byte_order.h:167
#define SEEK_END
Definition: cabinet.c:29
#define _CHECK_FH_CLEAR_OSSERR_RETURN(handle, errorcode, retexpr)
int _nhandle
Definition: ioinit.cpp:34
auto __acrt_lowio_lock_fh_and_call(int const fh, Action &&action) -> decltype(action())
_Check_return_opt_ __int64 __cdecl _lseeki64_nolock(_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin)
#define _ASSERTE(expr)
Definition: crtdbg.h:114
#define FOPEN
GLuint GLuint end
Definition: gl.h:1545
#define _doserrno
Definition: stdlib.h:131
#define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr)
#define SEEK_SET
Definition: jmemansi.c:26
#define SEEK_CUR
Definition: util.h:63
#define errno
Definition: errno.h:18
#define _osfile(i)
Definition: internal.h:72