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, 2010 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, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
25 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
26 /* Windows platforms. */
27 /* Get GetFileType. */
30 # include <sys/stat.h>
37 rpl_lseek (int fd, off_t offset, int whence)
39 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
40 /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
41 HANDLE h = (HANDLE) _get_osfhandle (fd);
42 if (h == INVALID_HANDLE_VALUE)
47 if (GetFileType (h) != FILE_TYPE_DISK)
53 /* BeOS lseek mistakenly succeeds on pipes... */
55 if (fstat (fd, &statbuf) < 0)
57 if (!S_ISREG (statbuf.st_mode))
63 return lseek (fd, offset, whence);