[fpc-pascal]File errors

Peter Vreman peter at freepascal.org
Mon May 5 11:52:46 CEST 2003


> On Mon, May 05, 2003 at 11:35:14AM +0200, Peter Vreman wrote:
>> > Hi,
>> >
>> > How do you check for file errors such as "Disk Full" before attempting
>> > to write out a file to disk ?
>> > You can easily check if a file exists with the fileExists function...
>> > Can something similar be done for other file errors ?
>>
>> You can check with diskfree() how much space is left on a disk
>
> Well the program I'm developing is irc services, any particular way
> you'd reccomend recoding it so it doesn't crash because of a 'Disk Full'
> error ?

You can turn of io-checking and check the result of ioresult

{$I-}
 writeln(flog,logmessage)
{$I+}
if ioresult<>0 then
 writeln(stderr,'Error writing to disk');






More information about the fpc-pascal mailing list