func (sfr *sparseFileReader) Read(b []byte) (n int, err error) {
	if len(sfr.sp) == 0 {
		// No more data fragments to read from.
		if sfr.pos < sfr.tot {
			// We're in the last hole
			n = sfr.readHole(b, sfr.tot)
			return
		}
		// Otherwise, we're at the end of the file
		return 0, io.EOF
	}
	if sfr.pos < sfr.sp[0].offset {
		// We're in a hole
		n = sfr.readHole(b, sfr.sp[0].offset)
		return
	}

	// We're not in a hole, so we'll read from the next data fragment
	posInFragment := sfr.pos - sfr.sp[0].offset
	bytesLeft := sfr.sp[0].numBytes - posInFragment
	if int64(len(b)) > bytesLeft {
		b = b[0:bytesLeft]
	}

	n, err = sfr.rfr.Read(b)
	sfr.pos += int64(n)

	if int64(n) == bytesLeft {
		// We're done with this fragment
		sfr.sp = sfr.sp[1:]
	}

	if err == io.EOF && sfr.pos < sfr.tot {
		// We reached the end of the last fragment's data, but there's a final hole
		err = nil
	}
	return
}
// Read reads the sparse file data in expanded form.
Read reads the sparse file data in expanded form.
// Read reads the sparse file data in expanded form .
func (sfr *sparseFileReader) Read(b []byte) (n int, err error) {
	if len(sfr.sp) == 0 {
		if sfr.pos < sfr.tot {
			n = sfr.readHole(b, sfr.tot)
			return
		}
		return 0, io.EOF
	}
	if sfr.pos < sfr.sp[0].offset {
		n = sfr.readHole(b, sfr.sp[0].offset)
		return
	}
	posInFragment := sfr.pos - sfr.sp[0].offset
	bytesLeft := sfr.sp[0].numBytes - posInFragment
	if int64(len(b)) > bytesLeft {
		b = b[0:bytesLeft]
	}
	n, err = sfr.rfr.Read(b)
	sfr.pos += int64(n)
	if int64(n) == bytesLeft {
		sfr.sp = sfr.sp[1:]
	}
	if err == io.EOF && sfr.pos < sfr.tot {
		err = nil
	}
	return
}
func ( sfr * sparseFileReader ) Read ( b [ ] byte ) ( n int , err error ) { if len ( sfr . sp ) == 0 { if sfr . pos < sfr . tot { n = sfr . readHole ( b , sfr . tot ) return } return 0 , io . EOF } if sfr . pos < sfr . sp [ 0 ] . offset { n = sfr . readHole ( b , sfr . sp [ 0 ] . offset ) return } posInFragment := sfr . pos - sfr . sp [ 0 ] . offset bytesLeft := sfr . sp [ 0 ] . numBytes - posInFragment if int64 ( len ( b ) ) > bytesLeft { b = b [ 0 : bytesLeft ] } n , err = sfr . rfr . Read ( b ) sfr . pos += int64 ( n ) if int64 ( n ) == bytesLeft { sfr . sp = sfr . sp [ 1 : ] } if err == io . EOF && sfr . pos < sfr . tot { err = nil } return }
Read reads the sparse file data in expanded form.
Read reads the sparse file data in expanded form .
// No more data fragments to read from. // We're in the last hole // Otherwise, we're at the end of the file // We're in a hole // We're not in a hole, so we'll read from the next data fragment // We're done with this fragment // We reached the end of the last fragment's data, but there's a final hole