ReactOS 0.4.16-dev-959-g2ec3a19
filelength.cpp File Reference
#include <corecrt_internal_lowio.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for filelength.cpp:

Go to the source code of this file.

Functions

template<typename Integer >
 _Success_ (return !=-1) static Integer __cdecl common_filelength(int const fh) throw ()
 
long __cdecl _filelength (int const fh)
 
__int64 __cdecl _filelengthi64 (int const fh)
 

Function Documentation

◆ _filelength()

long __cdecl _filelength ( int const  fh)

Definition at line 55 of file filelength.cpp.

56{
57 return common_filelength<long>(fh);
58}

◆ _filelengthi64()

__int64 __cdecl _filelengthi64 ( int const  fh)

Definition at line 60 of file filelength.cpp.

61{
62 return common_filelength<__int64>(fh);
63}

◆ _Success_()

template<typename Integer >
_Success_ ( return = -1) const
throw (
)

Definition at line 17 of file filelength.cpp.

19{
20 typedef __crt_integer_traits<Integer> traits;
21
23 _VALIDATE_CLEAR_OSSERR_RETURN(fh >= 0 && (unsigned)fh < (unsigned)_nhandle, EBADF, -1);
25
27 Integer end = -1;
28 __try
29 {
30 if ((_osfile(fh) & FOPEN) == 0)
31 {
32 errno = EBADF;
33 _doserrno = 0;
34 _ASSERTE(("Invalid file descriptor. File possibly closed by a different thread", 0));
35 __leave;
36 }
37
38 // Seek to the end to get the length:
39 Integer const here = traits::lseek_nolock(fh, 0, SEEK_CUR);
40 if (here == -1)
41 __leave;
42
43 end = traits::lseek_nolock(fh, 0, SEEK_END);
44 if (here != end)
45 traits::lseek_nolock(fh, here, SEEK_SET);
46 }
48 {
50 }
52 return end;
53}
#define EBADF
Definition: acclib.h:82
#define SEEK_END
Definition: cabinet.c:29
#define _CHECK_FH_CLEAR_OSSERR_RETURN(handle, errorcode, retexpr)
int _nhandle
Definition: ioinit.cpp:34
void __cdecl __acrt_lowio_lock_fh(_In_ int _FileHandle)
void __cdecl __acrt_lowio_unlock_fh(_In_ int _FileHandle)
#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 __try
Definition: pseh2_64.h:188
#define __leave
Definition: pseh2_64.h:192
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
#define errno
Definition: errno.h:18
#define _osfile(i)
Definition: internal.h:72