home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 61.dms / 61.adf / source.files / giocall.(sample) < prev    next >
Text File  |  1986-03-21  |  2KB  |  43 lines

  1. /*--------------------------------------------------------------*/
  2. /*  GIOCall.c:  An example of calling the Generic I/O Speed-up. */
  3. /*             1/23/86                     */
  4. /*                                                              */
  5. /* By Jerry Morrison and Steve Shaw, Electronic Arts.           */
  6. /* This software is in the public domain.                       */
  7. /*                                                              */
  8. /* This version for the Commodore-Amiga computer.               */
  9. /*                                                              */
  10. /*--------------------------------------------------------------*/
  11.     main(...) {
  12.     LONG file;
  13.     int success;
  14.     ...
  15.     success = (0 != (file = GOpen(...)));
  16.     /* A TmpRas is a good buffer to use for a variety of short-term uses.*/
  17.     if (success)
  18.     success = PutObject(file, ob, tmpRas.RasPtr, tmpRas.Size);
  19.     success &= (0 <= GClose(file));
  20.     }
  21.  
  22. /*----- PutObject writes a DVCS object out as a disk file.-----*/
  23. BOOL PutObject(file, ob, buffer, bufsize)
  24.     LONG file;  struct Object *ob;  BYTE *buffer;  LONG bufsize; {
  25.     int success = TRUE;
  26.  
  27.     if (bufsize > 2*BODY_BUFSIZE) {
  28.     /* Give buffer to speed-up writing.*/
  29.     GWriteDeclare(file, buffer+BODY_BUFSIZE, bufsize-BODY_BUFSIZE);
  30.     bufsize = BODY_BUFSIZE;  /* Used by PutObject for other purposes.*/
  31.     }
  32.     ...
  33.     /* Use GWrite and GSeek instead of Write and Seek.*/
  34.     success &= (0 <= GWrite(file, address, length));
  35.     ...
  36.     success &= (0 <= GWriteUndeclare(file));
  37.         /* Release the speed-up buffer.*/
  38.         /* This is not necessary if GClose is used to close the file,
  39.          * but it can't hurt.*/
  40.     return( (BOOL)success );
  41.     }
  42.  
  43.