filesize
Kenneth Brody
kenbrody at bestweb.net
Fri Mar 14 13:51:32 PDT 2008
Quoting Jeff Harrison (Fri, 14 Mar 2008 12:53:40 -0700 (PDT)):
>> From filepro's help file:
>
> "In a text file, it is possible that the value
> returned by FILESIZE() is not the same number of bytes
> that can be read from the file."
>
> Is there someone out there that can shed a little more
> light on this subject? Will opening the file in
> binary mode bypass this "possible" issue?
Perhaps. (Probably "yes" on all systems filePro currently runs on, but I
can't guarantee it.)
The reason is because of how text files are stored, particularly on Windows
systems. The end of each line is marked by two characters -- CR and LF --
yet in text mode this will read as only 1 character -- LF. Plus, a text
file may have a Ctrl-Z marking EOF.
So, if a file consists of the following sequence of 13 bytes:
61 62 63 64 0A 0D 61 62 63 64 0A 0D 1A
you will read() it as 10 bytes if opened in text mode:
61 62 63 64 0A 61 62 63 64 0A
As such, filesize() will return 13, but you can only read() 10 character.
Note that, if you open the file in binary mode, you will be able to read()
all 13 characters, but you will also see both 0D's (CR) and the 1A (Ctrl-Z),
and you will need to decide what to do with them.
--
KenBrody at BestWeb dot net spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com
More information about the Filepro-list
mailing list