File Open function parameters

Source: Internet
Author: User

I have encountered the o_trunc parameter here. I didn't understand what it meant at the time. Later I gave an example, but Sang couldn't afford it.

 

Int _ open (char * pathname, int access) opens a file for reading or writing,
Press Access to determine whether to read or write files. The access value is shown in the table below.
┌ ── ─ ┬ ── ─
│ Access value │ meaning │
├ ── ─ ┼ ── ─
│ O_rdonly │ read the file │
│ O_wronly │ write a file │
│ O_rdwr │ read and write │
│ O_noinherit │ if the file is not passed to the subroutine, it will be included │
│ O_denyall │ only allow currently processed files that must be accessed │
│ O_denywrite │ read only from any other open files │

│ O_denyread │ only allow writing from any other open files │
│ O_denynone │ allow other files to be shared and opened │
└ ── ─ ┴ ── ─
Int open (char * pathname, int access [, int permiss]) opens a file for reading or writing,
Press Access to determine whether to read or write files. The access value is shown in the table below.
┌ ── ─ ┬ ── ─ ┐
│ Access value │ meaning │
├ ── ─ ┼ ── ─ ┤
│ O_rdonly │ read the file │
│ O_wronly │ write a file │
│ O_rdwr │ read and write │
│ O_ndelay │ not used; compatible with Unix systems │
│ O_append │ read and write, but every write is always added at the end of the file │
│ O_creat │ if the file exists, this mark is useless; if it does not exist, create a new file │
│ O_trunc │ if the file exists, the length is truncated to 0, and the attribute remains unchanged │
│ O_excl │ unused; compatible with Unix systems │
│ O_binary │ this flag can be displayed to open a file in binary format │
│ O_text │ this flag can be used to display and open a file in text format │
└ ── ─ ┴ ── ─ ┘
Permiss is a File Attribute and can be set to the following values:
S_iwrite: s_iread | s_iwrite: Read and Write
Int creat (char * filename, int permiss) creates a new file filename and sets the read/write performance. Permiss indicates file read/write. The value s_iwrite allows s_iread to be read | s_iwrite allows read and write.
Int _ creat (char * filename, int attrib) creates a new file filename and sets the file attributes. Attrib is the file attribute. You can hide the fa_system System for the following value: fa_rdonly read-only fa_hidden.
Int creatnew (char * filenamt, int attrib) creates a new file filename and sets the file attributes. Attrib is the file attribute. You can hide the fa_system System for the following value: fa_rdonly read-only fa_hidden.

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.