Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
pinocchio
Commits
da30d860
Commit
da30d860
authored
Jul 09, 2021
by
Wolfgang Merkt
Browse files
Use boost::filesystem to make ROS package path look-up platform independent
parent
6d443445
Pipeline
#15152
passed with stage
in 219 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/utils/file-explorer.cpp
View file @
da30d860
...
...
@@ -3,8 +3,10 @@
//
#include <cstdlib>
#include <boost/filesystem.hpp>
#include "pinocchio/utils/file-explorer.hpp"
namespace
fs
=
boost
::
filesystem
;
namespace
pinocchio
{
...
...
@@ -20,15 +22,22 @@ namespace pinocchio
// Add a separator at the end so that last path is also retrieved
policyStr
+=
std
::
string
(
":"
);
size_t
lastOffset
=
0
;
std
::
string
path_string
;
path_string
.
reserve
(
500
);
fs
::
path
path
;
while
(
true
)
{
size_t
offset
=
policyStr
.
find_first_of
(
delimiter
,
lastOffset
);
if
(
offset
<
policyStr
.
size
())
{
list_of_paths
.
push_back
(
policyStr
.
substr
(
lastOffset
,
offset
-
lastOffset
));
// Support for devel spaces: We also need to look one package above:
path_string
=
policyStr
.
substr
(
lastOffset
,
offset
-
lastOffset
);
path
=
fs
::
path
(
path_string
);
list_of_paths
.
push_back
(
path_string
);
// Work-around for https://github.com/stack-of-tasks/pinocchio/issues/1463
list_of_paths
.
push_back
(
policyStr
.
substr
(
lastOffset
,
offset
-
lastOffset
)
+
"/.."
);
// To support ROS devel/isolated spaces, we also need to look one package above the package.xml:
if
(
fs
::
exists
(
path
/
"package.xml"
))
{
list_of_paths
.
push_back
(
fs
::
path
(
path
/
".."
).
string
());
}
}
if
(
offset
==
std
::
string
::
npos
)
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment