mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 02:44:02 +03:00
Preliminary debug state
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
package wrappers
|
||||
|
||||
import "bytes"
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
type BufferedReader struct {
|
||||
Buffer *bytes.Buffer
|
||||
}
|
||||
|
||||
var (
|
||||
BufferedReaderContinue = errors.New("Please continue reading")
|
||||
)
|
||||
|
||||
func (b *BufferedReader) BufferedRead(p []byte, callback func() error) (int, error) {
|
||||
if b.Buffer.Len() > 0 {
|
||||
return b.flush(p)
|
||||
@@ -17,7 +25,7 @@ func (b *BufferedReader) BufferedRead(p []byte, callback func() error) (int, err
|
||||
}
|
||||
|
||||
func (b *BufferedReader) flush(p []byte) (int, error) {
|
||||
if b.Buffer.Len() < len(p) {
|
||||
if b.Buffer.Len() <= len(p) {
|
||||
sizeToReturn := b.Buffer.Len()
|
||||
copy(p, b.Buffer.Bytes())
|
||||
b.Buffer.Reset()
|
||||
|
||||
Reference in New Issue
Block a user