home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
biblioteki
/
c_library
/
asyncio
/
source
/
closeasync.c
< prev
next >
Wrap
C/C++ Source or Header
|
1977-12-31
|
812b
|
48 lines
#include "async.h"
_ASM LibCall _ARGS LONG
CloseAsync( _REG( a0 ) AsyncFile *file )
{
LONG result;
if( file )
{
#ifdef ASIO_NOEXTERNALS
struct ExecBase *SysBase = file->af_SysBase;
struct DosLibrary *DOSBase = file->af_DOSBase;
#endif
result = AS_WaitPacket( file );
if( result >= 0 )
{
if( !file->af_ReadMode )
{
/* this will flush out any pending data in the write buffer */
if( file->af_BufferSize > file->af_BytesLeft )
{
result = Write(
file->af_File,
file->af_Buffers[ file->af_CurrentBuf ],
file->af_BufferSize - file->af_BytesLeft );
}
}
}
if( file->af_CloseFH )
{
Close( file->af_File );
}
FreeVec(file);
}
else
{
#ifndef ASIO_NOEXTERNALS
SetIoErr( ERROR_INVALID_LOCK );
#endif
result = -1;
}
return( result );
}