Beispiel #1
0
void FileName::generateDiskNames()
{
  //QCString commonPrefix;
  QListIterator<FileDef> it(*this);
  FileDef *fd;
  int count=0;
  for (;(fd=it.current());++it)
  {
    if (!fd->isReference()) count++;
  }
  if (count==1)
  {
    // skip references
    for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
    if (fd)
    {
      // name if unique, so diskname is simply the name
      //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data());
      fd->m_diskName=name;
    }
  }
  else if (count>1) // multiple occurrences of the same file name
  {
    //printf("Multiple occurrences of %s\n",name.data());
    int i=0,j=0;
    bool found=FALSE;
    while (!found) // search for the common prefix of all paths
    {
      for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
      if (fd)
      {
        char c=fd->m_path.at(i);
        if (c=='/') j=i; // remember last position of dirname
        ++it;
        while ((fd=it.current()) && !found)
        {
          if (!fd->isReference())
          {
            //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data());
            if (i==(int)fd->m_path.length())
            {
              //warning("Input file %s found multiple times!\n"
              //        "         The generated documentation for this file may not be correct!\n",fd->absFilePath().data());
              found=TRUE;
            }
            else if (fd->m_path[i]!=c)
            {
              found=TRUE;
            }
          }
          ++it;
        }
        i++;
      }
    }
    for (it.toFirst();(fd=it.current());++it)
    {
      //printf("fd->setName(%s)\n",(fd->path.right(fd->path.length()-j-1)+name).data());
      if (!fd->isReference())
      {
        QCString prefix = fd->m_path.right(fd->m_path.length()-j-1);
        fd->setName(prefix+name);
        //printf("!!!!!!!! non unique disk name=%s for fd=%s\n",(prefix+name).data(),fd->diskname.data());
        fd->m_diskName=prefix+name;
      }
    }
  }
}