(path string)
| 133 | } |
| 134 | |
| 135 | func readUint(path string) (uint64, error) { |
| 136 | f, err := os.Open(path) |
| 137 | if err != nil { |
| 138 | return 0, err |
| 139 | } |
| 140 | defer f.Close() |
| 141 | |
| 142 | // We should only need 20 bytes for the max uint64, but for a nice power of 2 |
| 143 | // lets use 32. |
| 144 | b := make([]byte, 32) |
| 145 | n, err := f.Read(b) |
| 146 | if err != nil { |
| 147 | return 0, err |
| 148 | } |
| 149 | s := string(bytes.TrimSpace(b[:n])) |
| 150 | if s == "max" { |
| 151 | // Return 0 for the max value to maintain backward compatibility. |
| 152 | return 0, nil |
| 153 | } |
| 154 | return parseUint(s, 10, 64) |
| 155 | } |
| 156 | |
| 157 | func parseUint(s string, base, bitSize int) (uint64, error) { |
| 158 | v, err := strconv.ParseUint(s, base, bitSize) |
searching dependent graphs…