Ejemplo n.º 1
0
//----------------------------------------
CAliases* CAliasesDictionary::CreateAliases(CXmlNode* aliasesNode)
{
  if (aliasesNode == NULL)
  {
    return NULL;
  }

  CAliases* aliases = new CAliases();

  std::string value;

  bool bOk = aliasesNode->GetPropVal(CAliasesDictionary::m_DESCR_ATTR, &value);
  aliases->SetDescription(value);
  
  value.clear();
  bOk = aliasesNode->GetPropVal(CAliasesDictionary::m_PRODUCT_TYPE_ATTR, &value);
  aliases->SetProductType(value);

  value.clear();
  bOk = aliasesNode->GetPropVal(CAliasesDictionary::m_REF_ATTR, &value);
  aliases->SetRef(value);

  value.clear();
  bOk = aliasesNode->GetPropVal(CAliasesDictionary::m_RECORD_ATTR, &value);
  aliases->SetRecord(value);

  CObArray arrayNodes(false);
  
  FindAllNodesByName(CAliasesDictionary::m_ALIAS_ELT, aliasesNode, arrayNodes, false);

  CObArray::const_iterator it;

  for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++)
  {
    CXmlNode* node = dynamic_cast<CXmlNode*>(*it);

    if (node == NULL)
    {
      continue;
    }

    CAlias* alias = CreateAlias(node);

    if (alias == NULL)
    {
      continue;
    }

    aliases->AddAlias(alias);
  }

  return aliases;
}
Ejemplo n.º 2
0
int main (int argc, const char * argv[])
{
  int     optch;
  static char optstring[] = OPT_STRING;

  while ((optch = getopt(argc, (char * const *)argv, optstring)) != -1)
  {
    switch(optch)
    {
      case 'v':
        PrintVersion();
        return EX_OK;
      case 'h':
        PrintHelp();
        return EX_OK;
      case 'c':
        noCustomIconCopy = true;
        break;
      case 't':
        noCopyFileCreatorTypes = true;
        break;
      case 'r':
        makeRelativeAlias = true;
    }
  }

  //check if a correct number of arguments was submitted
  if (argc - optind < 2)
  {
    fprintf(stderr,"Too few arguments.\n");
    PrintHelp();
    return EX_USAGE;
  }

  //check if file to be aliased exists
  if (access(argv[optind], F_OK) == -1)
  {
    perror(argv[optind]);
    return EX_NOINPUT;
  }

  //check if we can create alias in the specified location
  if (access(argv[optind+1], F_OK) != -1)
  {
    fprintf(stderr, "%s: File exists\n", argv[optind+1]);
    return EX_CANTCREAT;
  }

  CreateAlias(/*source*/(char *)argv[optind], /*destination*/(char *)argv[optind+1]);

  return EX_OK;
}