From 28551686ccd7b02cccd7ccc470b289e9cd8d8eae Mon Sep 17 00:00:00 2001 From: Elena Ceseracciu Date: Mon, 4 Nov 2013 17:41:26 +0100 Subject: [PATCH] [ResourceFinder] Use native path separators when providing paths --- src/libYARP_OS/src/ResourceFinder.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libYARP_OS/src/ResourceFinder.cpp b/src/libYARP_OS/src/ResourceFinder.cpp index 92e0c040a2a..857fa50e249 100644 --- a/src/libYARP_OS/src/ResourceFinder.cpp +++ b/src/libYARP_OS/src/ResourceFinder.cpp @@ -414,10 +414,11 @@ class ResourceFinderHelper { } ConstString s = ""; + ConstString slash = NetworkBase::getDirectorySeparator(); if (base1!="") { s = base1; - s = s + "/"; + s = s + slash; } if (isRooted(base2)) { @@ -426,7 +427,7 @@ class ResourceFinderHelper { s = s + base2; } if (base2!="") { - s = s + "/"; + s = s + slash; } if (isRooted(base3)) { @@ -435,7 +436,7 @@ class ResourceFinderHelper { s = s + base3; } if (base3!="") { - s = s + "/"; + s = s + slash; } s = s + name; @@ -835,9 +836,10 @@ class ResourceFinderHelper { { ConstString path = getPath(ResourceFinder::getDataHome(), "contexts", context, ""); + ConstString slash = NetworkBase::getDirectorySeparator(); if (path.length()>1) { - if (path[path.length()-1]=='/') { - path = path.substr(0,path.length()-1); + if (path[path.length()-1] == slash[0]) { + path = path.substr(0,path.length()-slash.size()); } } @@ -861,9 +863,10 @@ class ResourceFinderHelper { if (!found) robot = "default"; ConstString path = getPath(ResourceFinder::getDataHome(), "robots", robot, ""); + ConstString slash = NetworkBase::getDirectorySeparator(); if (path.length()>1) { - if (path[path.length()-1]=='/') { - path = path.substr(0,path.length()-1); + if (path[path.length()-1]==slash[0]) { + path = path.substr(0,path.length()-slash.size()); } } @@ -887,9 +890,10 @@ class ResourceFinderHelper { ConstString cap = config.check("capability_directory",Value("app")).asString(); ConstString path = getPath(root,cap,context,""); + ConstString slash = NetworkBase::getDirectorySeparator(); if (path.length()>1) { - if (path[path.length()-1]=='/') { - path = path.substr(0,path.length()-1); + if (path[path.length()-1]==slash[0]) { + path = path.substr(0,path.length()-slash.size()); } } return path;