ArmarXDataPath.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::core
19 * @author Nikolaus Vahrenkamp
20 * @date 2012
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #include "ArmarXDataPath.h" // for ArmarXDataPath
26 
27 #include <algorithm> // for min, fill, find
28 #include <cstdlib> // for getenv
29 #include <filesystem>
30 #include <fstream>
31 #include <regex>
32 #include <sstream> // for operator<<, char_traits, etc
33 #include <string> // for basic_string, string, etc
34 #include <vector> // for vector
35 
36 #include <boost/regex.hpp>
37 
38 #include <IceUtil/Handle.h> // for HandleBase
39 
40 #include <SimoxUtility/algorithm/string/string_tools.h>
41 #include <SimoxUtility/simox/SimoxPath.h>
42 
44 #include "ArmarXCore/core/exceptions/Exception.h" // for LocalException
45 #include "ArmarXCore/core/logging/LogSender.h" // for LogSender
47 #include <ArmarXCore/core/logging/Logging.h> // for ARMARX_WARNING_S, etc
49 #include <ArmarXCore/core/util/StringHelpers.h> // for Contains, VAROUT
51 
53 
54 //#include <execinfo.h>
55 //#include <stdio.h>
56 
57 namespace armarx
58 {
59  namespace fs = std::filesystem;
60 
61  // static void printBacktrace()
62  // {
63  // void* callstack[128];
64  // int i, frames = backtrace(callstack, 128);
65  // char** strs = backtrace_symbols(callstack, frames);
66  // for (i = 0; i < frames; ++i)
67  // {
68  // printf("%s\n", strs[i]);
69  // }
70  // free(strs);
71  // }
72 
74  {
76  {
77  // printf("Creating ArmarXDataPath_Data, this: %p\n", (void*)this);
78  // printBacktrace();
79  }
80 
82  {
83  // This is super weird!
84  // This global object should exist only once.
85  // However, we get two instances if run ArmarXGUIRun
86  // This actually causes a double free if we put these variables
87  // as static variables in the class (the vector is freed twice).
88 
89  // We now put these variables in this .cpp file to prevent double free.
90  // However, this means we have multiple instances now!
91  // How can this even happen?
92  // Are there two instances of ArmarXCore.so loaded in the GUI?
93 
94  // printf("Destroying ArmarXDataPath_Data(), this: %p\n", (void*)this);
95  // printBacktrace();
96  }
97 
98  std::vector<std::string> dataPaths;
99  bool initialized = false;
100  };
101 
102  static ArmarXDataPath_Data ArmarXDataPath_data;
103 
104 
105  ArmarXDataPath::ArmarXDataPath()
106  {
107  }
108 
109 
110  bool
111  ArmarXDataPath::getAbsolutePath(const std::string& relativeFilename,
112  std::string& storeAbsoluteFilename,
113  const std::vector<std::string>& additionalSearchPaths,
114  bool verbose)
115  {
116 
117  init();
118 
119  const std::filesystem::path filename(relativeFilename);
120 
121  // first: check current path
122  if (std::filesystem::exists(filename))
123  {
124  storeAbsoluteFilename = filename.string();
125  return true;
126  }
127 
128  const auto search = [&filename, &storeAbsoluteFilename](const auto& bases)
129  {
130  for (const auto& currentPath : bases)
131  {
132  std::filesystem::path path(currentPath);
133 
134  std::filesystem::path filenameComplete = path / filename;
135 
136  if (std::filesystem::exists(filenameComplete))
137  {
138  storeAbsoluteFilename = filenameComplete.string();
139  return true;
140  }
141  }
142  return false;
143  };
144  const auto searchProject = [&search](const auto& project)
145  {
146  CMakePackageFinder finder(project);
147  auto pathsString = finder.getDataDir();
148  Ice::StringSeq projectDataPaths = simox::alg::split(pathsString, ";,");
149  return search(projectDataPaths);
150  };
151  {
152  if (search(additionalSearchPaths) || search(ArmarXDataPath_data.dataPaths))
153  {
154  return true;
155  }
156  }
157 
158  //search for a package with the first part of the path (e.g.: ArmarxCore for the path ArmarXCore/foo/bar)
159  {
160  std::filesystem::path p = relativeFilename;
161 
162  if (p.is_absolute())
163  {
164  p = std::filesystem::relative(p, "/");
165  }
166  while (p.has_parent_path())
167  {
168  if (p.parent_path() == ".")
169  {
170  p = p.filename();
171  }
172  else
173  {
174  p = p.parent_path();
175  }
176  }
177  const auto pstr = p.string();
178  if (!pstr.empty() && searchProject(pstr))
179  {
180  return true;
181  }
182  }
183 
184  //search in all projects from getDefaultPackageNames()
186  {
187  for (const auto& project : Application::getInstance()->getArmarXPackageNames())
188  {
189  if (searchProject(project))
190  {
191  return true;
192  }
193  }
194  }
195 
196  if (verbose)
197  {
198  ARMARX_WARNING_S << "Could not find file '" << relativeFilename << "'"
199  << "\n in the following additional paths: " << additionalSearchPaths
200  << "\n or in the following data paths: "
201  << ArmarXDataPath_data.dataPaths;
202  }
203 
204  return false;
205  }
206 
207  std::string
208  ArmarXDataPath::getAbsolutePath(const std::string& relativeFilename,
209  const std::vector<std::string>& additionalSearchPaths,
210  bool verbose)
211  {
212  std::string storeAbsoluteFilename;
213  getAbsolutePath(relativeFilename, storeAbsoluteFilename, additionalSearchPaths, verbose);
214  return storeAbsoluteFilename;
215  }
216 
217  bool
218  ArmarXDataPath::SearchReadableFile(const std::string& queryFileName,
219  std::string& resultFileName,
220  bool verbose)
221  {
222  const auto file_ok = [](const std::string& f)
223  { return std::filesystem::exists(f) && std::ifstream(f).good(); };
224 
225  //cases
226  // -absolute
227  // - readable -> done
228  // - not readable -> try to find part
229  // - relative
230  // - found path
231  // - readable -> done
232  // - not readable -> failure
233  // - failed to find path
234  // - search for sub parts -> try search again
235 
236  if (std::filesystem::path{queryFileName}.is_absolute() && file_ok(queryFileName))
237  {
238  resultFileName = queryFileName;
239  return true;
240  }
241  //here queryFileName is always relative or the absolute is not ok
242  std::string found_file;
243  if (getAbsolutePath(queryFileName, found_file, {}, verbose) && file_ok(found_file))
244  {
245  resultFileName = found_file;
246  return true;
247  }
248  //now we need to try to search for package names
249  // try all strings ... of pattern /data/.../
250  std::size_t offset = 0;
251  while (offset != std::string::npos && offset < queryFileName.size())
252  {
253  // deal with paths like /prefix/data/foo/data/bar/file
254  // -> search for 'foo/data/bar/file' and 'bar/file'
255  static const std::string dataMarker = "/data/";
256  offset = queryFileName.find(dataMarker, offset);
257  if (offset == std::string::npos)
258  {
259  return false;
260  }
261  const std::string prefix_path = queryFileName.substr(0, offset);
262  offset += dataMarker.size();
263  const std::string path_in_data = queryFileName.substr(offset);
264 
265  // Check for '.../VirtualRobot/data/...'
266  if (simox::alg::ends_with(prefix_path, "VirtualRobot"))
267  {
268  found_file = simox::SimoxPath::getVirtualRobotDataDir() / path_in_data;
269  if (file_ok(found_file))
270  {
271  resultFileName = found_file;
272  return true;
273  }
274  }
275 
276  if (getAbsolutePath(path_in_data, found_file, {}, verbose) && file_ok(found_file))
277  {
278  resultFileName = found_file;
279  return true;
280  }
281  const std::size_t slash_offset = path_in_data.find("/");
282  if (slash_offset == std::string::npos)
283  {
284  return false;
285  }
286  const std::string package_name = path_in_data.substr(0, slash_offset);
287 
288  if (FindPackageAndAddDataPath(package_name) && // found package
289  getAbsolutePath(path_in_data, found_file) && // found file
290  file_ok(found_file) // file ok
291  )
292  {
293  resultFileName = found_file;
294  return true;
295  }
296  }
297  return false;
298  }
299 
300  std::string
301  ArmarXDataPath::getProject(const std::vector<std::string>& projects,
302  const std::string& relativeFilename)
303  {
304  std::filesystem::path fn(relativeFilename);
305  for (auto currentProject : projects)
306  {
307  armarx::CMakePackageFinder finder(currentProject);
308 
309  if (!finder.packageFound())
310  {
311  ARMARX_VERBOSE_S << "ArmarX Package " << currentProject << " has not been found!";
312  continue;
313  }
314 
315  //ARMARX_INFO_S << "Checking datapath: " << finder.getDataDir();
316  std::filesystem::path p(finder.getDataDir());
317  std::filesystem::path fnComplete = p / fn;
318 
319  if (std::filesystem::exists(fnComplete))
320  {
321  //ARMARX_INFO_S << "Found in project " << currentProject;
322  return currentProject;
323  }
324  }
325 
326  return std::string();
327  }
328 
329 
330  std::string
331  ArmarXDataPath::cleanPath(const std::string& filepathStr)
332  {
333  std::filesystem::path p(filepathStr);
334  std::filesystem::path result;
335 
336  for (std::filesystem::path::iterator it = p.begin(); it != p.end(); ++it)
337  {
338  if (*it == ".." && it != p.begin())
339  {
340  // /a/b/.. is not necessarily /a if b is a symbolic link
341  bool isSymLink = false;
342 
343  try
344  {
345  isSymLink = std::filesystem::is_symlink(result);
346  }
347  catch (std::filesystem::filesystem_error&)
348  {
349  }
350 
351  if (isSymLink)
352  {
353  result /= *it;
354  }
355  // /a/b/../.. is not /a/b/.. under most circumstances
356  // We can end up with ..s in our result because of symbolic links
357  else if (result.filename() == "..")
358  {
359  result /= *it;
360  }
361  // Otherwise it should be safe to resolve the parent
362  else
363  {
364  result = result.parent_path();
365  }
366  }
367  else if (*it == ".")
368  {
369  // Ignore
370  }
371  else
372  {
373  // Just concatenate other path entries
374  result /= *it;
375  }
376  }
377 
378  return result.string();
379  }
380 
381  std::string
382  ArmarXDataPath::getRelativeArmarXPath(const std::string& absolutePathString)
383  {
384  init();
385 
386  // traverse directories until root is reached
387  for (auto absolutePathPart = std::filesystem::path(absolutePathString);
388  absolutePathPart != absolutePathPart.parent_path();
389  absolutePathPart = absolutePathPart.parent_path())
390  {
391  for (const auto& dataPath : ArmarXDataPath_data.dataPaths)
392  {
393  const std::filesystem::path p(dataPath);
394 
395  if (std::filesystem::equivalent(p, absolutePathPart))
396  {
397  return relativeTo(p.string(), absolutePathString);
398  }
399  }
400  }
401 
402  throw LocalException() << "Could not make path relative to any ArmarX data path for '"
403  << absolutePathString << "'. "
404  << "Considered the following paths: "
405  << ArmarXDataPath_data.dataPaths;
406  return absolutePathString;
407  }
408 
409  std::string
410  ArmarXDataPath::relativeTo(const std::string& fromStr, const std::string& toStr)
411  {
412  // Start at the root path. While they are the same, do nothing.
413  // When they first diverge, take the remainder of the two paths
414  // and replace the entire from path with ".." segments.
415  fs::path from(fromStr);
416  fs::path to(toStr);
417  fs::path::const_iterator fromIter = (from).begin();
418  fs::path::const_iterator toIter = (to).begin();
419  if (from.empty())
420  {
421  throw LocalException("From path is empty");
422  }
423  if (to.empty())
424  {
425  throw LocalException("To path is empty");
426  }
427  if (*fromIter != *toIter)
428  {
429  throw LocalException("From and to path do not have the same toplevel dir: ")
430  << VAROUT(fromStr) << VAROUT(toStr);
431  }
432  // Loop through both
433  while (fromIter != from.end() && toIter != to.end() && (*toIter) == (*fromIter))
434  {
435  ++toIter;
436  ++fromIter;
437  }
438 
439  fs::path finalPath;
440  while (fromIter != from.end())
441  {
442  finalPath /= "..";
443  ++fromIter;
444  }
445 
446  while (toIter != to.end())
447  {
448  finalPath /= *toIter;
449  ++toIter;
450  }
451 
452  return finalPath.string();
453  }
454 
455  bool
456  ArmarXDataPath::mergePaths(std::string pathStr, std::string subPathStr, std::string& result)
457  {
458  fs::path subPath(subPathStr);
459  pathStr = cleanPath(pathStr);
460  subPathStr = cleanPath(subPathStr);
461  fs::path strippedPath;
462  while (!subPath.empty())
463  {
464  if (Contains(pathStr, subPath.string()))
465  {
466  result = remove_trailing_separator(fs::path(pathStr) / strippedPath).string();
467  return true;
468  }
469  strippedPath = subPath.filename() / strippedPath;
470  subPath = subPath.parent_path();
471  }
472  result.clear();
473  return false;
474  }
475 
476  void
477  ArmarXDataPath::initDataPaths(const std::string& dataPathList)
478  {
479  addDataPaths(dataPathList);
480  }
481 
482  bool
483  ArmarXDataPath::ReplaceEnvVars(std::string& string)
484  {
485  const boost::regex e("\\$([a-zA-Z0-9_]+)");
486  const boost::regex e2("\\$\\{([a-zA-Z0-9_]+)\\}");
487  boost::match_results<std::string::const_iterator> what;
488  bool found = false;
489  auto replaceVars = [&](const boost::regex& e)
490  {
491  bool found_match = boost::regex_search(string, what, e);
492  if (found_match)
493  {
494  for (size_t i = 1; i < what.size(); i += 2)
495  {
496  std::string var = what[i];
497 
498  auto envVar = getenv(var.c_str());
499  if (envVar)
500  {
501  string = boost::regex_replace(string, e, std::string(envVar));
502  found = true;
503  }
504  }
505  }
506  };
507  replaceVars(e);
508  replaceVars(e2);
509  return found;
510  }
511 
512  void
513  ArmarXDataPath::ReplaceVar(std::string& string,
514  const std::string varName,
515  const std::string& varValue)
516  {
517  string = simox::alg::replace_all(string, std::string("${") + varName + "}", varValue);
518  }
519 
520  void
522  {
523  ReplaceEnvVars(path);
524  if (!path.empty() && path[0] == '~')
525  {
526  path = path.erase(0, 1);
527  auto envVar = getenv("HOME");
528  if (envVar)
529  {
530  path = std::string(envVar) + "/" + path;
531  }
532  else
533  {
534  ARMARX_WARNING << "$HOME var is not set!";
535  }
536  }
537  path = cleanPath(path);
538  }
539 
540 
541  std::string
542  ArmarXDataPath::resolvePath(const std::string& path, bool verbose)
543  {
544  std::string resolved = path;
545  ResolveHomePath(resolved);
546  if (fs::path(resolved).is_relative())
547  {
548  std::string absolute;
549  if (getAbsolutePath(resolved, absolute, {}, verbose))
550  {
551  resolved = absolute;
552  }
553  }
554  return resolved;
555  }
556 
557 
558  void
559  ArmarXDataPath::addDataPaths(const std::string& dataPathList)
560  {
561  init();
562  __addPaths(dataPathList);
563  }
564 
565  void
566  ArmarXDataPath::addDataPaths(const std::vector<std::string>& dataPathList)
567  {
568  init();
569  for (const auto& p : dataPathList)
570  {
571  __addPaths(p);
572  }
573  }
574 
575  void
576  ArmarXDataPath::addDataPath(const std::string& dataPath)
577  {
578  init();
579  __addPaths(dataPath);
580  }
581 
582  std::string
584  {
585  if (const char* home_path = std::getenv("ArmarXHome_DIR"))
586  {
587  return cleanPath(std::string(home_path));
588  }
589  return std::string();
590  }
591 
592  void
593  ArmarXDataPath::init()
594  {
595  if (ArmarXDataPath_data.initialized)
596  {
597  return;
598  }
599 
600  // printf("ArmarXDataPath::init(), this=%p\n", (void*)&ArmarXDataPath_data);
601  // printBacktrace();
602 
603  if (const char* data_path = std::getenv("ArmarXData_DIRS"))
604  {
605  std::string pathStr(data_path);
606  __addPaths(pathStr);
607  }
608 
609  //check the documented variable
610  if (const char* data_path_dir = std::getenv("ArmarXData_DIR"))
611  {
612  std::string pathStr(data_path_dir);
613  __addPaths(pathStr);
614  }
615 
616  ArmarXDataPath_data.initialized = true;
617  }
618 
619  std::vector<std::string>
621  {
622  return ArmarXDataPath_data.dataPaths;
623  }
624 
625  bool
626  ArmarXDataPath::__addPaths(const std::string& pathList)
627  {
628  if (pathList == "")
629  {
630  return false;
631  }
632 
633  std::vector<std::string> separatedPaths = __separatePaths(pathList);
634 
635  if (separatedPaths.size() == 0)
636  {
637  return false;
638  }
639 
640  bool ok = true;
641 
642  for (int i = separatedPaths.size() - 1; i >= 0; i--)
643  {
644  ArmarXDataPath::ReplaceEnvVars(separatedPaths[i]);
645  ok = ok & __addPath(separatedPaths[i]);
646  }
647 
648  return ok;
649  }
650 
651  std::vector<std::string>
652  ArmarXDataPath::__separatePaths(const std::string& pathList)
653  {
654  std::string delimiters = ";";
655  std::vector<std::string> tokens = simox::alg::split(pathList, delimiters);
656  return tokens;
657  }
658 
659  bool
660  ArmarXDataPath::__pathIsValid(const std::string& path)
661  {
662  if (path.empty())
663  {
664  return false;
665  }
666 
667  std::filesystem::path p(path);
668  return std::filesystem::is_directory(p) || std::filesystem::is_symlink(p);
669  }
670 
671  bool
672  ArmarXDataPath::__addPath(const std::string& path)
673  {
674  if (path.empty())
675  {
676  return false;
677  }
678 
679  std::vector<std::string> splitted = simox::alg::split(path, "/");
680 
681  if (splitted.size() < 3)
682  {
683  ARMARX_WARNING_S << "Not a valid data path: '" << path << "'" << std::endl;
684  return false;
685  }
686 
687  std::string root = "";
688  std::string project = splitted[splitted.size() - 2];
689  std::string data = splitted[splitted.size() - 1];
690 
691  for (unsigned int i = 0; i < splitted.size() - 2; ++i)
692  {
693  root += "/" + splitted[i];
694  }
695 
696  std::filesystem::path p(root + "/" + project + "/" + data);
697 
698  if (!__pathIsValid(p))
699  {
700  ARMARX_INFO_S << "Not a valid data path: '" << p
701  << "'. Try to capitalize project folder..." << std::endl;
702 
703  // also check for capitalized parent folder (usually the project)
704  project = simox::alg::capitalize_words(project);
705  p = std::filesystem::path(root + "/" + project + "/" + data);
706  if (!__pathIsValid(p))
707  {
708  ARMARX_INFO_S << "Not a valid data path: '" << p
709  << "'. Try to caps project folder..." << std::endl;
710 
711  // also check for caps parent folder (usually the project)
712  project = simox::alg::to_upper(project);
713  p = std::filesystem::path(root + "/" + project + "/" + data);
714 
715  if (!__pathIsValid(p))
716  {
717  ARMARX_WARNING_S << "Not a valid data path: '" << p << "'" << std::endl;
718  return false;
719  }
720  }
721  }
722 
723  if (std::find(ArmarXDataPath_data.dataPaths.begin(),
724  ArmarXDataPath_data.dataPaths.end(),
725  p) == ArmarXDataPath_data.dataPaths.end())
726  {
727  ARMARX_DEBUG_S << "Adding data path:" << p << std::endl;
728  ArmarXDataPath_data.dataPaths.push_back(p);
729  }
730  return true;
731  }
732 
733  std::string
735  {
736  try
737  {
739  if (application.get() != nullptr)
740  {
741 
742  std::string cachePathStr;
743 
744  cachePathStr = application->getProperty<std::string>("CachePath").getValue();
745  if (std::filesystem::path(cachePathStr).is_relative())
746  {
747  std::string pathPrefix;
748  if (getenv(Application::ArmarXUserConfigDirEnvVar.c_str()))
749  {
750  pathPrefix =
751  std::string(getenv(Application::ArmarXUserConfigDirEnvVar.c_str()));
752  }
753  else
754  {
756  }
757  // ARMARX_INFO << VAROUT(pathPrefix);
758  cachePathStr =
759  (std::filesystem::path(pathPrefix) / std::filesystem::path(cachePathStr))
760  .string();
761  }
762  else
763  {
764  // ARMARX_INFO << "Cache path is absolute: " << cachePathStr;
765  }
766 
767  ReplaceEnvVars(cachePathStr);
768  return cachePathStr;
769  }
770  else
771  {
772  return "";
773  }
774  }
775  catch (LocalException& error)
776  {
777  return "";
778  }
779  }
780 
781  std::string
783  {
784  char* env_armarx_workspace = getenv("ARMARX_WORKSPACE");
785  char* env_armarx_default_config_dir_name = getenv("ARMARX_CONFIG_DIR_NAME");
786 
787  std::filesystem::path armarx_workspace;
788  std::filesystem::path armarx_config_dir;
789 
790  if (env_armarx_workspace != nullptr)
791  {
792  armarx_workspace = std::filesystem::path(env_armarx_workspace);
793  }
794  else
795  {
796  char* home = getenv("HOME");
797 
798  if (home != nullptr)
799  {
800  armarx_workspace = std::filesystem::path(home);
801  }
802  else
803  {
804  armarx_workspace = "~/";
805  }
806  }
807 
808  if (env_armarx_default_config_dir_name != nullptr)
809  {
810  armarx_config_dir = std::filesystem::path(env_armarx_default_config_dir_name);
811  }
812  else
813  {
814  if (env_armarx_workspace != nullptr)
815  {
816  armarx_config_dir = "armarx_config";
817  }
818  // Legacy mode.
819  else
820  {
821  armarx_config_dir = ".armarx";
822  }
823  }
824 
825  return (armarx_workspace / armarx_config_dir).string();
826  }
827 
828  bool
829  ArmarXDataPath::FindPackageAndAddDataPath(const std::string& packageName)
830  {
831  if (packageName.empty())
832  {
833  return false;
834  }
835  armarx::CMakePackageFinder finder(packageName);
836  if (finder.packageFound())
837  {
839  return true;
840  }
841  return false;
842  }
843 } // namespace armarx
armarx::ArmarXDataPath::resolvePath
static std::string resolvePath(const std::string &path, bool verbose=true)
Resolves environment variables and home paths and tries to make path absolute.
Definition: ArmarXDataPath.cpp:542
armarx::ArmarXDataPath_Data::~ArmarXDataPath_Data
~ArmarXDataPath_Data()
Definition: ArmarXDataPath.cpp:81
armarx::ArmarXDataPath::relativeTo
static std::string relativeTo(const std::string &from, const std::string &to)
Transform an absolute filepath into a relative path of the other absolute filepath.
Definition: ArmarXDataPath.cpp:410
armarx::ArmarXDataPath::addDataPath
static void addDataPath(const std::string &dataPath)
Definition: ArmarXDataPath.cpp:576
armarx::CMakePackageFinder::packageFound
bool packageFound() const
Returns whether or not this package was found with cmake.
Definition: CMakePackageFinder.cpp:485
armarx::ArmarXDataPath::ResolveHomePath
static void ResolveHomePath(std::string &path)
Resolves a path like ~/myfile.txt or $HOME/myfile.txt to /home/user/myfile.txt.
Definition: ArmarXDataPath.cpp:521
armarx::ArmarXDataPath::cleanPath
static std::string cleanPath(const std::string &filepathStr)
Definition: ArmarXDataPath.cpp:331
armarx::ArmarXDataPath_Data::dataPaths
std::vector< std::string > dataPaths
Definition: ArmarXDataPath.cpp:98
armarx::ArmarXDataPath::FindPackageAndAddDataPath
static bool FindPackageAndAddDataPath(const std::string &packageName)
Search for the package and add its data path if it was found.
Definition: ArmarXDataPath.cpp:829
armarx::remove_trailing_separator
fs::path remove_trailing_separator(fs::path p)
Definition: filesystem.h:32
armarx::Contains
bool Contains(const ContainerType &container, const ElementType &searchElement)
Definition: algorithm.h:295
armarx::ArmarXDataPath::getHomePath
static std::string getHomePath()
Definition: ArmarXDataPath.cpp:583
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
filesystem.h
armarx::ArmarXDataPath::getDataPaths
static std::vector< std::string > getDataPaths()
Definition: ArmarXDataPath.cpp:620
armarx::Application::GetArmarXConfigDefaultPath
static std::string GetArmarXConfigDefaultPath(bool envVarExpanded=true)
Definition: Application.cpp:687
armarx::ArmarXDataPath::getProject
static std::string getProject(const std::vector< std::string > &projects, const std::string &relativeFilename)
Definition: ArmarXDataPath.cpp:301
armarx::ArmarXDataPath_Data
Definition: ArmarXDataPath.cpp:73
visionx::imrecman::ok
@ ok
Definition: ImageRecordingManagerInterface.ice:46
project
std::string project
Definition: VisualizationRobot.cpp:83
StringHelpers.h
armarx::ArmarXDataPath::ReplaceVar
static void ReplaceVar(std::string &string, const std::string varName, const std::string &varValue)
Replaces all occurences of variables in bash notation, e.g.
Definition: ArmarXDataPath.cpp:513
ARMARX_DEBUG_S
#define ARMARX_DEBUG_S
Definition: Logging.h:198
Property.h
armarx::ArmarXDataPath::GetCachePath
static std::string GetCachePath()
The base Cache directory of ArmarX.
Definition: ArmarXDataPath.cpp:734
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::CMakePackageFinder::getDataDir
std::string getDataDir() const
Definition: CMakePackageFinder.h:176
armarx::ArmarXDataPath::getRelativeArmarXPath
static std::string getRelativeArmarXPath(const std::string &absolutePathString)
This method tries to morph a given absolute path into a relative path to a ArmarXDataPath.
Definition: ArmarXDataPath.cpp:382
filename
std::string filename
Definition: VisualizationRobot.cpp:84
armarx::Application::getInstance
static ApplicationPtr getInstance()
Retrieve shared pointer to the application object.
Definition: Application.cpp:289
armarx::ArmarXDataPath::initDataPaths
static void initDataPaths(const std::string &dataPathList)
Definition: ArmarXDataPath.cpp:477
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
armarx::ArmarXDataPath::GetDefaultUserConfigPath
static std::string GetDefaultUserConfigPath()
The user config directory of ArmarX.
Definition: ArmarXDataPath.cpp:782
armarx::ArmarXDataPath::SearchReadableFile
static bool SearchReadableFile(const std::string &querryFileName, std::string &resultFileName, bool verbose=true)
Definition: ArmarXDataPath.cpp:218
CMakePackageFinder.h
armarx::ArmarXDataPath::addDataPaths
static void addDataPaths(const std::string &dataPathList)
Definition: ArmarXDataPath.cpp:559
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:182
IceUtil::Handle< Application >
armarx::ArmarXDataPath::ReplaceEnvVars
static bool ReplaceEnvVars(std::string &string)
ReplaceEnvVars replaces environment variables in a string with their values, if the env.
Definition: ArmarXDataPath.cpp:483
armarx::ends_with
bool ends_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:50
LogSender.h
armarx::ArmarXDataPath_Data::initialized
bool initialized
Definition: ArmarXDataPath.cpp:99
ARMARX_VERBOSE_S
#define ARMARX_VERBOSE_S
Definition: Logging.h:200
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::ArmarXDataPath::getAbsolutePath
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
Definition: ArmarXDataPath.cpp:111
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
ArmarXDataPath.h
armarx::Application::ArmarXUserConfigDirEnvVar
static const std::string ArmarXUserConfigDirEnvVar
Definition: Application.h:296
armarx::ArmarXDataPath_Data::ArmarXDataPath_Data
ArmarXDataPath_Data()
Definition: ArmarXDataPath.cpp:75
armarx::ArmarXDataPath::mergePaths
static bool mergePaths(std::string path, std::string subPath, std::string &result)
Definition: ArmarXDataPath.cpp:456
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
Exception.h
Application.h
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:36