File: util.go

package info (click to toggle)
golang-github-dhowett-go-plist 0.0~git20181124.0.591f970-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 376 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package plist

import "io"

type countedWriter struct {
	io.Writer
	nbytes int
}

func (w *countedWriter) Write(p []byte) (int, error) {
	n, err := w.Writer.Write(p)
	w.nbytes += n
	return n, err
}

func (w *countedWriter) BytesWritten() int {
	return w.nbytes
}

func unsignedGetBase(s string) (string, int) {
	if len(s) > 1 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') {
		return s[2:], 16
	}
	return s, 10
}