home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / c_library / asyncio / source / openasync.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  841b  |  42 lines

  1. #include "async.h"
  2.  
  3. #ifdef ASIO_NOEXTERNALS
  4. _ASM LibCall _ARGS AsyncFile *
  5. OpenAsync(
  6.     _REG( a0 ) const STRPTR fileName,
  7.     _REG( d0 ) OpenModes mode,
  8.     _REG( d1 ) LONG bufferSize,
  9.     _REG( a1 ) struct ExecBase *SysBase,
  10.     _REG( a2 ) struct DosLibrary *DOSBase )
  11. #else
  12. _ASM LibCall _ARGS AsyncFile *
  13. OpenAsync(
  14.     _REG( a0 ) const STRPTR fileName,
  15.     _REG( d0 ) OpenModes mode,
  16.     _REG( d1 ) LONG bufferSize )
  17. #endif
  18. {
  19.     static const WORD PrivateOpenModes[] =
  20.     {
  21.         MODE_OLDFILE, MODE_NEWFILE, MODE_READWRITE
  22.     };
  23.     BPTR        handle;
  24.     AsyncFile    *file = NULL;
  25.  
  26.     if( handle = Open( fileName, PrivateOpenModes[ mode ] ) )
  27.     {
  28. #ifdef ASIO_NOEXTERNALS
  29.         file = AS_OpenAsyncFH( handle, mode, bufferSize, TRUE, SysBase, DOSBase );
  30. #else
  31.         file = AS_OpenAsyncFH( handle, mode, bufferSize, TRUE );
  32. #endif
  33.  
  34.         if( !file )
  35.         {
  36.             Close( handle );
  37.         }
  38.     }
  39.  
  40.     return( file );
  41. }
  42.