Ejemplo n.º 1
0
void base::trim_string(const base::string& input, base::string& output)
{
  int i, j;

  for (i=0; i<(int)input.size(); ++i)
    if (!std::isspace(input.at(i)))
      break;

  for (j=(int)input.size()-1; j>i; --j)
    if (!std::isspace(input.at(j)))
      break;

  if (i < j)
    output = input.substr(i, j - i + 1);
  else
    output = "";
}
Ejemplo n.º 2
0
static base::string remove_backslash_if_needed(const base::string& filename)
{
  if (!filename.empty() && base::is_path_separator(*(filename.end()-1))) {
    int len = filename.size();
#ifdef HAVE_DRIVES
    // if the name is C:\ or something like that, the backslash isn't
    // removed
    if (len == 3 && filename[1] == ':')
      return filename;
#else
    // this is just the root '/' slash
    if (len == 1)
      return filename;
#endif
    return base::remove_path_separator(filename);
  }
  return filename;
}