On Time RTOS-32 Documentation
Welcome
RTTarget-32
RTKernel-32
RTFiles-32
RTFiles-32 Programming Manual
RTFiles-32 Reference Manual
Introduction
General File I/O
Function RTFOpen
Function RTFClose
Function RTFRead
Function RTFWrite
Function RTFSeekEx
Function RTFSeek
Function RTFExtendEx
Function RTFCommit
Function RTFTruncate
Information about Files
File Attributes
Directories
Finding Files
File Name Operations
Disk and Volume Management
Miscellaneous File Functions
Raw I/O Functions
Functions for Debugging
Device Dependent Functions
Obsolete Functions
Disk Device Driver API
MTD Device Driver API
RTFiles-32 Error Codes
Code Page Reference
RTIP-32
RTPEG-32
RTUSB-32
|
Function RTFOpen
RTFOpen opens and possibly creates a file for subsequent read and/or write access:
RTFHANDLE RTFOpen(const char * FileName, DWORD Flags);
ParametersFileNamePointer to the name of the file to open/create. File names are not case sensitive. The file name can have one of the following formats:
Value |
Meaning |
[Drive:][\][Path\]Name |
A data file or directory file name with optional drive and path information. |
[Drive:]\ |
A root directory. |
\\.\Drive: |
A logical drive. |
\\.\PHYSICALDRIVEx |
A physical hard disk. x must be a digit (starting at '0') specifying the desired hard disk. |
Drive must be single letter greater or equal to 'A'.
FlagsCan be a combination of the following flags:
Value |
Meaning |
RTF_READ_WRITE |
The file is opened for read and write access. |
RTF_READ_ONLY |
The file is opened for read only access. |
RTF_OPEN_SHARED |
Opening the file multiple times should not generate an "access denied" error. By default, RTFiles-32 will allow the same file to be opened several times only if all instances of the file are opened with read only access. However, if one or more instances also require write access and all instances specify this flag, the call succeeds. Note that a drive file or device file spans one or more logical drives and thus conflicts with any other file on the respective drive or device. |
RTF_OPEN_NO_DIR |
Do not open directories. Use this flag to avoid accidentally opening directories. |
RTF_OPEN_DIR |
Overrides flag RTF_OPEN_NO_DIR and forces support for opening a directory. Directories can only be opened with read only access. |
RTF_CREATE |
Instructs RTFOpen to create the file if it does not exist. |
RTF_CREATE_ALWAYS |
Instructs RTFOpen to create the file even if it already exists. |
RTF_COMMITTED |
Specifies that all updates to the file should be written to the physical device immediately. This includes the directory entry for the file as well as the drive's FAT when the file's size changes. Use this flag with care, since the performance penalty can be severe. By default, RTFiles-32 will flush data buffers when the file pointer leaves a sector and it will flush FAT and directory data when the file is closed. |
RTF_CACHE_DATA |
Instructs RTFiles-32 not to discard data buffers for this file. This option is useful during random access where small blocks are read with frequent interleaving seek operations. In this case, RTFiles-32's internal buffers will serve as a cache for the file. By default, RTFiles-32 assumes that files are read or written sequentially and will therefore discard data buffers when the file pointer leaves a sector. |
RTF_LAZY_DATA |
Instructs RTFiles-32 not to flush dirty (modified) data buffers when the file pointer leaves a sector. This flag automatically also sets RTF_CACHE_DATA. This flag can improve performance when the same data is written several times, since data which would get overwritten will never actually be written to the disk. Such unflushed (lazy) data buffers will be flushed when the file is closed, or when the last file on the same drive is closed on drives with device option RTF_DEVICE_LAZY_WRITE. |
RTF_ATTR_HIDDEN,
RTF_ATTR_SYSTEM,
RTF_ATTR_ARCHIVE |
If RTFOpen creates the file, any combination of these file attributes may be set. The file will be created with all specified attributes set. |
return valueIf the function succeeds, the return value is a file handle for the opened file and the file pointer of the file is set to 0. If the return value is less than 0, the function has failed and the return value is the error code. All possible error codes are given in section RTFiles-32 Error Codes. Function RTFErrorMessage can be used to display a meaningful message string for the error code.
General File I/O
Function RTFClose
|