Untyped
files are low-level I/O channels used primarily for direct access to disk files
regardless of type and structuring. An untyped file is declared with the word file
and nothing more. For example,
var
DataFile: file;
For
untyped files, the Reset and Rewrite procedures allow an extra parameter
to specify the record size used in data transfers. For historical reasons, the
default record size is 128 bytes. A record size of 1 is the only value that
correctly reflects the exact size of any file. (No partial records are possible
when the record size is 1.)
Except for Read and Write, all typed-file standard procedures and functions are also allowed on untyped files. Instead of Read and Write, two procedures called BlockRead and BlockWrite are used for high-speed data transfers.
Standard routines and I/O: Overview
无类型文件是低级I/O通道,它主要用于直接访问磁盘文件,而不管文件的类型和结构。无类型文件的声明只使用保留字file,例如
var
DataFile: file;
对无类型文件调用Reset和Rewrite过程时,允许用额外的参数指定用于数据传输的记录尺寸。由于历史原因(较早的Pascal),缺省的记录尺寸是128字节。记录的尺寸是1时,它仅作为一个特殊的值,用于精确反映任何文件的实际尺寸(记录不可再分是可能的,此时记录尺寸为1)。
除Read和Write外,所有用于类型文件的标准过程和函数也允许用于无类型文件。作为Read和Write的替代例程,BlockRead和BlockWrite用于高速数据传输。