1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* An lseek() function that detects pipes.
4 Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, see <http://www.gnu.org/licenses/>. */
24 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
25 /* Windows platforms. */
26 /* Get GetFileType. */
28 /* Get _get_osfhandle. */
29 # include "msvc-nothrow.h"
31 # include <sys/stat.h>
38 rpl_lseek (int fd, off_t offset, int whence)
40 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
41 /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
42 HANDLE h = (HANDLE) _get_osfhandle (fd);
43 if (h == INVALID_HANDLE_VALUE)
48 if (GetFileType (h) != FILE_TYPE_DISK)
54 /* BeOS lseek mistakenly succeeds on pipes... */
56 if (fstat (fd, &statbuf) < 0)
58 if (!S_ISREG (statbuf.st_mode))
64 #if _GL_WINDOWS_64_BIT_OFF_T
65 return _lseeki64 (fd, offset, whence);
67 return lseek (fd, offset, whence);