| 1234567891011121314151617 |
- MODULE TBadFile;
- // A failed file open returns NIL; file operations on it must degrade
- // safely (no SIGSEGV). The path below cannot be opened. Exit 42.
- IMPORT Files;
- VAR ExitCode : INTEGER;
- VAR f : Files.File;
- VAR n : INTEGER;
- BEGIN
- f := Files.OpenWrite("no/such/dir/_t_badfile.txt");
- Files.WriteChar(f, 'x'); (* NIL handle: must be a no-op *)
- Files.WriteInt(f, 123);
- Files.Close(f);
- f := Files.OpenRead("no/such/dir/_t_badfile.txt");
- n := Files.ReadInt(f); (* NIL handle: must return 0 *)
- Files.Close(f);
- ExitCode := 42
- END TBadFile.
|