1 /*-------------------------------------------------------------------------
4 * Replacements for fseeko() and ftello().
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
9 * src/port/win32fseek.c
11 *-------------------------------------------------------------------------
15 #include "postgres_fe.h"
25 * Calling fseek() on a handle to a non-seeking device such as a pipe or
26 * a communications device is not supported, and fseek() may not return
27 * an error. This wrapper relies on the file type to check which cases
31 _pgfseeko64(FILE *stream
, pgoff_t offset
, int origin
)
34 HANDLE hFile
= (HANDLE
) _get_osfhandle(_fileno(stream
));
36 fileType
= pgwin32_get_file_type(hFile
);
40 if (fileType
== FILE_TYPE_DISK
)
41 return _fseeki64(stream
, offset
, origin
);
42 else if (fileType
== FILE_TYPE_CHAR
|| fileType
== FILE_TYPE_PIPE
)
53 * Same as _pgfseeko64().
56 _pgftello64(FILE *stream
)
59 HANDLE hFile
= (HANDLE
) _get_osfhandle(_fileno(stream
));
61 fileType
= pgwin32_get_file_type(hFile
);
65 if (fileType
== FILE_TYPE_DISK
)
66 return _ftelli64(stream
);
67 else if (fileType
== FILE_TYPE_CHAR
|| fileType
== FILE_TYPE_PIPE
)