Contents page

Rules for Tools/fastopen()


fastopen(), fastclose(), fastread(), fastwrite()
SYNOPSIS
    long fastopen(char *filename, long mode); 
    void fastclose(long file); 
    long fastread(long file, char *buffer, long length); 
    long fastwrite(long file, char *buffer, long length);

ARGUMENTS
    `long file'
          Buffered file i/o identifier.

    `char *filename'
          Filename string.

    `long mode'
          MODE_NEWFILE or MODE_OLDFILE.

    `long count'
          Number of bytes read.

    `char *buffer'
          Memory to read or write to.

    `long length'
          Length, in bytes, of read or write.

    `long error'
          -1 if unable to write.

DESCRIPTION
     Bars&Pipes uses its own buffered i/o system for faster reads and
     writes.   `fastopen()', `fastclose()', `fastread()', and
     `fastwrite()' replace the AmigaDos `Open()', `Close()', `Read()',
     and `Write()' routines directly.

     You are not required to use these routines for reading and writing
     your own files.  However, Tools and Accessories that provide
     routines to Bars&Pipes for loading and saving data as part of a
     song file must use `fastread()' and `fastwrite()'.

     Both `fastread()' and `fastwrite()' can not handle buffer sizes
     larger than 3900 bytes (yes, this is a bug!)  This is in the
     process of being fixed, but in order to maintain full
     compatibility with all Bars&Pipes, make sure your reads and writes
     do not extend beyond this maximum.  Here's a short routine that
     solves the problem for reading:
	 
readlargebuff(file,buffer,size) long file; char *buffer; long file; {
    long index = 0;
    for (;size >= 3900;size -= 3900) {
        (*functions->fastread)(file,&buffer[index],3900);
        index += 3900;
    }
    if (size) (*functions->fastread)(file,&buffer[index],size); 
}