diff options
Diffstat (limited to 'mysys/my_os2file64.c')
-rw-r--r-- | mysys/my_os2file64.c | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c index 8964e562ea1..b7ee40d292e 100644 --- a/mysys/my_os2file64.c +++ b/mysys/my_os2file64.c @@ -22,7 +22,6 @@ void _OS2errno( APIRET rc); longlong _lseek64( int fd, longlong offset, int seektype); int _lock64( int fd, int locktype, my_off_t start, my_off_t length, myf MyFlags); -int _sopen64( const char *name, int oflag, int shflag, int mask); // // this class is used to define a global c++ variable, that @@ -255,7 +254,7 @@ int _lock64( int fd, int locktype, my_off_t start, return(-1); } -int _sopen64( const char *name, int oflag, int shflag, int mask) +int _sopen( const char *name, int oflag, int shflag, int mask) { int fail_errno; APIRET rc = 0; @@ -325,17 +324,60 @@ int _sopen64( const char *name, int oflag, int shflag, int mask) return hf; } -inline int open( const char *name, int oflag) +int read( int fd, void *buffer, unsigned int count) { - return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE); + APIRET rc; + ULONG actual; + + rc = DosRead( fd, (PVOID) buffer, count, &actual); + + if (!rc) + return( actual);/* NO_ERROR */ + + // set errno + _OS2errno( rc); + // write failed + return(-1); } -inline int open( const char *name, int oflag, int mask) +int write( int fd, const void *buffer, unsigned int count) { - return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, mask); + APIRET rc; + ULONG actual; + + rc = DosWrite( fd, (PVOID) buffer, count, &actual); + + if (!rc) + return( actual);/* NO_ERROR */ + + // set errno + _OS2errno( rc); + // write failed + return(-1); +} + +int close( int fd) +{ + APIRET rc; + ULONG actual; + + rc = DosClose( fd); + + if (!rc) + return( 0);/* NO_ERROR */ + + // set errno + _OS2errno( rc); + // write failed + return(-1); } -inline int sopen( const char *name, int oflag, int shflag, int mask) +inline int open( const char *name, int oflag) +{ + return sopen( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE); +} + +inline int open( const char *name, int oflag, int mask) { - return _sopen64( name, oflag, shflag, mask); + return sopen( name, oflag, OPEN_SHARE_DENYNONE, mask); } |