Neither of the SparseWriter users actually _wants_ the underlying
WriteSeeker to be closed; so, don't.
That makes it clear where the responsibility for closing the file
lies, and allows us to remove the reliance on the destinations
reliably returning ErrClosed.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... instead of using a multi-variable state machine.
The net effect of this code is exactly the same as the previous implementation,
except:
- the operation after Write() returns an error might differ
- If the file ends with zeroes, we don't Seek(-1), and
we don't create a hole at all if it is too small, preferring
to save a syscall.
But this formulation is hopefully easier to prove correct.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>