version 1.4, 2019/12/02 23:32:09 |
version 1.5, 2019/12/08 00:06:38 |
Line 150 func (p Path) Replace(from, to string) P |
|
Line 150 func (p Path) Replace(from, to string) P |
|
return Path(strings.Replace(string(p), from, to, -1)) |
return Path(strings.Replace(string(p), from, to, -1)) |
} |
} |
|
|
func (p Path) JoinClean(s Path) Path { |
func (p Path) JoinClean(s RelPath) Path { |
return Path(path.Join(string(p), string(s))) |
return Path(path.Join(string(p), string(s))) |
} |
} |
|
|
func (p Path) JoinNoClean(s Path) Path { |
func (p Path) JoinNoClean(s RelPath) Path { |
return Path(string(p) + "/" + string(s)) |
return Path(string(p) + "/" + string(s)) |
} |
} |
|
|
Line 198 func (p Path) IsAbs() bool { |
|
Line 198 func (p Path) IsAbs() bool { |
|
} |
} |
|
|
// Rel returns the relative path from this path to the other. |
// Rel returns the relative path from this path to the other. |
func (p Path) Rel(other Path) Path { |
// |
|
// The returned path is a canonical relative path. |
|
// It starts with a possibly empty sequence of "../", |
|
// followed by a possibly empty sequence of non-dotdot directories. |
|
// It may have a single dot at the end, which means the path goes to a directory. |
|
func (p Path) Rel(other Path) RelPath { |
fp := filepath.FromSlash(p.String()) |
fp := filepath.FromSlash(p.String()) |
fpOther := filepath.FromSlash(other.String()) |
fpOther := filepath.FromSlash(other.String()) |
rel, err := filepath.Rel(fp, fpOther) |
rel, err := filepath.Rel(fp, fpOther) |
assertNil(err, "Relpath from %q to %q", p, other) |
assertNil(err, "Relpath from %q to %q", p, other) |
return NewPath(filepath.ToSlash(rel)) |
return NewRelPath(NewPath(filepath.ToSlash(rel))) |
} |
} |
|
|
// CurrPath is a path that is either absolute or relative to the current |
// CurrPath is a path that is either absolute or relative to the current |
Line 290 func (p CurrPath) CleanPath() CurrPath { |
|
Line 295 func (p CurrPath) CleanPath() CurrPath { |
|
return CurrPath(p.AsPath().CleanPath()) |
return CurrPath(p.AsPath().CleanPath()) |
} |
} |
|
|
func (p CurrPath) JoinNoClean(other Path) CurrPath { |
func (p CurrPath) JoinNoClean(other RelPath) CurrPath { |
return CurrPath(p.AsPath().JoinNoClean(other)) |
return CurrPath(p.AsPath().JoinNoClean(other)) |
} |
} |
|
|
func (p CurrPath) JoinClean(other Path) CurrPath { |
func (p CurrPath) JoinClean(other RelPath) CurrPath { |
return NewCurrPath(p.AsPath().JoinClean(other)) |
return NewCurrPath(p.AsPath().JoinClean(other)) |
} |
} |
|
|
func (p CurrPath) Rel(rel CurrPath) Path { |
func (p CurrPath) Rel(rel CurrPath) RelPath { |
return p.AsPath().Rel(rel.AsPath()) |
return p.AsPath().Rel(rel.AsPath()) |
} |
} |
|
|
Line 341 func (p CurrPath) ReadPaths() []CurrPath |
|
Line 346 func (p CurrPath) ReadPaths() []CurrPath |
|
var filenames []CurrPath |
var filenames []CurrPath |
for _, info := range infos { |
for _, info := range infos { |
if !isIgnoredFilename(info.Name()) { |
if !isIgnoredFilename(info.Name()) { |
joined := p.JoinNoClean(NewPath(info.Name())).CleanPath() |
joined := p.JoinNoClean(NewRelPathString(info.Name())).CleanPath() |
filenames = append(filenames, joined) |
filenames = append(filenames, joined) |
} |
} |
} |
} |
Line 362 func (p CurrPath) WriteString(s string) |
|
Line 367 func (p CurrPath) WriteString(s string) |
|
// PkgsrcPath is a path relative to the pkgsrc root. |
// PkgsrcPath is a path relative to the pkgsrc root. |
type PkgsrcPath string |
type PkgsrcPath string |
|
|
func NewPkgsrcPath(p Path) PkgsrcPath { return PkgsrcPath(p) } |
func NewPkgsrcPath(p Path) PkgsrcPath { |
|
_ = NewRelPath(p) |
|
return PkgsrcPath(p) |
|
} |
|
|
func (p PkgsrcPath) String() string { return string(p) } |
func (p PkgsrcPath) String() string { return string(p) } |
|
|
func (p PkgsrcPath) AsPath() Path { return NewPath(string(p)) } |
func (p PkgsrcPath) AsPath() Path { return NewPath(string(p)) } |
|
|
|
func (p PkgsrcPath) AsRelPath() RelPath { return RelPath(p) } |
|
|
func (p PkgsrcPath) DirClean() PkgsrcPath { |
func (p PkgsrcPath) DirClean() PkgsrcPath { |
return NewPkgsrcPath(p.AsPath().DirClean()) |
return NewPkgsrcPath(p.AsPath().DirClean()) |
} |
} |
Line 384 func (p PkgsrcPath) HasPrefixPath(prefix |
|
Line 394 func (p PkgsrcPath) HasPrefixPath(prefix |
|
return p.AsPath().HasPrefixPath(prefix) |
return p.AsPath().HasPrefixPath(prefix) |
} |
} |
|
|
func (p PkgsrcPath) JoinNoClean(other Path) PkgsrcPath { |
func (p PkgsrcPath) JoinNoClean(other RelPath) PkgsrcPath { |
return NewPkgsrcPath(p.AsPath().JoinNoClean(other)) |
return NewPkgsrcPath(p.AsPath().JoinNoClean(other)) |
} |
} |
|
|
func (p PkgsrcPath) JoinRel(other RelPath) PkgsrcPath { |
|
return p.JoinNoClean(other.AsPath()) |
|
} |
|
|
|
// PackagePath is a path relative to the package directory. It is used |
// PackagePath is a path relative to the package directory. It is used |
// for the PATCHDIR and PKGDIR variables, as well as dependencies and |
// for the PATCHDIR and PKGDIR variables, as well as dependencies and |
// conflicts on other packages. |
// conflicts on other packages. |
type PackagePath string |
type PackagePath string |
|
|
func NewPackagePath(p Path) PackagePath { return PackagePath(p) } |
func NewPackagePath(p RelPath) PackagePath { |
|
return PackagePath(p) |
|
} |
|
|
|
func NewPackagePathString(p string) PackagePath { |
|
_ = NewRelPathString(p) |
|
return PackagePath(p) |
|
} |
|
|
func (p PackagePath) AsPath() Path { return Path(p) } |
func (p PackagePath) AsPath() Path { return Path(p) } |
|
|
|
func (p PackagePath) AsRelPath() RelPath { return RelPath(p) } |
|
|
func (p PackagePath) String() string { return p.AsPath().String() } |
func (p PackagePath) String() string { return p.AsPath().String() } |
|
|
// TODO: try RelPath instead of Path |
func (p PackagePath) JoinNoClean(other RelPath) PackagePath { |
func (p PackagePath) JoinNoClean(other Path) PackagePath { |
return NewPackagePathString(p.AsPath().JoinNoClean(other).String()) |
return NewPackagePath(p.AsPath().JoinNoClean(other)) |
|
} |
} |
|
|
func (p PackagePath) IsEmpty() bool { return p.AsPath().IsEmpty() } |
func (p PackagePath) IsEmpty() bool { return p.AsPath().IsEmpty() } |
Line 414 func (p PackagePath) IsEmpty() bool { re |
|
Line 428 func (p PackagePath) IsEmpty() bool { re |
|
// further specified. |
// further specified. |
type RelPath string |
type RelPath string |
|
|
func NewRelPath(p Path) RelPath { return RelPath(p) } |
func NewRelPath(p Path) RelPath { |
|
assert(!p.IsAbs()) |
|
return RelPath(p) |
|
} |
|
|
func NewRelPathString(p string) RelPath { return RelPath(p) } |
func NewRelPathString(p string) RelPath { |
|
assert(!NewPath(p).IsAbs()) |
|
return RelPath(p) |
|
} |
|
|
func (p RelPath) AsPath() Path { return NewPath(string(p)) } |
func (p RelPath) AsPath() Path { return NewPath(string(p)) } |
|
|
func (p RelPath) String() string { return p.AsPath().String() } |
func (p RelPath) String() string { return p.AsPath().String() } |
|
|
|
func (p RelPath) IsEmpty() bool { return p.AsPath().IsEmpty() } |
|
|
|
func (p RelPath) Split() (RelPath, string) { |
|
dir, base := p.AsPath().Split() |
|
return NewRelPath(dir), base |
|
} |
|
|
func (p RelPath) DirClean() RelPath { return RelPath(p.AsPath().DirClean()) } |
func (p RelPath) DirClean() RelPath { return RelPath(p.AsPath().DirClean()) } |
|
|
func (p RelPath) DirNoClean() RelPath { |
func (p RelPath) DirNoClean() RelPath { |
Line 438 func (p RelPath) Count() int { return p. |
|
Line 465 func (p RelPath) Count() int { return p. |
|
|
|
func (p RelPath) Clean() RelPath { return NewRelPath(p.AsPath().Clean()) } |
func (p RelPath) Clean() RelPath { return NewRelPath(p.AsPath().Clean()) } |
|
|
|
func (p RelPath) CleanDot() RelPath { |
|
return NewRelPath(p.AsPath().CleanDot()) |
|
} |
|
|
func (p RelPath) CleanPath() RelPath { |
func (p RelPath) CleanPath() RelPath { |
return RelPath(p.AsPath().CleanPath()) |
return RelPath(p.AsPath().CleanPath()) |
} |
} |
|
|
func (p RelPath) JoinNoClean(other Path) RelPath { |
func (p RelPath) JoinNoClean(other RelPath) RelPath { |
return RelPath(p.AsPath().JoinNoClean(other)) |
return RelPath(p.AsPath().JoinNoClean(other)) |
} |
} |
|
|
Line 454 func (p RelPath) HasPrefixPath(prefix Pa |
|
Line 485 func (p RelPath) HasPrefixPath(prefix Pa |
|
return p.AsPath().HasPrefixPath(prefix) |
return p.AsPath().HasPrefixPath(prefix) |
} |
} |
|
|
|
func (p RelPath) HasPrefixText(prefix string) bool { |
|
return p.AsPath().HasPrefixText(prefix) |
|
} |
|
|
func (p RelPath) ContainsPath(sub Path) bool { |
func (p RelPath) ContainsPath(sub Path) bool { |
return p.AsPath().ContainsPath(sub) |
return p.AsPath().ContainsPath(sub) |
} |
} |
Line 465 func (p RelPath) ContainsText(text strin |
|
Line 500 func (p RelPath) ContainsText(text strin |
|
func (p RelPath) HasSuffixPath(suffix Path) bool { |
func (p RelPath) HasSuffixPath(suffix Path) bool { |
return p.AsPath().HasSuffixPath(suffix) |
return p.AsPath().HasSuffixPath(suffix) |
} |
} |
|
|
|
func (p RelPath) HasSuffixText(suffix string) bool { |
|
return p.AsPath().HasSuffixText(suffix) |
|
} |
|
|
|
func (p RelPath) Rel(other Path) RelPath { return p.AsPath().Rel(other) } |