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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: common/dirwalk/util.go
diff --git a/common/dirwalk/util.go b/common/dirwalk/util.go
new file mode 100644
index 0000000000000000000000000000000000000000..3047ced495d6d43eb7307bfc8e75f74a541aa16f
--- /dev/null
+++ b/common/dirwalk/util.go
@@ -0,0 +1,51 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package dirwalk
+
+import "io"
+
+type multiReadCloser struct {
+ io.Reader
+ closers []io.Closer
+}
+
+func (mrc multiReadCloser) Close() error {
+ for _, c := range mrc.closers {
+ if err := c.Close(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+type stringStack struct {
+ elements []string
+}
+
+func (s *stringStack) push(v string) {
+ s.elements = append(s.elements, v)
+}
+
+func (s *stringStack) pop() string {
+ var v string
+ v, s.elements = s.elements[s.last()], s.elements[:s.last()]
+ return v
+}
+
+func (s *stringStack) peek() string {
+ return s.elements[s.last()]
+}
+
+func (s *stringStack) size() int {
+ return len(s.elements)
+}
+
+func (s *stringStack) last() int {
+ return len(s.elements) - 1
+}
+
+func newStringStack() *stringStack {
+ return &stringStack{elements: make([]string, 0)}
+}

Powered by Google App Engine
This is Rietveld 408576698