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
This commit is contained in:
Noah Campbell
2013-09-12 10:48:59 -07:00
parent 998b2f73f8
commit 74b55fc7c8
8 changed files with 46 additions and 43 deletions

View File

@@ -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) {