Refactor elements of sparse file parsing that depend on
an fd into SparseFileSource class, then create implementations
using both fd and buffer. Add sparse_file_read_buf which
reads the given buffer into a sparse file cookie without
copying.
Test: flash system with sparse images
Bug: 78793464
Change-Id: Ice6c8e1ff075d6867e070f80fcf5aa4f530a1b95
Switch vnsprintf to StringPrintf to avoid off-by-one, and switch
sparse_read.c to cpp.
Test: fastboot flash normal image with smaller sparse limit
Change-Id: Ia399b167625deb271bfd0ee3273071306d71c4d4