Exemplo n.º 1
0
Arquivo: js.cpp Projeto: xkp/XKP
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();
  }
Exemplo n.º 2
0
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;
}