summaryrefslogtreecommitdiffstats
path: root/hugolib/config.go
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-09-12 10:48:59 -0700
committerNoah Campbell <noahcampbell@gmail.com>2013-09-12 10:48:59 -0700
commit74b55fc7c87f2887c42ce8626cb461fee5d7b907 (patch)
treefd071f824ac14cff6ddaf9c9582a65843a6ab316 /hugolib/config.go
parent998b2f73f8da8886be87c29e23623d24445cbe93 (diff)
Normalize paths within hugo
filepath was used inconsistently throughout the hugolib. With the introduction of source and target modules, all path are normalized to "/". This simplifies the processing of paths. It does mean that contributors need to be aware of using path/filepath in any module other than source or target is not recommended. The current exception is hugolib/config.go
Diffstat (limited to 'hugolib/config.go')
-rw-r--r--hugolib/config.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/hugolib/config.go b/hugolib/config.go
index 12dc544c7..030a5c945 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -103,7 +103,7 @@ func (c *Config) readInConfig() {
func (c *Config) setPath(p string) {
if p == "" {
- path, err := FindPath()
+ path, err := findPath()
if err != nil {
fmt.Printf("Error finding path: %s", err)
}
@@ -124,7 +124,7 @@ func (c *Config) GetPath() string {
return c.Path
}
-func FindPath() (string, error) {
+func findPath() (string, error) {
serverFile, err := filepath.Abs(os.Args[0])
if err != nil {
@@ -147,13 +147,14 @@ func FindPath() (string, error) {
return path, nil
}
+// GetAbsPath return the absolute path for a given path with the internal slashes
+// properly converted.
func (c *Config) GetAbsPath(name string) string {
if filepath.IsAbs(name) {
return name
}
- p := filepath.Join(c.GetPath(), name)
- return p
+ return filepath.ToSlash(filepath.Join(c.GetPath(), name))
}
func (c *Config) findConfigFile(configFileName string) (string, error) {