Skip to content

Commit

Permalink
bug fix, add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalTux committed Apr 11, 2020
1 parent 8af39ab commit 23d0ef3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion item.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ func (f *filepathHndlr) meta() *itemMeta {
return &f.m
}

// NewItemConcat returns a single Item object actually representing multiple
// items being concatenated.
func NewItemConcat(items ...Item) Item {
return &itemConcat{items: items}
}
Expand All @@ -222,14 +224,18 @@ func (i *itemConcat) Close() error {

func (i *itemConcat) Read(p []byte) (int, error) {
for {
if len(i.items) >= i.pos {
if i.pos >= len(i.items) {
return 0, io.EOF
}

item := i.items[i.pos]
n, err := item.Read(p)
if err == io.EOF {
i.pos += 1
if n > 0 {
// this shouldn't happen
return n, nil
}
continue
}
return n, err
Expand Down

0 comments on commit 23d0ef3

Please # to comment.