Mail Archives: djgpp-workers/2001/01/24/19:36:05
> > + 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 <errno.h>
#include <dpmi.h>
#include <libc/dosio.h>
+ #include <go32.h>
+ #include <sys/farptr.h>
+ #include <dos.h>
+ #include <fcntl.h>
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 */
- Raw text -