Sfairadora

  • Reference Guide

File Opening and Creation

These constants determine the mode of file opening and creation. The values are combined together with the operator | (e.g. FILE_OPEN_READ|FILE_OPEN_WRITE). The value of a specific flag is determined by the binary operator & (e.g. (x & FILE_OPEN_READ)!=0).
The constants are of the type Word.
Name
Description
FILE_OPEN_READ (0x0001)
The file is to be open for reading.
FILE_OPEN_WRITE (0x0002)
The file is to be open for writing.
FILE_OPEN_MUST_EXIST (0x0004)
If the file already exists, the file opening fails.
FILE_OPEN_NEW_ONLY (0x0008)
For file creation: if a file of the specified name already exists, the function fails and returns an error. When the flag is not set, a possible existing file is deleted and a new one is created.
FILE_OPEN_TRUNCATE (0x0010)
If the file exists, its content is deleted on opening.
FILE_OPEN_RANDOM (0x0080)
The flag signifies, that the data from the file will be read in a random order, rather than sequentially. This flag is a mere hint for the operating system to optimize the file access.
FILE_OPEN_SEQ (0x0100)
The flag signifies, that the data from the file will be read sequentially. This flag is a mere hint for the operating system to optimize the file access.
FILE_OPEN_SHARE_READ (0x0200)
The file allows other read accesses
FILE_OPEN_SHARE_WRITE (0x0400)
The file allows other write accesses
FILE_OPEN_ATOMIC (0x0800)
The data is not written to the target file until the close function is called. Prior that, all the modifications can be canceled with the abort function.
If a File variable is destroyed without being closed, and the file was open with the FILE_OPEN_ATOMIC flag, the changes are canceled as if the abort function was called. This can be useful for error handling – when a function is interrupted by occurrence of an Error value, this also makes all possible changes to open files canceled.
FILE_OPEN_BAK_FILE (0x1000)
At closing, the original file is copied with its file name extension changed to .bak. This flag implies the FILE_OPEN_ATOMIC flag.
FILE_OPEN_KEEP_IDENTICAL (0x2000)
If the FILE_OPEN_ATOMIC or FILE_OPEN_BAK_FILE flags are used and the new file content is identical to the original content, the original file is kept including its last modification time.

See Also