check for seekability on win

pull/112/head
Dave Vasilevsky 6 months ago
parent 446087ed7a
commit 7ed15497be

@ -69,7 +69,7 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memchr memmove memset strerror strtol sched_getaffinity sysconf
GetSystemInfo _setmode])
GetSystemInfo _setmode _get_osfhandle])
AC_CHECK_HEADER([sys/endian.h],
[
AC_CHECK_DECLS([htole64, le64toh], [], [], [

@ -4,6 +4,9 @@
#include <stdarg.h>
#include <math.h>
#if HAVE__GET_OSFHANDLE
#include <windows.h>
#endif
#pragma mark UTILS
@ -344,6 +347,17 @@ static lzma_index *next_index(off_t *pos) {
}
bool decode_index(void) {
#if HAVE__GET_OSFHANDLE
// windows pretends that seeking works on pipes, but then it doesn't
// try to check that this is a "regular" file with win api
intptr_t hdl = _get_osfhandle(_fileno(gInFile));
DWORD ftype = GetFileType((HANDLE)hdl);
if (ftype != FILE_TYPE_DISK) {
fprintf(stderr, "can not seek in input\n");
return false;
}
#endif
if (fseeko(gInFile, 0, SEEK_END) == -1) {
fprintf(stderr, "can not seek in input: %s\n", strerror(errno));
return false; // not seekable

Loading…
Cancel
Save