home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / asyncio / src / openasync.c < prev    next >
C/C++ Source or Header  |  1997-02-18  |  822b  |  43 lines

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