My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filename.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
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.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #include "filename.h"
19 #include "util.h"
20 #include "config.h"
21 
22 FileName::FileName(const char *fn,const char *n) : FileList()
23 {
24  setAutoDelete(TRUE);
25  fName=fn;
26  name=n;
27 }
28 
30 {
31 }
32 
33 
35 {
36  //QCString commonPrefix;
37  QListIterator<FileDef> it(*this);
38  FileDef *fd;
39  int count=0;
40  for (;(fd=it.current());++it)
41  {
42  if (!fd->isReference()) count++;
43  }
44  if (count==1)
45  {
46  // skip references
47  for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
48  if (fd)
49  {
50  // name if unique, so diskname is simply the name
51  //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data());
52  fd->setDiskName(name);
53  }
54  }
55  else if (count>1) // multiple occurrences of the same file name
56  {
57  //printf("Multiple occurrences of %s\n",name.data());
58  int i=0,j=0;
59  bool found=FALSE;
60  while (!found) // search for the common prefix of all paths
61  {
62  for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
63  if (fd)
64  {
65  char c=fd->getPath().at(i);
66  if (c=='/') j=i; // remember last position of dirname
67  ++it;
68  while ((fd=it.current()) && !found)
69  {
70  QCString path = fd->getPath();
71  if (!fd->isReference())
72  {
73  //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data());
74  if (i==(int)path.length())
75  {
76  //warning("Input file %s found multiple times!\n"
77  // " The generated documentation for this file may not be correct!\n",fd->absFilePath().data());
78  found=TRUE;
79  }
80  else if (path[i]!=c)
81  {
82  found=TRUE;
83  }
84  }
85  ++it;
86  }
87  i++;
88  }
89  }
90  for (it.toFirst();(fd=it.current());++it)
91  {
92  //printf("fd->setName(%s)\n",(fd->path.right(fd->path.length()-j-1)+name).data());
93  if (!fd->isReference())
94  {
95  QCString path = fd->getPath();
96  QCString prefix = path.right(path.length()-j-1);
97  fd->setName(prefix+name);
98  //printf("!!!!!!!! non unique disk name=%s:%s\n",prefix.data(),name.data());
99  fd->setDiskName(prefix+name);
100  }
101  }
102  }
103 }
104 
105 int FileName::compareValues(const FileDef *f1, const FileDef *f2) const
106 {
107  return qstricmp(f1->fileName(),f2->fileName());
108 }
109 
111  QListIterator<FileDef>(fname)
112 {
113 }
114 
116 {
117 }
118 
120 {
121 }
122 
124 {
125  FileNameListIterator it(*this);
126  FileName *fn;
127  for (;(fn=it.current());++it)
128  {
129  fn->generateDiskNames();
130  }
131 }
132 
133 int FileNameList::compareValues(const FileName *f1, const FileName *f2) const
134 {
135  return Config_getBool(FULL_PATH_NAMES) ?
136  qstricmp(f1->fullName(),f2->fullName()) :
137  qstricmp(f1->fileName(),f2->fileName());
138 }
139 
141  QListIterator<FileName>(fnlist)
142 {
143 }
144 
145 static bool getCaseSenseNames()
146 {
147  static bool caseSenseNames = Config_getBool(CASE_SENSE_NAMES);
148  return caseSenseNames;
149 }
150 
152 {
153 }
154