// file : build2/functions-path.cxx -*- C++ -*- // copyright : Copyright (c) 2014-2016 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #include #include using namespace std; namespace build2 { static value path_thunk (vector_view args, const function_overload& f) try { return function_family::default_thunk (move (args), f); } catch (const invalid_path& e) { fail << "invalid path: '" << e.path << "'" << endf; } void path_functions () { function_family f ("path", &path_thunk); // normalize // f["normalize"] = [](path p) {p.normalize (); return p;}; f["normalize"] = [](paths v) {for (auto& p: v) p.normalize (); return v;}; f["normalize"] = [](dir_path p) {p.normalize (); return p;}; f["normalize"] = [](dir_paths v) {for (auto& p: v) p.normalize (); return v;}; f[".normalize"] = [](names ns) { // For each path decide based on the presence of a trailing slash // whether it is a directory. Return as untyped list of (potentially // mixed) paths. // for (name& n: ns) { if (n.directory ()) n.dir.normalize (); else n.value = convert (move (n)).normalize ().string (); } return ns; }; } }