home *** CD-ROM | disk | FTP | other *** search
- {*************************************************************************}
- { }
- { FILSIZ }
- { Copyright by Ron Sparks - Not for Sale without Written Permission }
- { Significant portions coauthored by Jim Keohane }
- { Personal use is approved without permission if the }
- { author's names are included }
- { }
- { First version - April 12, 1986 }
- { }
- { Revision History: }
- { }
- { Date Modification }
- { ====== =============================== }
- { }
- { }
- { }
- { }
- { GENERAL COMMENTS }
- { ---------------- }
- { This routine was inspired by and contains significant portions of }
- { the "FILESIZE" routine originated by Jim Keohane on BIX in Apr 86 }
- { Revisions and upgrades were added by Ron Sparks. This procedure }
- { can return the filesize of the file sent in by variable phile. It }
- { must have been previously assigned and opened. This routine is now }
- { nondestructive of the file pointer position. If LOCN is true the }
- { function returns the current position of the pointer in bytes from }
- { the start of the file. This may be used to indicate progress in }
- { processing a file. It returns a Real value as opposed to Turbo's }
- { builtin function which returns an integer. }
- { }
- {*************************************************************************}
-
- {-------------------------------------------------------------> Filesiz }
- FUNCTION FilSize(VAR phile : filtyp; VAR locn : Boolean) : Real;
- { original author - Jim Keohane placed in public domain }
- { Additions and revisions by Ron Sparks Apr 12, 1986 }
- { Revisions include With statement, Handle name & Format }
- { Additions include code to make filesize nondestructive to current }
- { file pointer location. Also added is code to get current}
- { position in file for Percent read calculations }
-
-
- TYPE
- intregs = RECORD
- CASE Integer OF
- 0 : (ax, bx, cx, dx, bp, si, di, ds, es, flags : Integer);
- 1 : (al, ah, bl, bh, cl, ch, dl, dh : Byte);
- END;
- VAR
- reg : intregs;
- Curptroff, curptrseg : Integer;
- temp1, temp2 : Real;
- BEGIN
- WITH reg DO
- BEGIN
- ax := $4201; { First find out where you are }
- bx := Mem[Seg(phile):Ofs(phile)];
- cx := 0;
- dx := 0;
- MsDos(reg);
- temp1 := ax;
- temp2 := dx;
- IF NOT Locn THEN
- BEGIN
- curptrseg := dx; { Now save current pointers }
- curptroff := ax; { ... stuffing your own value here }
- ax := $4202; { would allow you to position }
- cx := 0; { anywhere in file you wish.... }
- dx := 0;
- MsDos(reg);
- temp1 := ax;
- temp2 := dx;
- ax := $4200; {And reposition back where you}
- cx := curptrseg; {were. }
- dx := curptroff;
- MsDos(reg);
- END;
- IF (flags AND $01) = 1 THEN
- filsize := 0
- ELSE
- IF temp1 >= 0 THEN
- filsize := (temp2*65536.0)+temp1
- ELSE
- filsize := (temp2*65536.0)+(temp1+65536.0);
- END;
- END;
-