/programs/develop/open watcom/trunk/clib/h/kolibri.h |
---|
99,63 → 99,18 |
#endif |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
#pragma pack(pop) |
#pragma pack(push, 1) |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
#pragma pack(pop) |
#pragma pack(push, 1) |
typedef struct |
{ unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
unsigned init_heap(void); |
163,8 → 118,7 |
unsigned user_free(void *); |
int create_file(const char *name); |
int set_file_size(const char *name, unsigned size); |
int get_fileinfo(const char *name,FILEINFO *info); |
int get_fileinfo(const char *name,FILEINFO* pinfo); |
int read_file (const char *name,void *buff, unsigned offset, unsigned count,unsigned *reads); |
int write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes); |
205,22 → 159,6 |
parm [EAX] value [EAX] \ |
modify [ EBX ]; |
#pragma aux set_file_size = \ |
"push 0" \ |
"push 0" \ |
"mov [esp+1], eax" \ |
"push 0" \ |
"push 0" \ |
"push 0" \ |
"push ebx" \ |
"push 4" \ |
"mov ebx, esp" \ |
"mov eax, 70" \ |
"int 0x40" \ |
"add esp, 28" \ |
parm [EAX] [EBX] value [EAX] \ |
modify [ EBX ]; |
#pragma aux get_fileinfo = \ |
"push 0" \ |
"push 0" \ |
/programs/develop/open watcom/trunk/clib/handleio/oshdl.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/handleio/setmd.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/handleio/fstat.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/handleio/chsizklbr.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/handleio/openklbr.c |
---|
68,10 → 68,6 |
char* buff; |
char c; |
buff = (char*)lib_malloc(strlen(path)+2); |
strcpy(buff, path); |
if(*path == '/') |
{ |
buff = (char*)lib_malloc(strlen(path)+1); |
131,7 → 127,6 |
}; |
}; |
buff[len]= '\0'; |
return buff; |
}; |
176,19 → 171,10 |
path = getfullpath(name); |
err=get_fileinfo(path,&info); |
if( mode & O_EXCL && mode & O_CREAT ) |
if(err=get_fileinfo(path,&info)) |
{ |
if( !err) |
{ |
__set_errno( EEXIST ); |
return (HANDLE)-1; |
}; |
} |
// printf("failed getfileinfo %s\n\r", path); |
if(err) |
{ |
if(mode & O_CREAT) |
err=create_file(path); |
198,12 → 184,9 |
return (HANDLE)-1; |
}; |
}; |
if( mode & O_TRUNC ) |
set_file_size(path, 0); |
if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) ))) |
{ |
lib_free(path); |
{ lib_free(path); |
return (HANDLE)-1; |
}; |
228,8 → 211,9 |
return( -1 ); |
} |
rwmode = mode & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT ); |
rwmode = mode; |
/*** Open the file ***/ |
handle = __openFileHandle( name, mode); |
241,11 → 225,11 |
} |
// Now use the slot we got. |
__setOSHandle( hid, handle ); // JBS 99/11/01 |
iomode_flags = 0; |
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE; |
else if( rwmode == O_RDONLY) iomode_flags |= _READ; |
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE; |
/programs/develop/open watcom/trunk/clib/handleio/qread.c |
---|
46,8 → 46,6 |
int __qread( int handle, void *buffer, unsigned len ) |
{ |
int err; |
__file_handle *fh; |
unsigned amount_read=0; |
54,11 → 52,13 |
__handle_check( handle, -1 ); |
fh = (__file_handle*) __getOSHandle( handle ); |
err = read_file(fh->name,buffer,fh->offset,len,&amount_read); |
fh->offset+=amount_read; |
if(err) |
if(read_file(fh->name,buffer,fh->offset,len,&amount_read)) |
{ |
if ( amount_read == 0) |
return (-1); |
} |
fh->offset+=amount_read; |
return( amount_read ); |
}; |
/programs/develop/open watcom/trunk/clib/handleio/write.c |
---|
44,7 → 44,6 |
#include "rtdata.h" |
#include "seterrno.h" |
#include "lseek.h" |
#include "kolibri.h" |
/* |
The _lwrite function writes data to the specified file. |
143,6 → 142,8 |
unsigned int offset; |
}__file_handle; |
int _stdcall write_file (const char *name,const void* buff,unsigned offset, unsigned count,unsigned *reads); |
static int os_write( int handle, const void *buffer, unsigned len, unsigned *amt ) |
/********************************************************************************/ |
{ |
153,9 → 154,12 |
fh = (__file_handle*) __getOSHandle( handle ); |
rc = write_file(fh->name,buffer,fh->offset,len,amt); |
fh->offset+= *amt; |
if(write_file(fh->name,buffer,fh->offset,len,amt)) |
{ |
rc = __set_errno_nt(); |
}; |
if( *amt != len ) |
{ |
rc = ENOSPC; |
/programs/develop/open watcom/trunk/clib/handleio/read.c |
---|
41,7 → 41,6 |
#include "rtdata.h" |
#include "seterrno.h" |
#include "lseek.h" |
#include "kolibri.h" |
typedef struct |
{ |
49,6 → 48,9 |
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; |
58,11 → 60,8 |
BOOL rc; |
HANDLE h; |
unsigned amount_read; |
int err; |
__file_handle *fh; |
__handle_check( handle, -1 ); |
__ChkTTYIOMode( handle ); |
iomode_flags = __GetIOMode( handle ); |
83,15 → 82,14 |
if( iomode_flags & _BINARY ) /* if binary mode */ |
{ |
err=read_file(fh->name,buffer,fh->offset,len,&amount_read); |
fh->offset+=amount_read; |
total_len = amount_read; |
if(err) |
if(read_file(fh->name,buffer,fh->offset,len,&amount_read)) |
{ |
if ( amount_read == 0) |
return (-1); |
} |
fh->offset+=amount_read; |
total_len = amount_read; |
} |
else |
{ |
total_len = 0; |
98,12 → 96,13 |
read_len = len; |
do |
{ |
err=read_file(fh->name,buffer,fh->offset,len,&amount_read); |
fh->offset+=amount_read; |
if(read_file(fh->name,buffer,fh->offset,len,&amount_read)) |
{ |
if( amount_read == 0 ) |
break; /* EOF */ |
{ /* EOF */ |
break; |
} |
} |
reduce_idx = 0; |
finish_idx = reduce_idx; |
for( ; reduce_idx < amount_read; ++reduce_idx ) |