Commit 3d25175f authored by Cristian Maglie's avatar Cristian Maglie

Updated go-paths-helper

parent 6145d748
......@@ -30,11 +30,11 @@
[[projects]]
branch = "master"
digest = "1:fd2ebfc02b6ad10599b226d2c0265f160e95e7c80e23f01dcf34a8aff0de98c9"
digest = "1:045d5ae3596598b9b9591042561fbcbf2d484d2a744fd007151cab3862a6b8f6"
name = "github.com/arduino/go-paths-helper"
packages = ["."]
pruneopts = "UT"
revision = "751652ddd9f0a98650e681673c2c73937002e889"
revision = "c3c98d1bf2e1069f60ab84bff3a2eb3c5422f3b0"
[[projects]]
branch = "master"
......
......@@ -444,6 +444,25 @@ func (p *Path) EquivalentTo(other *Path) bool {
return p.Clean().path == other.Clean().path
}
// Parents returns all the parents directories of the current path. If the path is absolute
// it starts from the current path to the root, if the path is relative is starts from the
// current path to the current directory.
// The path should be clean for this method to work properly (no .. or . or other shortcuts).
// This function does not performs any check on the returned paths.
func (p *Path) Parents() []*Path {
res := []*Path{}
dir := p
for {
res = append(res, dir)
parent := dir.Parent()
if parent.EquivalentTo(dir) {
break
}
dir = parent
}
return res
}
func (p *Path) String() string {
return p.path
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment