Skip to content

Commit f366804

Browse files
committed
bug_674442 CREATE_FOLDERS should not create unused folders
Also known as issue #4672 The folders are still created but in case the folders are empty after the doxygen run the directories are removed.
1 parent 8c8a034 commit f366804

18 files changed

+84
-0
lines changed

src/dir.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ bool Dir::exists() const
200200
return fi.exists() && fi.isDir();
201201
}
202202

203+
bool Dir::isEmpty(const std::string subdir) const
204+
{
205+
fs::path pth = path();
206+
pth /= subdir;
207+
return fs::is_empty(pth);
208+
}
209+
203210
bool Dir::isRelative() const
204211
{
205212
return isRelativePath(p->path.string());

src/dir.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Dir final
7878

7979
DirIterator iterator() const;
8080

81+
bool Dir::isEmpty(const std::string subdir) const;
8182
bool exists() const;
8283
std::string filePath(const std::string &path,bool acceptsAbsPath=true) const;
8384
bool exists(const std::string &path,bool acceptsAbsPath=true) const;

src/docbookgen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ void DocbookGenerator::init()
313313

314314
createSubDirs(d);
315315
}
316+
void DocbookGenerator::cleanup()
317+
{
318+
QCString dname = Config_getString(DOCBOOK_OUTPUT);
319+
Dir d(dname.str());
320+
clearSubDirs(d);
321+
}
322+
316323

317324
void DocbookGenerator::startFile(const QCString &name,const QCString &,const QCString &,int)
318325
{

src/docbookgen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class DocbookGenerator : public OutputGenerator
9999
virtual std::unique_ptr<OutputGenerator> clone() const;
100100

101101
static void init();
102+
void cleanup();
102103

103104
OutputType type() const { return Docbook; }
104105

src/doxygen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12144,6 +12144,8 @@ void generateOutput()
1214412144
g_s.end();
1214512145
}
1214612146

12147+
g_outputList->cleanup();
12148+
1214712149
int cacheParam;
1214812150
msg("lookup cache used %zu/%zu hits=%" PRIu64 " misses=%" PRIu64 "\n",
1214912151
Doxygen::lookupCache->size(),

src/htmlgen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ void HtmlGenerator::init()
971971
{
972972
mgr.copyResource("svgpan.js",dname);
973973
}
974+
974975
if (!Config_getBool(DISABLE_INDEX) && Config_getBool(HTML_DYNAMIC_MENUS))
975976
{
976977
mgr.copyResource("menu.js",dname);
@@ -990,6 +991,13 @@ void HtmlGenerator::init()
990991
}
991992
}
992993

994+
void HtmlGenerator::cleanup()
995+
{
996+
QCString dname = Config_getString(HTML_OUTPUT);
997+
Dir d(dname.str());
998+
clearSubDirs(d);
999+
}
1000+
9931001
/// Additional initialization after indices have been created
9941002
void HtmlGenerator::writeTabData()
9951003
{

src/htmlgen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class HtmlGenerator : public OutputGenerator
7373

7474
virtual OutputType type() const { return Html; }
7575
static void init();
76+
void cleanup();
7677
static void writeStyleSheetFile(TextStream &t);
7778
static void writeHeaderFile(TextStream &t, const QCString &cssname);
7879
static void writeFooterFile(TextStream &t);

src/latexgen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ void LatexGenerator::init()
494494
createSubDirs(d);
495495
}
496496

497+
void LatexGenerator::cleanup()
498+
{
499+
QCString dname = Config_getString(LATEX_OUTPUT);
500+
Dir d(dname.str());
501+
clearSubDirs(d);
502+
}
503+
497504
static void writeDefaultStyleSheet(TextStream &t)
498505
{
499506
t << ResourceMgr::instance().getAsString("doxygen.sty");

src/latexgen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class LatexGenerator : public OutputGenerator
8686
virtual std::unique_ptr<OutputGenerator> clone() const;
8787

8888
static void init();
89+
void cleanup();
8990
static void writeStyleSheetFile(TextStream &t);
9091
static void writeHeaderFile(TextStream &t);
9192
static void writeFooterFile(TextStream &t);

src/mangen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ void ManGenerator::init()
115115
createSubDirs(d);
116116
}
117117

