misc/libphysfs/physfs.c
changeset 12453 89423b1db329
parent 12213 bb5522e88ab2
equal deleted inserted replaced
12452:e18cfe90e4e2 12453:89423b1db329
  2586     io = fh->io;
  2586     io = fh->io;
  2587     if (len >= fh->bufsize)  /* need more than the buffer takes. */
  2587     if (len >= fh->bufsize)  /* need more than the buffer takes. */
  2588     {
  2588     {
  2589         /* leave buffer empty, go right to output instead. */
  2589         /* leave buffer empty, go right to output instead. */
  2590         rc = io->read(io, buffer, len);
  2590         rc = io->read(io, buffer, len);
  2591         if (rc < 0)
  2591         if (rc <= 0)
  2592             return ((retval == 0) ? rc : retval);
  2592             return ((retval == 0) ? rc : retval);
  2593         return retval + rc;
  2593         return retval + rc;
  2594     } /* if */
  2594     } /* if */
  2595 
  2595 
  2596     /* need less than buffer can take. Fill buffer. */
  2596     /* need less than buffer can take. Fill buffer. */
  2597     rc = io->read(io, fh->buffer, fh->bufsize);
  2597     rc = io->read(io, fh->buffer, fh->bufsize);
  2598     if (rc < 0)
  2598     if (rc <= 0)
  2599         return ((retval == 0) ? rc : retval);
  2599         return ((retval == 0) ? rc : retval);
  2600 
  2600 
  2601     assert(fh->bufpos == 0);
  2601     assert(fh->bufpos == 0);
  2602     fh->buffill = (PHYSFS_uint32) rc;
  2602     fh->buffill = (PHYSFS_uint32) rc;
  2603     rc = doBufferedRead(fh, buffer, len);  /* go from the start, again. */
  2603     rc = doBufferedRead(fh, buffer, len);  /* go from the start, again. */
  2604     if (rc < 0)
  2604     if (rc <= 0)
  2605         return ((retval == 0) ? rc : retval);
  2605         return ((retval == 0) ? rc : retval);
  2606 
  2606 
  2607     return retval + rc;
  2607     return retval + rc;
  2608 } /* doBufferedRead */
  2608 } /* doBufferedRead */
  2609 
  2609