1 /******************************************************************************
3 * $Id: filename.cpp,v 1.18 2001/03/19 19:27:40 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
21 FileName::FileName(const char *fn,const char *n) : FileList()
33 void FileName::generateDiskNames()
35 //QCString commonPrefix;
40 if (!fd->isReference()) count++;
47 while (fd && fd->isReference()) fd=next();
48 // name if unique, so diskname is simply the name
49 //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data());
50 fd->diskname=name.copy();
52 else if (count>1) // multiple occurrences of the same file name
54 //printf("Multiple occurrences of %s\n",name.data());
57 while (!found) // search for the common prefix of all paths
60 while (fd && fd->isReference()) fd=next();
61 char c=fd->path.at(i);
62 if (c=='/') j=i; // remember last position of dirname
66 if (!fd->isReference())
68 //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data());
69 if (i==(int)fd->path.length())
71 //warning("Warning: Input file %s found multiple times!\n"
72 // " The generated documentation for this file may not be correct!\n",fd->absFilePath().data());
75 else if (fd->path[i]!=c)
87 //printf("fd->setName(%s)\n",(fd->path.right(fd->path.length()-j-1)+name).data());
88 if (!fd->isReference())
90 QCString prefix = fd->path.right(fd->path.length()-j-1);
91 fd->setName(prefix+name);
92 //printf("!!!!!!!! non unique disk name=%s for fd=%s\n",(prefix+name).data(),fd->diskname.data());
93 fd->diskname=prefix+name;
100 int FileName::compareItems(GCI item1, GCI item2)
102 FileName *f1=(FileName *)item1;
103 FileName *f2=(FileName *)item2;
104 return stricmp(f1->fileName(),f2->fileName());
107 FileNameIterator::FileNameIterator(const FileName &fname) :
108 QListIterator<FileDef>(fname)
112 FileNameList::FileNameList() : QList<FileName>()
116 FileNameList::~FileNameList()
120 void FileNameList::generateDiskNames()
122 FileName *fn=first();
125 fn->generateDiskNames();
130 int FileNameList::compareItems(GCI item1, GCI item2)
132 FileName *f1=(FileName *)item1;
133 FileName *f2=(FileName *)item2;
134 //printf("FileNameList::compareItems `%s'<->`%s'\n",
135 // f1->fileName(),f2->fileName());
136 return Config_getBool("FULL_PATH_NAMES") ?
137 stricmp(f1->fullName(),f2->fullName()) :
138 stricmp(f1->fileName(),f2->fileName());
141 FileNameListIterator::FileNameListIterator(const FileNameList &fnlist) :
142 QListIterator<FileName>(fnlist)