1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-06 17:25:27 -05:00

rename buf.Copy

This commit is contained in:
Darien Raymond
2017-04-17 22:50:02 +02:00
parent e362c74fa9
commit ab9349ec31
11 changed files with 29 additions and 30 deletions

View File

@@ -40,9 +40,7 @@ func ReadFullFrom(reader io.Reader, size int) Supplier {
}
}
// Pipe dumps all payload from reader to writer, until an error occurs.
// ActivityTimer gets updated as soon as there is a payload.
func Pipe(timer signal.ActivityTimer, reader Reader, writer Writer) error {
func copyInternal(timer signal.ActivityTimer, reader Reader, writer Writer) error {
for {
buffer, err := reader.Read()
if err != nil {
@@ -64,9 +62,10 @@ func Pipe(timer signal.ActivityTimer, reader Reader, writer Writer) error {
}
}
// PipeUntilEOF behaves the same as Pipe(). The only difference is PipeUntilEOF returns nil on EOF.
func PipeUntilEOF(timer signal.ActivityTimer, reader Reader, writer Writer) error {
err := Pipe(timer, reader, writer)
// Copy dumps all payload from reader to writer or stops when an error occurs.
// ActivityTimer gets updated as soon as there is a payload.
func Copy(timer signal.ActivityTimer, reader Reader, writer Writer) error {
err := copyInternal(timer, reader, writer)
if err != nil && errors.Cause(err) != io.EOF {
return err
}