118+
void ManGenerator::cleanup()
119+
{
120+
QCString dname = Config_getString(MAN_OUTPUT);
121+
Dir d(dname.str());
122+
clearSubDirs(d);
123+
}
124+
118125
static QCString buildFileName(const QCString &name)
119126
{
120127
QCString fileName;

src/mangen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ManGenerator : public OutputGenerator
3535
void writeDoc(DocNode *,const Definition *,const MemberDef *,int);
3636

3737
static void init();
38+
void cleanup();
3839
void startFile(const QCString &name,const QCString &manName,const QCString &title,int);
3940
void writeSearchInfo() {}
4041
void writeFooter(const QCString &) {}

src/outputgen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ class OutputGenerator : public BaseOutputDocInterface
497497
virtual void writeLabel(const QCString &,bool) = 0;
498498
virtual void endLabels() = 0;
499499

500+
virtual void cleanup() = 0;
501+
500502
protected:
501503
TextStream m_t;
502504
private:

src/outputlist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ class OutputList : public OutputDocInterface
475475
void endLabels()
476476
{ forall(&OutputGenerator::endLabels); }
477477

478+
void cleanup()
479+
{ forall(&OutputGenerator::cleanup); }
480+
478481
void startFontClass(const QCString &c)
479482
{ forall(&OutputGenerator::startFontClass,c); }
480483
void endFontClass()

src/rtfgen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ void RTFGenerator::init()
207207
createSubDirs(d);
208208
}
209209

210+
void RTFGenerator::cleanup()
211+
{
212+
QCString dname = Config_getString(RTF_OUTPUT);
213+
Dir d(dname.str());
214+
clearSubDirs(d);
215+
}
216+
210217
static QCString makeIndexName(const QCString &s,int i)
211218
{
212219
QCString result=s;

src/rtfgen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class RTFGenerator : public OutputGenerator
3232
virtual std::unique_ptr<OutputGenerator> clone() const;
3333

3434
static void init();
35+
void cleanup();
3536
static void writeStyleSheetFile(TextStream &t);
3637
static void writeExtensionsFile(TextStream &t);
3738
OutputType type() const { return RTF; }

src/util.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3702,6 +3702,32 @@ void createSubDirs(const Dir &d)
37023702
}
37033703
}
37043704

3705+
void clearSubDirs(const Dir &d)
3706+
{
3707+
if (Config_getBool(CREATE_SUBDIRS))
3708+
{
3709+
// remove empty subdirectories
3710+
for (int l1=0;l1<16;l1++)
3711+
{
3712+
QCString subdir;
3713+
subdir.sprintf("d%x",l1);
3714+
for (int l2=0;l2<256;l2++)
3715+
{
3716+
QCString subsubdir;
3717+
subsubdir.sprintf("d%x/d%02x",l1,l2);
3718+
if (d.exists(subsubdir.str()) && d.isEmpty(subsubdir.str()))
3719+
{
3720+
d.rmdir(subsubdir.str());
3721+
}
3722+
}
3723+
if (d.exists(subdir.str()) && d.isEmpty(subdir.str()))
3724+
{
3725+
d.rmdir(subdir.str());
3726+
}
3727+
}
3728+
}
3729+
}
3730+
37053731
/*! Input is a scopeName, output is the scopename split into a
37063732
* namespace part (as large as possible) and a classname part.
37073733
*/

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ void addDirPrefix(QCString &fileName);
321321
QCString relativePathToRoot(const QCString &name);
322322

323323
void createSubDirs(const Dir &d);
324+
void clearSubDirs(const Dir &d);
324325

325326
QCString stripPath(const QCString &s);
326327

src/xmlgen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,7 @@ void generateXML()
20212021
}
20222022

20232023
writeCombineScript();
2024+
clearSubDirs(xmlDir);
20242025
}
20252026

20262027

0 commit comments

Comments
 (0)