CopyReaderAt copies to a writer from a given reader at for the given number of bytes. This copy does not commit the writer.
(cw Writer, ra ReaderAt, n int64)
| 235 | // CopyReaderAt copies to a writer from a given reader at for the given |
| 236 | // number of bytes. This copy does not commit the writer. |
| 237 | func CopyReaderAt(cw Writer, ra ReaderAt, n int64) error { |
| 238 | ws, err := cw.Status() |
| 239 | if err != nil { |
| 240 | return err |
| 241 | } |
| 242 | |
| 243 | copied, err := copyWithBuffer(cw, io.NewSectionReader(ra, ws.Offset, n)) |
| 244 | if err != nil { |
| 245 | return fmt.Errorf("failed to copy: %w", err) |
| 246 | } |
| 247 | if copied < n { |
| 248 | // Short writes would return its own error, this indicates a read failure |
| 249 | return fmt.Errorf("failed to read expected number of bytes: %w", io.ErrUnexpectedEOF) |
| 250 | } |
| 251 | return nil |
| 252 | } |
| 253 | |
| 254 | // CopyReader copies to a writer from a given reader, returning |
| 255 | // the number of bytes copied. |
no test coverage detected
searching dependent graphs…