io.mh

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

MH
179
字号
/*
 *  io.h        Low level I/O routines that work with file handles
 *
:include crwat.sp
 */
#ifndef _IO_H_INCLUDED
#define _IO_H_INCLUDED
:include readonly.sp
:include cpluspro.sp

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif

#ifndef __TYPES_H_INCLUDED
 #include <sys/types.h>
#endif

:include pshpackl.sp

:include timet.sp

:include wchar_t.sp

:include maxpath.sp

/* Symbolic constants for the access() function */

#define R_OK    4       /*  Test for read permission    */
#define W_OK    2       /*  Test for write permission   */
#define X_OK    1       /*  Test for execute permission */
#define F_OK    0       /*  Test for existence of file  */

#define ACCESS_WR       0x0002
#define ACCESS_RD       0x0004

/* Symbolic constants for the lseek() function */

#define SEEK_SET    0           /* Seek relative to the start of file   */
#define SEEK_CUR    1           /* Seek relative to current position    */
#define SEEK_END    2           /* Seek relative to the end of the file */

/* Symbolic constants for stream I/O */

#define STDIN_FILENO    0
#define STDOUT_FILENO   1
#define STDERR_FILENO   2
#ifndef NO_EXT_KEYS     /* extensions enabled */
#if ! defined(__NT__)
#define STDAUX_FILENO   3
#define STDPRN_FILENO   4
#endif
#endif


typedef unsigned long   _fsize_t;

struct _finddata_t {
    unsigned    attrib;
    time_t      time_create;
    time_t      time_access;
    time_t      time_write;
    _fsize_t    size;
    char        name[_MAX_PATH];
};

struct _wfinddata_t {
    unsigned    attrib;
    time_t      time_create;
    time_t      time_access;
    time_t      time_write;
    _fsize_t    size;
    wchar_t     name[_MAX_PATH];
};

#ifdef __WATCOM_INT64__
struct _finddatai64_t {
    unsigned    attrib;
    time_t      time_create;
    time_t      time_access;
    time_t      time_write;
    __int64     size;
    char        name[_MAX_PATH];
};

struct _wfinddatai64_t {
    unsigned    attrib;
    time_t      time_create;
    time_t      time_access;
    time_t      time_write;
    __int64     size;
    wchar_t     name[_MAX_PATH];
};
#endif

/* File attribute constants for attrib field */
#define _A_NORMAL       0x00    /* Normal file - read/write permitted */
#define _A_RDONLY       0x01    /* Read-only file */
#define _A_HIDDEN       0x02    /* Hidden file */
#define _A_SYSTEM       0x04    /* System file */
#define _A_SUBDIR       0x10    /* Subdirectory */
#define _A_ARCH         0x20    /* Archive file */


_WCRTLINK extern int  access(const char *__path,int __mode);
_WCRTLINK extern int  _access(const char *__path,int __mode);
_WCRTLINK extern int  chmod(const char *__path,int __pmode);
_WCRTLINK extern int  chsize(int __handle,long __size);
_WCRTLINK extern int  close(int __handle);
_WCRTLINK extern int  _close(int __handle);
_WCRTLINK extern int  creat(const char *__path,int __pmode);
_WCRTLINK extern int  dup(int __handle);
_WCRTLINK extern int  _dup(int __handle);
_WCRTLINK extern int  dup2(int __handle1,int __handle2);
_WCRTLINK extern int  eof(int __handle);
_WCRTLINK extern long filelength(int __handle);
_WCRTLINK extern int  fsync( int __filedes );
_WCRTLINK extern long _get_osfhandle( int __posixhandle );
_WCRTLINK extern int  _hdopen(int __handle,int __mode);
_WCRTLINK extern int  isatty(int __handle);
_WCRTLINK extern int  lock(int __handle,unsigned long __offset,
                           unsigned long __nbytes);
_WCRTLINK extern off_t lseek(int __handle,off_t __offset,int __origin);
_WCRTLINK extern off_t _lseek(int __handle,off_t __offset,int __origin);
_WCRTLINK extern int  open(const char *__path,int __oflag,...);
_WCRTLINK extern int  _open(const char *__path,int __oflag,...);
_WCRTLINK extern int  _open_osfhandle( long __osfhandle, int __flags );
_WCRTLINK extern int  _os_handle(int __handle);
_WCRTLINK extern int  _pipe( int *__phandles, unsigned __psize, int __textmode );
_WCRTLINK extern int  read(int __handle,void *__buf,unsigned int __len);
_WCRTLINK extern int  setmode(int __handle,int __mode);
_WCRTLINK extern int  _setmode(int __handle,int __mode);
_WCRTLINK extern int  sopen(const char *__path,int __oflag,int __shflag,...);
_WCRTLINK extern off_t tell(int __handle);
_WCRTLINK extern int  umask(int __permission);
_WCRTLINK extern int  unlink(const char *__path);
_WCRTLINK extern int  unlock(int __handle,unsigned long __offset,
                             unsigned long __nbytes);
_WCRTLINK extern int  write(int __handle,const void *__buf,unsigned int __len);
_WCRTLINK extern int  _waccess(const wchar_t *__path,int __mode);
_WCRTLINK extern int  _wchmod( const wchar_t *__path, int __pmode );
_WCRTLINK extern int  _wunlink(const wchar_t *__path);

_WCRTLINK extern long _findfirst( const char *__filespec,
                                  struct _finddata_t *__fileinfo );
_WCRTLINK extern long _wfindfirst( const wchar_t *__filespec,
                                   struct _wfinddata_t *__fileinfo );
_WCRTLINK extern int  _findnext( long __handle,
                                 struct _finddata_t *__fileinfo );
_WCRTLINK extern int  _wfindnext( long __handle,
                                  struct _wfinddata_t *__fileinfo );
_WCRTLINK extern int  _findclose( long __handle );

_WCRTLINK extern char       *_mktemp( char *__template );
_WCRTLINK extern wchar_t    *_wmktemp( wchar_t *__template );

#ifdef __WATCOM_INT64__
_WCRTLINK extern long       _findfirsti64( const char *__filespec,
                                           struct _finddatai64_t *__fileinfo );
_WCRTLINK extern long       _wfindfirsti64( const wchar_t *__filespec,
                                            struct _wfinddatai64_t *__fileinfo );
_WCRTLINK extern int        _findnexti64( long __handle,
                                          struct _finddatai64_t *__fileinfo );
_WCRTLINK extern int        _wfindnexti64( long __handle,
                                           struct _wfinddatai64_t *__fileinfo );
_WCRTLINK extern __int64    _filelengthi64( int __handle );
_WCRTLINK extern __int64    _lseeki64( int __handle, __int64 __offset,
                                       int __origin );
_WCRTLINK extern __int64    _telli64( int __handle );
#endif

#ifndef _STAT_H_INCLUDED
 #include <sys/stat.h>
#endif

:include poppack.sp
:include cplusepi.sp
#endif

⌨️ 快捷键说明

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