Пример #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
Directory * StaticAPI::allocate(Directory & container, const Token & token, const char * id, bool regist)
{
    static unsigned int assignment_count = 0;
    Directory * node;

    if(!(token == Token::IDENTIFIER || token == Token::INTEGER))
        ExceptionMessage("Given token(%) is not suitable for an object identifier.","オブジェクトの識別名として利用できない字句(%)が指定されました") << token << throwException;

    if(regist && (token == Token::INTEGER && token.value <= 0))
        ExceptionMessage("Cannot assign an ID number less or equal to 0.","0以下のID番号を設定することはできません").throwException();


    node = container.findChild(id);
    if(node != 0)
    {
        Directory::iterator scope;

        scope = node->begin();
        while(scope != node->end())
        {
            if((*scope).first.compare(token) == 0)
                ExceptionMessage("Identifier % is already used.","識別名%はすでに利用されています") << token << throwException;
            ++ scope;
        }
    }else
        node = container.addChild(id);

    node = node->addChild(token);
    (*node)["#order"] = assignment_count++;

    if(token == Token::IDENTIFIER)
    {
        if(regist)
        {
            Directory * scope = container.openChild("/","identifier",token.c_str(),NULL);
            if(*scope == Directory::INTEGER)
                *node = scope->toInteger();
        }
    }else
        *node = token.value;

    last = node;
    return node;
}
Пример #3
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;
}
Пример #4
0
DirectoryIterator::DirectoryIterator(const Directory& dir)
{
    cur = dir.begin();
    end = dir.end();
    eof = (cur == end);
}