PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Loren Doornek on October 21, 2019, 11:02:11 AM

Title: FIN(x,"filelength") returns a negative value
Post by: Loren Doornek on October 21, 2019, 11:02:11 AM
On a particular Linux system, FIN(x,"filelength") is returning a negative number for large files (>2.4Gb), but DEC($00$+MID(FIN(x),1,4)) does properly return the file size.  I suspect some 32-bit/64-bit issue, but Linux is 64-bit, and PXPlus is version 12, so it seems that that the "filelength" should work.  I've also tested on version 12 in our development system, and it works fine.  Any suggestions on what I might look at to figure out why the "filelength" isn't working in some systems?

-}open(1)"/usr/common/bigfile.zip"
-}print fin(1,"filelength")
-1472746782
-}print dec($00$+mid(fin(1),1,4))
 2822220514
-}end
-}print ssn
1250-664-0656993
-}print tcb(29)
 12500002
Title: Re: FIN(x,"filelength") returns a negative value
Post by: Mike King on October 21, 2019, 01:28:59 PM
You may want to check the OS versions.

On Linux we issue a fstat call to ask for the file size which should return a 64 bit value on a system that supports larger files however its possible this may not be the case.  Also, if using multi-segmented files there was a fix in version 13 to properly return the sum of all segments.