plugins/xz/xz.c
/* Read data from the file. */
Read data from the file.
Read data from the file .
static int
xz_pread (void *handle, void *buf, uint32_t count, uint64_t offset)
{
  struct xz_handle *h = handle;
  char *data;
  uint64_t start, size;
  uint32_t n;
  data = get_block (h->c, offset, &start, &size);
  if (!data) {
    data = xzfile_read_block (h->xz, offset, &start, &size);
    if (data == NULL)
      return -1;
    put_block (h->c, start, size, data);
  }
  n = count;
  if (start + size - offset < n)
    n = start + size - offset;
  memcpy (buf, &data[offset-start], n);
  buf += n;
  count -= n;
  offset += n;
  if (count > 0)
    return xz_pread (h, buf, count, offset);
  return 0;
}
static int xz_pread ( void * handle , void * buf , uint32_t count , uint64_t offset ) { struct xz_handle * h = handle ; char * data ; uint64_t start , size ; uint32_t n ; data = get_block ( h -> c , offset , & start , & size ) ; if ( ! data ) { data = xzfile_read_block ( h -> xz , offset , & start , & size ) ; if ( data == NULL ) return -1 ; put_block ( h -> c , start , size , data ) ; } n = count ; if ( start + size - offset < n ) n = start + size - offset ; memcpy ( buf , & data [ offset - start ] , n ) ; buf += n ; count -= n ; offset += n ; if ( count > 0 ) return xz_pread ( h , buf , count , offset ) ; return 0 ; }
Read data from the file.
Read data from the file .
/* Find the block in the cache. */ /* Not in the cache.  We need to read the block from the xz file. */ /* It's possible if the blocks are really small or oddly aligned or
   * if the requests are large that we need to read the following
   * block to satisfy the request.
   */