d_creat.gml

来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 49 行

GML
49
字号
.func _dos_creat
#include <&doshdr>
unsigned _dos_creat( const char *path,
                     unsigned attribute,
                     int *&fd );
.ixfunc2 '&DosFunc' &func
.ixfunc2 '&OsIo' &func
.funcend
.desc begin
The &func function uses system call 0x3C to create a new file named
.arg path,
with the access attributes specified by
.arg attribute.
The &handle for the new file is returned in the word pointed to by
.arg &fd..
If the file already exists, the contents will be erased, and the
attributes of the file will remain unchanged.
.im creatatt
.desc end
.return begin
The &func function returns zero if successful.
Otherwise, it returns an OS error code and sets
.kw errno
accordingly.
.return end
.see begin
.seelist &function. creat _dos_creat _dos_creatnew _dos_open _dos_open
.seelist &function. open fdopen fopen freopen _fsopen _grow_handles
.seelist &function. _hdopen open _open_osfhandle _popen sopen
.see end
.exmp begin
#include <stdio.h>
#include <&doshdr>
.exmp break
void main()
  {
    int &fd;
.exmp break
    if( _dos_creat( "file", _A_NORMAL, &amp.&fd ) != 0 ){
      printf( "Unable to create file\n" );
    } else {
      printf( "Create succeeded\n" );
      _dos_close( &fd );
    }
  }
.exmp end
.class DOS
.system

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?