Created
July 15, 2010 11:20
-
-
Save mrosset/476831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"container/vector" | |
"os" | |
"path" | |
"io/ioutil" | |
) | |
type V struct { | |
list vector.StringVector | |
} | |
func (*V) VisitDir(path string, f *os.FileInfo) bool { | |
// walk in each directory | |
return true | |
} | |
func (v *V) VisitFile(p string, f *os.FileInfo) { | |
if f.Name == "PKGBUILD" { | |
v.list.Push(p[0:len(p)-8]) // remove PKGBUILD from path and store it in vector | |
return // prune | |
} | |
//If path is a symlink test read its contents for more paths to walk | |
if f.IsSymlink() && !f.FollowedSymlink { //FIME: test if FollowedSymlink is sane | |
dirs, _ := ioutil.ReadDir(p) | |
if len(dirs) > 0 { | |
for _, e := range dirs { | |
path.Walk(path.Join(p, e.Name), v, nil) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment