str js_lang::expression_path(const str& expr ) { size_t pos = expr.find_last_of("."); if (pos != str::npos) { return str(expr.begin(), expr.begin() + pos); } return str(); }
str get_filename_from_pathname(const str& pathname) { auto pos = pathname.find_last_of('/'); if(pos == pathname.size() - 1) throw std::runtime_error("bad pathname: " + pathname); else if(pos != str::npos) return pathname.substr(pos + 1); return pathname; }