CFile Open File Mode summary

Source: Internet
Author: User
Knowledge and skills need to accumulate in the process of daily drip, so we should strengthen the summary and accumulation of this aspect. The following is a summary of the classification and specification of the CFile class open file pattern. Cfile::modecreate creates a new file directly. If the file already exists, the contents of the file are automatically zeroed.
Cfile::modenotruncate This value is used in general modecreate combinations. If you create a file that already exists, it will not be zeroed. The file can be opened reliably, either by creating a new file or by opening an existing file. This is useful for opening a settings file that may not exist. This option is commonly available for cstdiofile.
Cfile::moderead Open the file as read-only.
Cfile::modereadwrite opens the file in a readable and writable manner.
Cfile::modewrite opens the file as a write-only method.
Cfile::modenoinherit prevents file quilt process inheritance.
Cfile::sharedenynone opens the file read and write mode without denying other processes. If the file is already open in compatibility mode by another process, the file creation fails.
Cfile::sharedenyread to deny other processes the means to read the file. If the file has been opened in compatibility mode or read by another process, the file creation failed.
Cfile::sharedenywrite to turn off the way that other processes write to the file. If the file has been opened by another process in compatibility mode or write, the file creation failed.
Cfile::shareexclusive is opened in exclusive mode, denying other processes access to the file. Build fails if the file has been opened in any way by any process.
Cfile::sharecompat This flag is not valid in 32-bit MFC. This flag is mapped to cfile::shareexclusive when CFile::Open is used.
Cfile::typetext opens in text mode.
The cfile::typebinary is opened in binary mode (used only in derived classes).
Cfile::osnobuffer system Open file does not open system cache. You can view the file_flag_no_buffering of CreateFile in the Platform SDK.
Cfile::oswritethrough a flag that passes through any cache and writes the disk directly. You can view the File_flag_write_through of CreateFile in the Platform SDK.
cfile::osrandomaccess random Access file mode. The system optimizes file buffers in this way.
cfile::ossequentialscan     access to the file in the order from beginning to end. The system uses this method to optimize the file buffer. You can view the File_flag_sequential_scan of CreateFile in PLATFORM SDK. There are several patterns that may be advanced in the SDK, not used very often, but should be able to meet some of the user's advanced requirements on some occasion. Because I have not used, so there may be a deviation in the understanding of translation. If you have the opportunity to understand thoroughly, then to revise it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.