filesize
Jeff Harrison
jeffaharrison at yahoo.com
Fri Mar 14 14:04:54 PDT 2008
--- Kenneth Brody <kenbrody at bestweb.net> wrote:
> 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.
>
> --
Oh, I know what to do with them! :-)
Thanks. I was just looking for some affirmation that
filesize() will return the actual size of the file.
Reading the help file made it sound like that was not
necessarily the case.
Jeff Harrison
jeffaharrison at yahoo.com
Author of JHExport and JHImport. The fastest and
easiest ways to generate filepro exports and imports.
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the Filepro-list
mailing list