From: "Mark E." To: djgpp-workers AT delorie DOT com Date: Wed, 24 Jan 2001 19:35:45 -0500 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: filelength and errno patch Message-ID: <3A6F2E91.17471.6D5BA@localhost> In-reply-to: <3405-Wed24Jan2001222741+0200-eliz@is.elta.co.il> References: <3A6EF1B9 DOT 6453 DOT 3E8C83 AT localhost> (snowball3 AT bigfoot DOT com) X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > > + if (_osmajor >= 7 && _osmajor < 10) > > + { > > + regs.x.ax = 0x71A6; > > + regs.x.bx = fhandle; > Does this work on plain DOS 7 or only on Windows 9X? If the latter, > you will need to test _USE_LFN, I think. I tried it under DOS 7.{whatever} and it doesn't work. So I added the _USE_LFN test. Here's a revised patch. Let me know if it and the errno patch are ok. Index: filelen.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/filelen.c,v retrieving revision 1.1 diff -c -p -r1.1 filelen.c *** filelen.c 1995/03/29 20:55:56 1.1 --- filelen.c 2001/01/24 23:13:55 *************** *** 1,3 **** --- 1,4 ---- + /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* This is file FILELEN.C */ /* *************** *** 11,16 **** --- 12,21 ---- #include #include #include + #include + #include + #include + #include long __filelength(int); *************** __filelength(int fhandle) *** 21,26 **** --- 26,56 ---- unsigned short fpos_high, fpos_low; long retval; + /* Use the LFN API when available to get the file length. */ + if (_osmajor >= 7 && _osmajor < 10 && _USE_LFN) + { + regs.x.ax = 0x71A6; + regs.x.bx = fhandle; + regs.x.ds = __tb >> 4; + regs.x.dx = 0; + regs.x.flags |= 1; + __dpmi_int(0x21, ®s); + + if ((regs.x.flags & 1) == 0) + { + /* Offset 0x24 contains the low 32-bits of the file size. + Offset 0x20 contains the high 32-bits. */ + retval = _farpeekl(_dos_ds, __tb + 0x24); + + if (_farpeekl(_dos_ds, __tb + 0x20) != 0) + { + errno = EOVERFLOW; + return -1L; + } + return retval; + } + } + /* Remember the current file position, so we can return there later. */ regs.x.ax = 0x4201; /* set pointer from current position */