Archived
1
0

Adds settings methods to make paths absolute

This commit is contained in:
Jip J. Dekker 2016-03-19 20:53:52 +01:00
parent 4cc5b785a3
commit 3a5fc0e9e7
2 changed files with 14 additions and 2 deletions

View File

@ -72,8 +72,8 @@ func FindFileDir(file string) (string, error) {
}
// AbsolutePath returns an the path if it is absolute or
// otherwise filepath.Join(lib, path)
func AbsolutePath(path, lib string) string {
// otherwise filepath.Join(root, path)
func AbsolutePath(path, root string) string {
if filepath.IsAbs(path) {
return path
}

View File

@ -42,3 +42,15 @@ func FromFile(path string) (*Settings, error) {
}
return &s, nil
}
// AbsolutePaths makes all paths in settings absolute using the given
// absolute root
func (s *settings.Settings) AbsolutePaths(root string) {
for i := range s.IgnoreDirs {
s.IgnoreDirs[i] := helpers.AbsolutePath(s.IgnoreDirs[i], root)
}
for i := range s.LilypondIncludes {
s.LilypondIncludes[i] := helpers.AbsolutePath(s.LilypondIncludes[i], root)
}
s.OutputDir := helpers.AbsolutePath(s.OutputDir, root)
}