mirror of
https://github.com/rclone/rclone.git
synced 2025-08-17 17:11:37 +02:00
Break the fs package up into smaller parts.
The purpose of this is to make it easier to maintain and eventually to allow the rclone backends to be re-used in other projects without having to use the rclone configuration system. The new code layout is documented in CONTRIBUTING.
This commit is contained in:
18
lib/readers/readfill.go
Normal file
18
lib/readers/readfill.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package readers
|
||||
|
||||
import "io"
|
||||
|
||||
// ReadFill reads as much data from r into buf as it can
|
||||
//
|
||||
// It reads until the buffer is full or r.Read returned an error.
|
||||
//
|
||||
// This is io.ReadFull but when you just want as much data as
|
||||
// possible, not an exact size of block.
|
||||
func ReadFill(r io.Reader, buf []byte) (n int, err error) {
|
||||
var nn int
|
||||
for n < len(buf) && err == nil {
|
||||
nn, err = r.Read(buf[n:])
|
||||
n += nn
|
||||
}
|
||||
return n, err
|
||||
}
|
Reference in New Issue
Block a user