Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: common/dirwalk/util.go

Issue 2054763004: luci-go/common/dirwalk: Code for walking a directory tree efficiently Base URL: https://github.com/luci/luci-go@master
Patch Set: Major rewrite of the code. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698