$IOChecks Compiler Directive
When
$IOChecks
is enabled, Delphi checks the results of
all I/O functions and reports an I/O runtime error if a function
fails. With $IOChecks
disabled, you must call the
IOResult
function to learn whether an I/O
operation succeeded.
// Return True if the named file is a PostScript file, // and False if the file does not exist or is not a PostScript file. // A PostScript file starts with the characters '%!'. function IsPostScript(const FileName: string): Boolean; type TPair = array[0..1] of Char; const PostScript: TPair = '%!'; var F: File of TPair; Pair: TPair; begin AssignFile(F, FileName); FileMode := 0; {$IOChecks Off} Reset(F); Read(F, Pair); {$IOChecks On} Result := (IOResult = 0) and (Pair = PostScript); CloseFile(F); end;