diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/ulikunitz/xz/lzma/bytewriter.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/ulikunitz/xz/lzma/bytewriter.go')
-rw-r--r-- | vendor/github.com/ulikunitz/xz/lzma/bytewriter.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/github.com/ulikunitz/xz/lzma/bytewriter.go b/vendor/github.com/ulikunitz/xz/lzma/bytewriter.go new file mode 100644 index 0000000..a3696ba --- /dev/null +++ b/vendor/github.com/ulikunitz/xz/lzma/bytewriter.go | |||
@@ -0,0 +1,37 @@ | |||
1 | // Copyright 2014-2017 Ulrich Kunitz. All rights reserved. | ||
2 | // Use of this source code is governed by a BSD-style | ||
3 | // license that can be found in the LICENSE file. | ||
4 | |||
5 | package lzma | ||
6 | |||
7 | import ( | ||
8 | "errors" | ||
9 | "io" | ||
10 | ) | ||
11 | |||
12 | // ErrLimit indicates that the limit of the LimitedByteWriter has been | ||
13 | // reached. | ||
14 | var ErrLimit = errors.New("limit reached") | ||
15 | |||
16 | // LimitedByteWriter provides a byte writer that can be written until a | ||
17 | // limit is reached. The field N provides the number of remaining | ||
18 | // bytes. | ||
19 | type LimitedByteWriter struct { | ||
20 | BW io.ByteWriter | ||
21 | N int64 | ||
22 | } | ||
23 | |||
24 | // WriteByte writes a single byte to the limited byte writer. It returns | ||
25 | // ErrLimit if the limit has been reached. If the byte is successfully | ||
26 | // written the field N of the LimitedByteWriter will be decremented by | ||
27 | // one. | ||
28 | func (l *LimitedByteWriter) WriteByte(c byte) error { | ||
29 | if l.N <= 0 { | ||
30 | return ErrLimit | ||
31 | } | ||
32 | if err := l.BW.WriteByte(c); err != nil { | ||
33 | return err | ||
34 | } | ||
35 | l.N-- | ||
36 | return nil | ||
37 | } | ||