Clib chsize, fstat, setmode.

set_file_size: watcom-specific implementation

git-svn-id: svn://kolibrios.org@727 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2008-02-10 14:10:44 +00:00
parent 26580c8bd1
commit a73bea0da8
9 changed files with 481 additions and 44 deletions

View File

@@ -41,6 +41,7 @@
#include "rtdata.h"
#include "seterrno.h"
#include "lseek.h"
#include "kolibri.h"
typedef struct
{
@@ -48,9 +49,6 @@ typedef struct
unsigned int offset;
}__file_handle;
int _stdcall read_file (const char *name,char *buff,unsigned offset, unsigned count,unsigned *reads);
_WCRTLINK int read( int handle, void *buf, unsigned len )
{
unsigned read_len, total_len;
@@ -60,8 +58,11 @@ _WCRTLINK int read( int handle, void *buf, unsigned len )
BOOL rc;
HANDLE h;
unsigned amount_read;
int err;
__file_handle *fh;
__handle_check( handle, -1 );
__ChkTTYIOMode( handle );
iomode_flags = __GetIOMode( handle );
@@ -82,13 +83,14 @@ _WCRTLINK int read( int handle, void *buf, unsigned len )
if( iomode_flags & _BINARY ) /* if binary mode */
{
if(read_file(fh->name,buffer,fh->offset,len,&amount_read))
{
if ( amount_read == 0)
return (-1);
}
err=read_file(fh->name,buffer,fh->offset,len,&amount_read);
fh->offset+=amount_read;
total_len = amount_read;
if(err)
if ( amount_read == 0)
return (-1);
}
else
{
@@ -96,13 +98,12 @@ _WCRTLINK int read( int handle, void *buf, unsigned len )
read_len = len;
do
{
if(read_file(fh->name,buffer,fh->offset,len,&amount_read))
{
if( amount_read == 0 )
{ /* EOF */
break;
}
}
err=read_file(fh->name,buffer,fh->offset,len,&amount_read);
fh->offset+=amount_read;
if( amount_read == 0 )
break; /* EOF */
reduce_idx = 0;
finish_idx = reduce_idx;
for( ; reduce_idx < amount_read; ++reduce_idx )