summaryrefslogtreecommitdiffstats
path: root/lib/common/filepath.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-18 23:18:04 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-18 23:19:43 +0200
commit387641b4352d9f9da0d036db68a79e1fadbd4b5d (patch)
tree9965511bf2e3820b2114504aab25ef9cffb2e4f7 /lib/common/filepath.go
parenta52a4ddc7662b8a4d0b8a1fd7be88742d1379691 (diff)
Normalize relativePath projects to support Windows path.
Diffstat (limited to 'lib/common/filepath.go')
-rw-r--r--lib/common/filepath.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/common/filepath.go b/lib/common/filepath.go
index 4c8c0da..8101c5a 100644
--- a/lib/common/filepath.go
+++ b/lib/common/filepath.go
@@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"regexp"
+ "strings"
)
// Exists returns whether the given file or directory exists or not
@@ -55,3 +56,18 @@ func ResolveEnvVar(s string) (string, error) {
return path.Clean(res), nil
}
+
+// PathNormalize
+func PathNormalize(p string) string {
+ sep := string(filepath.Separator)
+ if sep != "/" {
+ return p
+ }
+ // Replace drive like C: by C/
+ res := p
+ if p[1:2] == ":" {
+ res = p[0:1] + sep + p[2:]
+ }
+ res = strings.Replace(res, "\\", "/", -1)
+ return filepath.Clean(res)
+}