Skip to content

Commit

Permalink
[ResourceFinder] Use native path separators when providing paths
Browse files Browse the repository at this point in the history
  • Loading branch information
elen4 committed Nov 4, 2013
1 parent b5bf758 commit 2855168
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/libYARP_OS/src/ResourceFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ class ResourceFinderHelper {
}

ConstString s = "";
ConstString slash = NetworkBase::getDirectorySeparator();

if (base1!="") {
s = base1;
s = s + "/";
s = s + slash;
}

if (isRooted(base2)) {
Expand All @@ -426,7 +427,7 @@ class ResourceFinderHelper {
s = s + base2;
}
if (base2!="") {
s = s + "/";
s = s + slash;
}

if (isRooted(base3)) {
Expand All @@ -435,7 +436,7 @@ class ResourceFinderHelper {
s = s + base3;
}
if (base3!="") {
s = s + "/";
s = s + slash;
}

s = s + name;
Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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());
}
}

Expand All @@ -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;
Expand Down

0 comments on commit 2855168

Please sign in to comment.