summaryrefslogtreecommitdiffstats
path: root/lib/folder/folder-pathmap.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-28 21:44:26 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-29 08:56:46 +0200
commitd94141ed7419867231a1050eb81c72bfd25003c6 (patch)
tree5ea9d86d2769527354d42853949f28d5b0c030e0 /lib/folder/folder-pathmap.go
parent29b13449d2e8a5dad2aefda6e9a2b5661fecfc2a (diff)
Fixed path convertion/mapping for in/out and for command args.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/folder/folder-pathmap.go')
-rw-r--r--lib/folder/folder-pathmap.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/folder/folder-pathmap.go b/lib/folder/folder-pathmap.go
index f73f271..1020026 100644
--- a/lib/folder/folder-pathmap.go
+++ b/lib/folder/folder-pathmap.go
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
common "github.com/iotbzh/xds-common/golib"
"github.com/iotbzh/xds-server/lib/xdsconfig"
@@ -80,7 +81,7 @@ func (f *PathMap) GetConfig() FolderConfig {
return f.config
}
-// GetFullPath returns the full path
+// GetFullPath returns the full path of a directory (from server POV)
func (f *PathMap) GetFullPath(dir string) string {
if &dir == nil {
return f.config.DataPathMap.ServerPath
@@ -88,6 +89,28 @@ func (f *PathMap) GetFullPath(dir string) string {
return filepath.Join(f.config.DataPathMap.ServerPath, dir)
}
+// ConvPathCli2Svr Convert path from Client to Server
+func (f *PathMap) ConvPathCli2Svr(s string) string {
+ if f.config.ClientPath != "" && f.config.DataPathMap.ServerPath != "" {
+ return strings.Replace(s,
+ f.config.ClientPath,
+ f.config.DataPathMap.ServerPath,
+ -1)
+ }
+ return s
+}
+
+// ConvPathSvr2Cli Convert path from Server to Client
+func (f *PathMap) ConvPathSvr2Cli(s string) string {
+ if f.config.ClientPath != "" && f.config.DataPathMap.ServerPath != "" {
+ return strings.Replace(s,
+ f.config.DataPathMap.ServerPath,
+ f.config.ClientPath,
+ -1)
+ }
+ return s
+}
+
// Remove a folder
func (f *PathMap) Remove() error {
// nothing to do