X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=lib%2Flseek.c;fp=lib%2Flseek.c;h=0000000000000000000000000000000000000000;hp=f2ed8bb54c135f698acfc730574d412561d72ecc;hb=9c23efbf57cbfe4ba0fbe833c6956bf567b5b00e;hpb=282798f52e2cde76eaeb1384d6fcbdc624c79611 diff --git a/lib/lseek.c b/lib/lseek.c deleted file mode 100644 index f2ed8bb5..00000000 --- a/lib/lseek.c +++ /dev/null @@ -1,62 +0,0 @@ -/* An lseek() function that detects pipes. - Copyright (C) 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include - -/* Specification. */ -#include - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* Windows platforms. */ -/* Get GetFileType. */ -# include -#else -# include -#endif -#include - -#undef lseek - -off_t -rpl_lseek (int fd, off_t offset, int whence) -{ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */ - HANDLE h = (HANDLE) _get_osfhandle (fd); - if (h == INVALID_HANDLE_VALUE) - { - errno = EBADF; - return -1; - } - if (GetFileType (h) != FILE_TYPE_DISK) - { - errno = ESPIPE; - return -1; - } -#else - /* BeOS lseek mistakenly succeeds on pipes... */ - struct stat statbuf; - if (fstat (fd, &statbuf) < 0) - return -1; - if (!S_ISREG (statbuf.st_mode)) - { - errno = ESPIPE; - return -1; - } -#endif - return lseek (fd, offset, whence); -}