From 3a5fc0e9e758a9c2261d09deca27f69027c6f3ca Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Sat, 19 Mar 2016 20:53:52 +0100 Subject: [PATCH] Adds settings methods to make paths absolute --- helpers/file_utils.go | 4 ++-- settings/settings.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/helpers/file_utils.go b/helpers/file_utils.go index 1286350..b74e3b3 100644 --- a/helpers/file_utils.go +++ b/helpers/file_utils.go @@ -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 } diff --git a/settings/settings.go b/settings/settings.go index efbd983..7406885 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -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) +}