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.