21 lines
515 B
Text
21 lines
515 B
Text
MODULE FileTest EXPORTS Main;
|
|
|
|
IMPORT IO, Fmt, FS, File, OSError, Pathname;
|
|
|
|
PROCEDURE FileExists(file: Pathname.T): BOOLEAN =
|
|
VAR status: File.Status;
|
|
BEGIN
|
|
TRY
|
|
status := FS.Status(file);
|
|
RETURN TRUE;
|
|
EXCEPT
|
|
| OSError.E => RETURN FALSE;
|
|
END;
|
|
END FileExists;
|
|
|
|
BEGIN
|
|
IO.Put(Fmt.Bool(FileExists("input.txt")) & "\n");
|
|
IO.Put(Fmt.Bool(FileExists("/input.txt")) & "\n");
|
|
IO.Put(Fmt.Bool(FileExists("docs/")) & "\n");
|
|
IO.Put(Fmt.Bool(FileExists("/docs")) & "\n");
|
|
END FileTest.
|