.. _program_listing_file_src_common_cli_helper.cpp: Program Listing for File cli_helper.cpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``src/common/cli_helper.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "common/cli_helper.h" #include "common/filesystem.h" namespace marian { namespace cli { void makeAbsolutePaths(YAML::Node& config, const std::string& configPath, const std::set& PATHS) { auto configDir = filesystem::Path{configPath}.parentPath(); auto transformFunc = [&](const std::string& nodePath) -> std::string { // Catch stdin/stdout and do not process if(nodePath == "stdin" || nodePath == "stdout") return nodePath; // replace relative path w.r.t. config directory try { return canonical(filesystem::Path{nodePath}, configDir).string(); } catch(filesystem::FilesystemError& e) { // will fail if file does not exist; use parent in that case std::cerr << e.what() << std::endl; auto parentPath = filesystem::Path{nodePath}.parentPath(); return (canonical(parentPath, configDir) / filesystem::Path{nodePath}.filename()) .string(); } }; processPaths(config, transformFunc, PATHS); } } // namespace cli } // namespace marian