示例#1
0
std::vector<std::string>
System::opendir_recursive(const std::string& pathname)
{
  std::vector<std::string> lst;
  try
  {
    Directory dir = opendir(pathname);
    for(auto it = dir.begin(); it != dir.end(); ++it)
    {
      if (it->type == DE_DIRECTORY)
      {
        std::vector<std::string> subdir = opendir_recursive(Pathname::join(pathname, it->name));
        lst.insert(lst.end(), subdir.begin(), subdir.end());
      }
      else if (it->type == DE_FILE)
      {
        lst.push_back(Pathname::join(pathname, it->name));
      }
    }
  }
  catch(const std::exception& err)
  {
    log_warn("%1%", err.what());
  }
  return lst;
}
示例#2
0
std::vector<std::string>
System::opendir_recursive(const std::string& pathname)
{
  std::vector<std::string> lst;
  Directory dir = opendir(pathname);
  for(auto it = dir.begin(); it != dir.end(); ++it)
  {
    if (it->type == DE_DIRECTORY)
    {
      std::vector<std::string> subdir = opendir_recursive(pathname + "/" + it->name);
      lst.insert(lst.end(), subdir.begin(), subdir.end());
    }
    else if (it->type == DE_FILE)
    {
      lst.push_back(pathname + "/" + it->name);
    }
  }
  return lst;
}