OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package dirwalk |
| 6 |
| 7 import "io" |
| 8 |
| 9 type multiReadCloser struct { |
| 10 io.Reader |
| 11 closers []io.Closer |
| 12 } |
| 13 |
| 14 func (mrc multiReadCloser) Close() error { |
| 15 for _, c := range mrc.closers { |
| 16 if err := c.Close(); err != nil { |
| 17 return err |
| 18 } |
| 19 } |
| 20 return nil |
| 21 } |
| 22 |
| 23 type stringStack struct { |
| 24 elements []string |
| 25 } |
| 26 |
| 27 func (s *stringStack) push(v string) { |
| 28 s.elements = append(s.elements, v) |
| 29 } |
| 30 |
| 31 func (s *stringStack) pop() string { |
| 32 var v string |
| 33 v, s.elements = s.elements[s.last()], s.elements[:s.last()] |
| 34 return v |
| 35 } |
| 36 |
| 37 func (s *stringStack) peek() string { |
| 38 return s.elements[s.last()] |
| 39 } |
| 40 |
| 41 func (s *stringStack) size() int { |
| 42 return len(s.elements) |
| 43 } |
| 44 |
| 45 func (s *stringStack) last() int { |
| 46 return len(s.elements) - 1 |
| 47 } |
| 48 |
| 49 func newStringStack() *stringStack { |
| 50 return &stringStack{elements: make([]string, 0)} |
| 51 } |
OLD | NEW |