File I/O

File I/O

Top  Previous  Next

File I/O intrinsics operate the same way as in the standard version of XPL with some minor exceptions.

 

1. Buffer Size. In standard XPL there are two types of disk I/O: buffered and unbuffered. With buffered disk I/O the data are sent to and read from a buffer in memory. This way a program only accesses the hardware disk when it absolutely must. With unbuffered I/O every character is sent directly to the disk. Since writing to memory is much faster than calling the disk I/O routines, buffered I/O is much faster. The downside of this is that standard XPL only allows one buffered input and one buffered output file at a time. In EXPL all disk files are buffered, even if an unbuffered file is specified.

 

2. Automatic File Closing. If an XPL program running in the IDE opens a file and doesn't close it, the file will be marked as "in use" by the operating system even after the XPL program terminates. This is because the development environment is still running, and the operating system won't automatically close the file. As a result, if you try to re-run the program without closing the EXPL development environment, the program will be unable to open the file because the operating system still considers it in use. To solve this problem, the intrinsics package keeps a list of all open files and closes any unclosed handles when the XPL program terminates.