[fpc-pascal]filesize
Jonas Maebe
jonas at zeus.rug.ac.be
Wed Jul 24 16:00:23 CEST 2002
On Wed, 24 Jul 2002, Adam Naumowicz wrote:
> > Strange, when I just tested it, the error was caused by reset.
>
> That is really strange :-)
> On my system the prog below runs without errors.
>
> program tester;
>
> var f:file of char;
>
> begin
> filemode:=0;
Here you set filemode to 0, so it's normal that this runs without error.
> assign(f,'/etc/passwd');
> reset(f);
> // writeln(FileSize(f));
> close(f);
> end.
>
> GDB located the error at FileSize, so that was while I said so.
Did you compile it with IO checking on? (-Ci, or add {$i+} at the top) Try
also compiling with -gl, then the program will write out the position in
the source where the problem occurred.
> Therefore my question is still valid - should a call to a routine as
> FileSize or Read cause an error when a FileMode is default ?
Yes, if you have read-only access to that file, but the error should
already happen right after the the reset call. Since the file isn't
successfully opened, the read/filesize/... will also produce errors since
they're called to operate on an unopened file.
> I checked that the same test program doesn't complain when compiled
> with GPC, with Kylix error #13 is raised.
GPC isn't a very good reference, since it's TP compatibility isn't that
good. I don't have a clue what error #13 is supposed to be.
Jonas
More information about the fpc-pascal
mailing list