From 0d05e79d67b5b808918541f429b06805207e8bdb Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 11 Mar 2021 23:05:13 +0100 Subject: Refactoring: Replaced QDir with Dir - Dir is based on ghc::filesystem, a std::filesystem compatible implementation that does not require C++17. --- src/CMakeLists.txt | 1 + src/cite.cpp | 23 ++-- src/classdef.cpp | 86 ++++++------- src/code.l | 14 +-- src/configimpl.l | 13 +- src/context.cpp | 25 ++-- src/defgen.cpp | 45 +------ src/dia.cpp | 18 ++- src/dir.cpp | 292 +++++++++++++++++++++++++++++++++++++++++++ src/dir.h | 103 +++++++++++++++ src/dirdef.h | 1 - src/docbookgen.cpp | 6 +- src/dot.cpp | 15 ++- src/dotfilepatcher.cpp | 27 ++-- src/dotgfxhierarchytable.cpp | 3 +- src/dotgraph.cpp | 6 +- src/dotgraph.h | 4 +- src/dotrunner.cpp | 18 +-- src/doxygen.cpp | 209 ++++++++++++++----------------- src/doxygen.h | 2 +- src/fileinfo.cpp | 65 +++++++--- src/fileinfo.h | 2 +- src/formula.cpp | 50 ++++---- src/htags.cpp | 19 ++- src/htmlgen.cpp | 6 +- src/latexgen.cpp | 4 +- src/mangen.cpp | 10 +- src/memberdef.cpp | 207 +++++++++++++++--------------- src/memberdef.h | 3 +- src/msc.cpp | 11 +- src/perlmodgen.cpp | 50 ++------ src/portable.cpp | 8 +- src/rtfgen.cpp | 31 +++-- src/sqlite3gen.cpp | 5 +- src/template.cpp | 31 +++-- src/util.cpp | 17 ++- src/util.h | 5 +- src/vhdljjparser.cpp | 5 +- src/vhdljjparser.h | 2 +- src/xmlgen.cpp | 4 +- 40 files changed, 886 insertions(+), 560 deletions(-) create mode 100644 src/dir.cpp create mode 100644 src/dir.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f47e15..b99bef5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -232,6 +232,7 @@ add_library(doxymain STATIC definition.cpp dia.cpp diagram.cpp + dir.cpp dirdef.cpp docbookgen.cpp docbookvisitor.cpp diff --git a/src/cite.cpp b/src/cite.cpp index 914fbc6..13465a5 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -24,9 +24,9 @@ #include "util.h" #include "debug.h" #include "fileinfo.h" +#include "dir.h" #include -#include #include #include @@ -276,8 +276,8 @@ void CitationManager::generatePage() // Strictly not required when only latex is generated QCString bibOutputDir = outputDir+"/"+bibTmpDir; QCString bibOutputFiles = ""; - QDir thisDir; - if (!thisDir.exists(bibOutputDir) && !thisDir.mkdir(bibOutputDir)) + Dir thisDir; + if (!thisDir.exists(bibOutputDir.str()) && !thisDir.mkdir(bibOutputDir.str())) { err("Failed to create temporary output directory '%s', skipping citations\n",bibOutputDir.data()); return; @@ -299,8 +299,8 @@ void CitationManager::generatePage() } } - QString oldDir = QDir::currentDirPath(); - QDir::setCurrent(outputDir); + std::string oldDir = Dir::currentDirPath(); + Dir::setCurrent(outputDir.str()); // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc @@ -314,7 +314,7 @@ void CitationManager::generatePage() } Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); // 6. read back the file QCString doc; @@ -405,17 +405,18 @@ void CitationManager::generatePage() // 9. Remove temporary files if (!citeDebug) { - thisDir.remove(citeListFile); - thisDir.remove(doxygenBstFile); - thisDir.remove(bib2xhtmlFile); + thisDir.remove(citeListFile.str()); + thisDir.remove(doxygenBstFile.str()); + thisDir.remove(bib2xhtmlFile.str()); // we might try to remove too many files as empty files didn't get a corresponding new file // but the remove function does not emit an error for it and we don't catch the error return // so no problem. for (size_t j = 1; j <= citeDataList.size(); j++) { - thisDir.remove(bibOutputDir + bibTmpFile + QCString().setNum(static_cast(j)) + ".bib"); + QCString bibFile = bibOutputDir + bibTmpFile + QCString().setNum(static_cast(j)) + ".bib"; + thisDir.remove(bibFile.str()); } - thisDir.rmdir(bibOutputDir); + thisDir.rmdir(bibOutputDir.str()); } } diff --git a/src/classdef.cpp b/src/classdef.cpp index 668e96f..c01d51f 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -2431,23 +2431,22 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const char *h void ClassDefImpl::addClassAttributes(OutputList &ol) const { - QStrList sl; - if (isFinal()) sl.append("final"); - if (isSealed()) sl.append("sealed"); - if (isAbstract()) sl.append("abstract"); - if (getLanguage()==SrcLangExt_IDL && isPublished()) sl.append("published"); + StringVector sl; + if (isFinal()) sl.push_back("final"); + if (isSealed()) sl.push_back("sealed"); + if (isAbstract()) sl.push_back("abstract"); + if (getLanguage()==SrcLangExt_IDL && isPublished()) sl.push_back("published"); ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); - if (sl.count()>0) + if (!sl.empty()) { ol.startLabels(); - const char *s=sl.first(); - while (s) + size_t i=0; + for (const auto &s : sl) { - const char *ns = sl.next(); - ol.writeLabel(s,ns==0); - s=ns; + i++; + ol.writeLabel(s.c_str(),i==sl.size()); } ol.endLabels(); } @@ -3001,47 +3000,50 @@ void ClassDefImpl::writeMemberList(OutputList &ol) const && memberWritten) { ol.writeString(""); - QStrList sl; + StringVector sl; if (lang==SrcLangExt_VHDL) { - sl.append(theTranslator->trVhdlType(md->getMemberSpecifiers(),TRUE)); //append vhdl type + sl.push_back(theTranslator->trVhdlType(md->getMemberSpecifiers(),TRUE).str()); //append vhdl type } - else if (md->isFriend()) sl.append("friend"); - else if (md->isRelated()) sl.append("related"); + else if (md->isFriend()) sl.push_back("friend"); + else if (md->isRelated()) sl.push_back("related"); else { if (Config_getBool(INLINE_INFO) && md->isInline()) - sl.append("inline"); - if (md->isExplicit()) sl.append("explicit"); - if (md->isMutable()) sl.append("mutable"); - if (prot==Protected) sl.append("protected"); - else if (prot==Private) sl.append("private"); - else if (prot==Package) sl.append("package"); + sl.push_back("inline"); + if (md->isExplicit()) sl.push_back("explicit"); + if (md->isMutable()) sl.push_back("mutable"); + if (prot==Protected) sl.push_back("protected"); + else if (prot==Private) sl.push_back("private"); + else if (prot==Package) sl.push_back("package"); if (virt==Virtual && getLanguage()!=SrcLangExt_ObjC) - sl.append("virtual"); - else if (virt==Pure) sl.append("pure virtual"); - if (md->isStatic()) sl.append("static"); - if (md->isSignal()) sl.append("signal"); - if (md->isSlot()) sl.append("slot"); + sl.push_back("virtual"); + else if (virt==Pure) sl.push_back("pure virtual"); + if (md->isStatic()) sl.push_back("static"); + if (md->isSignal()) sl.push_back("signal"); + if (md->isSlot()) sl.push_back("slot"); // this is the extra member page - if (md->isOptional()) sl.append("optional"); - if (md->isAttribute()) sl.append("attribute"); - if (md->isUNOProperty()) sl.append("property"); - if (md->isReadonly()) sl.append("readonly"); - if (md->isBound()) sl.append("bound"); - if (md->isRemovable()) sl.append("removable"); - if (md->isConstrained()) sl.append("constrained"); - if (md->isTransient()) sl.append("transient"); - if (md->isMaybeVoid()) sl.append("maybevoid"); - if (md->isMaybeDefault()) sl.append("maybedefault"); - if (md->isMaybeAmbiguous())sl.append("maybeambiguous"); + if (md->isOptional()) sl.push_back("optional"); + if (md->isAttribute()) sl.push_back("attribute"); + if (md->isUNOProperty()) sl.push_back("property"); + if (md->isReadonly()) sl.push_back("readonly"); + if (md->isBound()) sl.push_back("bound"); + if (md->isRemovable()) sl.push_back("removable"); + if (md->isConstrained()) sl.push_back("constrained"); + if (md->isTransient()) sl.push_back("transient"); + if (md->isMaybeVoid()) sl.push_back("maybevoid"); + if (md->isMaybeDefault()) sl.push_back("maybedefault"); + if (md->isMaybeAmbiguous())sl.push_back("maybeambiguous"); } - const char *s=sl.first(); - while (s) + bool firstSpan=true; + for (const auto &s : sl) { - ol.docify(s); - s=sl.next(); - if (s) ol.writeString(""); + if (!firstSpan) + { + ol.writeString(""); + firstSpan=false; + } + ol.docify(s.c_str()); } ol.writeString(""); } diff --git a/src/code.l b/src/code.l index be1f179..90c1ff3 100644 --- a/src/code.l +++ b/src/code.l @@ -38,7 +38,6 @@ #include #include #include -#include #include "code.h" #include "entry.h" @@ -58,6 +57,7 @@ #include "tooltip.h" #include "scopedtypevariant.h" #include "symbolresolver.h" +#include "dir.h" // Toggle for some debugging info //#define DBG_CTX(x) fprintf x @@ -92,7 +92,7 @@ struct codeYY_state std::unordered_map< std::string, ScopedTypeVariant > codeClassMap; QCString curClassName; - QStrList curClassBases; + StringVector curClassBases; QCString parmType; QCString parmName; @@ -497,7 +497,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale if (ambig) // multiple input files match the name { DBG_CTX((stderr,"===== yes %s is ambiguous\n",yytext)); - QCString name = QDir::cleanDirPath(yytext).utf8(); + QCString name = Dir::cleanDirPath(yytext); if (!name.isEmpty() && yyextra->sourceFileDef) { const FileName *fn = Doxygen::inputNameLinkedMap->find(name); @@ -783,8 +783,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale DBG_CTX((stderr,"Adding new class %s\n",yyextra->curClassName.data())); ScopedTypeVariant var(yyextra->curClassName); // insert base classes. - char *s=yyextra->curClassBases.first(); - while (s) + for (const auto &s : yyextra->curClassBases) { const ClassDef *bcd=0; auto it = yyextra->codeClassMap.find(s); @@ -792,12 +791,11 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale { bcd = toClassDef(it->second.globalDef()); } - if (bcd==0) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s); + if (bcd==0) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s.c_str()); if (bcd && bcd->name()!=yyextra->curClassName) { var.localDef()->insertBaseClass(bcd->name()); } - s=yyextra->curClassBases.next(); } yyextra->codeClassMap.emplace(std::make_pair(yyextra->curClassName.str(),std::move(var))); } @@ -819,7 +817,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale } {SEP}?({ID}{SEP})*{ID} { DBG_CTX((stderr,"%s:addBase(%s)\n",yyextra->curClassName.data(),yytext)); - yyextra->curClassBases.inSort(yytext); + yyextra->curClassBases.push_back(yytext); generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext); } "<" { diff --git a/src/configimpl.l b/src/configimpl.l index d237714..2f1aefc 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -27,11 +27,11 @@ #include #include -#include - #include #include +#include + #include "regex.h" #include "configimpl.h" #include "version.h" @@ -41,6 +41,7 @@ #include "lang_cfg.h" #include "configoptions.h" #include "fileinfo.h" +#include "dir.h" #define YY_NO_INPUT 1 #define YY_NO_UNISTD_H 1 @@ -1529,10 +1530,8 @@ void Config::checkAndCorrect() StringVector stripFromPath = Config_getList(STRIP_FROM_PATH); if (stripFromPath.empty()) // by default use the current path { - QString p = QDir::currentDirPath(); - if (p.at(p.length()-1)!='/') - p.append('/'); - stripFromPath.push_back(p.utf8().str()); + std::string p = Dir::currentDirPath()+"/"; + stripFromPath.push_back(p); } else { @@ -1871,7 +1870,7 @@ void Config::checkAndCorrect() if (inputSources.empty()) { // use current dir as the default - inputSources.push_back(QDir::currentDirPath().utf8().str()); + inputSources.push_back(Dir::currentDirPath()); } else { diff --git a/src/context.cpp b/src/context.cpp index f4614dd..dc7c31f 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -14,7 +14,6 @@ */ #include -#include #include "context.h" #include "config.h" @@ -54,6 +53,7 @@ #include "groupdef.h" #include "searchindex.h" #include "resourcemgr.h" +#include "dir.h" // TODO: pass the current file to Dot*::writeGraph, so the user can put dot graphs in other // files as well @@ -4687,16 +4687,11 @@ class MemberContext::Private : public DefinitionContext Cachable &cache = getCache(); if (!cache.labels) { - QStrList sl; - m_memberDef->getLabels(sl,m_memberDef->getOuterScope()); + StringVector sl = m_memberDef->getLabels(m_memberDef->getOuterScope()); TemplateList *tl = TemplateList::alloc(); - if (sl.count()>0) + for (const auto &s : sl) { - QStrListIterator it(sl); - for (;it.current();++it) - { - tl->append(*it); - } + tl->append(s.c_str()); } cache.labels.reset(tl); } @@ -10118,7 +10113,7 @@ void generateOutputViaTemplate() g_globals.outputFormat = ContextOutputFormat_Html; g_globals.dynSectionId = 0; g_globals.outputDir = Config_getString(HTML_OUTPUT); - QDir dir(g_globals.outputDir); + Dir dir(g_globals.outputDir.str()); createSubDirs(dir); HtmlEscaper htmlEsc; ctx->setEscapeIntf(Config_getString(HTML_FILE_EXTENSION),&htmlEsc); @@ -10143,7 +10138,7 @@ void generateOutputViaTemplate() g_globals.outputFormat = ContextOutputFormat_Latex; g_globals.dynSectionId = 0; g_globals.outputDir = Config_getString(LATEX_OUTPUT); - QDir dir(g_globals.outputDir); + Dir dir(g_globals.outputDir.str()); createSubDirs(dir); LatexEscaper latexEsc; ctx->setEscapeIntf(".tex",&latexEsc); @@ -10173,17 +10168,17 @@ void generateOutputViaTemplate() void generateTemplateFiles(const char *templateDir) { if (!templateDir) return; - QDir thisDir; + Dir thisDir; if (!thisDir.exists(templateDir) && !thisDir.mkdir(templateDir)) { err("Failed to create output directory '%s'\n",templateDir); return; } - QCString outDir = QCString(templateDir)+"/html"; + std::string outDir = std::string(templateDir)+"/html"; if (!thisDir.exists(outDir) && !thisDir.mkdir(outDir)) { - err("Failed to create output directory '%s'\n",outDir.data()); + err("Failed to create output directory '%s'\n",outDir.c_str()); return; } - ResourceMgr::instance().writeCategory("html",outDir); + ResourceMgr::instance().writeCategory("html",outDir.c_str()); } diff --git a/src/defgen.cpp b/src/defgen.cpp index 1cb09f5..4ad2d41 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -33,8 +33,8 @@ #include "namespacedef.h" #include "filedef.h" #include "filename.h" +#include "dir.h" -#include #include #define DEF_DB(x) @@ -522,50 +522,15 @@ static void generateDEFForFile(const FileDef *fd,FTextStream &t) void generateDEF() { - QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY); - if (outputDirectory.isEmpty()) - { - outputDirectory=QDir::currentDirPath().utf8(); - } - else - { - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - term("tag OUTPUT_DIRECTORY: Output directory '%s' does not " - "exist and cannot be created\n",outputDirectory.data()); - } - else - { - msg("Notice: Output directory '%s' does not exist. " - "I have created it for you.\n", outputDirectory.data()); - } - dir.cd(outputDirectory); - } - outputDirectory=dir.absPath().utf8(); - } - - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - err("Cannot create directory %s\n",outputDirectory.data()); - return; - } - } - QDir defDir(outputDirectory+"/def"); - if (!defDir.exists() && !defDir.mkdir(outputDirectory+"/def")) + QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY)+"/def"; + Dir defDir(outputDirectory.str()); + if (!defDir.exists() && !defDir.mkdir(outputDirectory.str())) { err("Could not create def directory in %s\n",outputDirectory.data()); return; } - QCString fileName=outputDirectory+"/def/doxygen.def"; + QCString fileName=outputDirectory+"/doxygen.def"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { diff --git a/src/dia.cpp b/src/dia.cpp index 4a00a17..11c5270 100644 --- a/src/dia.cpp +++ b/src/dia.cpp @@ -1,12 +1,10 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -20,8 +18,8 @@ #include "config.h" #include "message.h" #include "util.h" +#include "dir.h" -#include static const int maxCmdLine = 40960; @@ -33,10 +31,10 @@ void writeDiaGraphFromFile(const char *inFile,const char *outDir, absOutFile+=outFile; // chdir to the output dir, so dot can find the font file. - QCString oldDir = QDir::currentDirPath().utf8(); + std::string oldDir = Dir::currentDirPath(); // go to the html output directory (i.e. path) - QDir::setCurrent(outDir); - //printf("Going to dir %s\n",QDir::currentDirPath().data()); + Dir::setCurrent(outDir); + //printf("Going to dir %s\n",Dir::currentDirPath().c_str()); QCString diaExe = Config_getString(DIA_PATH)+"dia"+Portable::commandExtension(); QCString diaArgs; QCString extension; @@ -85,6 +83,6 @@ void writeDiaGraphFromFile(const char *inFile,const char *outDir, } error: - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); } diff --git a/src/dir.cpp b/src/dir.cpp new file mode 100644 index 0000000..caef5c7 --- /dev/null +++ b/src/dir.cpp @@ -0,0 +1,292 @@ +/****************************************************************************** + * + * Copyright (C) 1997-2021 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#include "filesystem.hpp" +#include "dir.h" + +namespace fs = ghc::filesystem; + +//----------------------------------------------------------------------------------------------- + +struct DirEntry::Private +{ + fs::directory_entry entry; +}; + +DirEntry::DirEntry() : p(std::make_unique()) +{ +} + +DirEntry::~DirEntry() +{ +} + +bool DirEntry::is_directory() const +{ + return p->entry.is_directory(); +} + +bool DirEntry::is_regular_file() const +{ + return p->entry.is_regular_file(); +} + +bool DirEntry::is_symlink() const +{ + return p->entry.is_symlink(); +} + +std::string DirEntry::path() const +{ + return p->entry.path().string(); +} + +//----------------------------------------------------------------------------------------------- + +struct DirIterator::Private +{ + Private() : it() {} + Private(const std::string &path) : it(path) {} + fs::directory_iterator it; + mutable DirEntry current; +}; + +DirIterator::DirIterator() : p(std::make_unique()) +{ +} + +DirIterator::DirIterator(const std::string &path) : p(std::make_unique(path)) +{ +} + +DirIterator::DirIterator(const DirIterator &it) : p(std::make_unique()) +{ + p->it = it.p->it; +} + +DirIterator::~DirIterator() +{ +} + +DirIterator &DirIterator::operator=(const DirIterator &it) +{ + if (&it!=this) + { + p->it = it.p->it; + } + return *this; +} + +DirIterator DirIterator::operator++() +{ + DirIterator result; + result.p->it = ++p->it; + return result; +} + +const DirIterator::value_type &DirIterator::operator*() const +{ + p->current.p->entry = *p->it; + return p->current; +} + +const DirIterator::value_type *DirIterator::operator->() const +{ + p->current.p->entry = *p->it; + return &p->current; +} + +bool operator==(const DirIterator &it1,const DirIterator &it2) +{ + return it1.p->it!=it2.p->it; +} + +bool operator!=(const DirIterator &it1,const DirIterator &it2) +{ + return it1.p->it!=it2.p->it; +} + +DirIterator begin(DirIterator it) noexcept +{ + return it; +} + +DirIterator end(const DirIterator &) noexcept +{ + return DirIterator(); +} + + +//----------------------------------------------------------------------------------------------- + + +struct Dir::Private +{ + fs::path path; +}; + +Dir::Dir() : p(std::make_unique()) +{ + std::error_code ec; + p->path = fs::current_path(ec); +} + +Dir::Dir(const Dir &d) : p(std::make_unique()) +{ + p->path = d.p->path; +} + +Dir &Dir::operator=(const Dir &d) +{ + if (&d!=this) + { + p->path = d.p->path; + } + return *this; +} + +Dir::Dir(const std::string &path) : p(std::make_unique()) +{ + setPath(path); +} + +Dir::~Dir() +{ +} + +void Dir::setPath(const std::string &path) +{ + p->path = path; +} + +std::string Dir::path() const +{ + return p->path.string(); +} + +DirIterator Dir::iterator() const +{ + return DirIterator(p->path.string()); +} + +static void correctPath(std::string &s) +{ + std::replace( s.begin(), s.end(), '\\', '/' ); +} + +bool Dir::exists(const std::string &path,bool acceptsAbsPath) const +{ + std::string result = filePath(path,acceptsAbsPath); + std::error_code ec; + bool exist = fs::exists(fs::path(result),ec); + return !ec && exist; +} + +bool Dir::exists() const +{ + return exists(p->path.string()); +} + +bool Dir::isRelative() const +{ + return isRelativePath(p->path.string()); +} + +bool Dir::isRelativePath(const std::string &path) +{ + return fs::path(path).is_relative(); +} + +std::string Dir::filePath(const std::string &path,bool acceptsAbsPath) const +{ + std::string result; + if (acceptsAbsPath && !isRelativePath(path)) + { + result = path; + } + else + { + result = (p->path / path).string(); + } + correctPath(result); + return result; +} + +bool Dir::mkdir(const std::string &path,bool acceptsAbsPath) const +{ + std::error_code ec; + std::string result = filePath(path,acceptsAbsPath); + if (exists(path,acceptsAbsPath)) + { + return true; + } + else + { + return fs::create_directory(result,ec); + } +} + +bool Dir::rmdir(const std::string &path,bool acceptsAbsPath) const +{ + return remove(path,acceptsAbsPath); +} + +bool Dir::remove(const std::string &path,bool acceptsAbsPath) const +{ + std::error_code ec; + std::string result = filePath(path,acceptsAbsPath); + return fs::remove(result,ec); +} + +bool Dir::rename(const std::string &orgName,const std::string &newName,bool acceptsAbsPath) const +{ + std::error_code ec; + std::string fn1 = filePath(orgName,acceptsAbsPath); + std::string fn2 = filePath(newName,acceptsAbsPath); + fs::rename(fn1,fn2,ec); + return !ec; +} + +std::string Dir::currentDirPath() +{ + std::error_code ec; + std::string result = fs::current_path(ec).string(); + correctPath(result); + return result; +} + +bool Dir::setCurrent(const std::string &path) +{ + std::error_code ec; + fs::current_path(path,ec); + return !ec; +} + +std::string Dir::cleanDirPath(const std::string &path) +{ + std::error_code ec; + std::string result = fs::path(path).lexically_normal().string(); + correctPath(result); + return result; +} + +std::string Dir::absPath() const +{ + std::error_code ec; + std::string result = fs::absolute(p->path,ec).string(); + correctPath(result); + return result; +} + diff --git a/src/dir.h b/src/dir.h new file mode 100644 index 0000000..c02c60d --- /dev/null +++ b/src/dir.h @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Copyright (C) 1997-2021 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef DIR_H +#define DIR_H + +#include +#include + +#include "fileinfo.h" + +class DirEntry +{ + public: + ~DirEntry(); + bool is_directory() const; + bool is_regular_file() const; + bool is_symlink() const; + std::string path() const; + private: + friend class DirIterator; + DirEntry(); + struct Private; + std::unique_ptr p; +}; + +class DirIterator +{ + public: + using value_type = DirEntry; + using difference_type = std::ptrdiff_t; + using pointer = value_type*; + using reference = value_type&; + using iterator_category = std::input_iterator_tag; + DirIterator(const DirIterator &it); + DirIterator &operator=(const DirIterator &it); + DirIterator operator++(); + const value_type &operator*() const; + const value_type *operator->() const; + + friend bool operator==(const DirIterator &it1,const DirIterator &it2); + friend bool operator!=(const DirIterator &it1,const DirIterator &it2); + friend DirIterator begin(DirIterator it) noexcept; + friend DirIterator end(const DirIterator &) noexcept; + ~DirIterator(); + + private: + friend class Dir; + DirIterator(); + DirIterator(const std::string &path); + struct Private; + std::unique_ptr p; +}; + +/** Class representing a directory in the file system */ +class Dir final +{ + public: + Dir(); + Dir(const std::string &path); + Dir(const Dir &d); + Dir &operator=(const Dir &d); + ~Dir(); + void setPath(const std::string &path); + std::string path() const; + + DirIterator iterator() const; + + bool exists() const; + std::string filePath(const std::string &path,bool acceptsAbsPath=true) const; + bool exists(const std::string &path,bool acceptsAbsPath=true) const; + bool mkdir(const std::string &path,bool acceptsAbsPath=true) const; + bool rmdir(const std::string &path,bool acceptsAbsPath=true) const; + bool remove(const std::string &path,bool acceptsAbsPath=true) const; + bool rename(const std::string &orgName,const std::string &newName, + bool acceptsAbsPath=true) const; + std::string absPath() const; + + bool isRelative() const; + + static bool isRelativePath(const std::string &path); + static std::string currentDirPath(); + static bool setCurrent(const std::string &path); + static std::string cleanDirPath(const std::string &path); + + private: + struct Private; + std::unique_ptr p; +}; + +#endif diff --git a/src/dirdef.h b/src/dirdef.h index 0e3db91..5bc49e7 100644 --- a/src/dirdef.h +++ b/src/dirdef.h @@ -24,7 +24,6 @@ #include class FileList; -class QStrList; class FileDef; class OutputList; class UsedDir; diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 4319dda..1f10029 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -17,7 +17,6 @@ #include -#include #include #include "docbookgen.h" #include "doxygen.h" @@ -51,6 +50,7 @@ #include "membergroup.h" #include "dirdef.h" #include "section.h" +#include "dir.h" // no debug info #define Docbook_DB(x) do {} while(0) @@ -296,8 +296,8 @@ DB_GEN_C void DocbookGenerator::init() { QCString dir=Config_getString(DOCBOOK_OUTPUT); - QDir d(dir); - if (!d.exists() && !d.mkdir(dir)) + Dir d(dir.str()); + if (!d.exists() && !d.mkdir(dir.str())) { term("Could not create output directory %s\n",dir.data()); } diff --git a/src/dot.cpp b/src/dot.cpp index ddabbc7..cc0f070 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -16,8 +16,6 @@ #include #include -#include - #include "config.h" #include "dot.h" #include "dotrunner.h" @@ -29,6 +27,7 @@ #include "doxygen.h" #include "language.h" #include "index.h" +#include "dir.h" #define MAP_CMD "cmapx" @@ -273,7 +272,7 @@ bool DotManager::run() const void writeDotGraphFromFile(const char *inFile,const char *outDir, const char *outFile,GraphOutputFormat format) { - QDir d(outDir); + Dir d(outDir); if (!d.exists()) { term("Output dir %s does not exist!\n",outDir); @@ -281,8 +280,8 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir, QCString imgExt = getDotImageExtension(); QCString imgName = (QCString)outFile+"."+imgExt; - QCString absImgName = d.absPath().utf8()+"/"+imgName; - QCString absOutFile = d.absPath().utf8()+"/"+outFile; + QCString absImgName = QCString(d.absPath())+"/"+imgName; + QCString absOutFile = QCString(d.absPath())+"/"+outFile; DotRunner dotRun(inFile); if (format==GOF_BITMAP) @@ -326,7 +325,7 @@ void writeDotImageMapFromFile(FTextStream &t, const QCString &context,int graphId) { - QDir d(outDir); + Dir d(outDir.str()); if (!d.exists()) { term("Output dir %s does not exist!\n",outDir.data()); @@ -335,7 +334,7 @@ void writeDotImageMapFromFile(FTextStream &t, QCString mapName = baseName+".map"; QCString imgExt = getDotImageExtension(); QCString imgName = baseName+"."+imgExt; - QCString absOutFile = d.absPath().utf8()+"/"+mapName; + QCString absOutFile = QCString(d.absPath())+"/"+mapName; DotRunner dotRun(inFile.data()); dotRun.addJob(MAP_CMD,absOutFile); @@ -368,5 +367,5 @@ void writeDotImageMapFromFile(FTextStream &t, t << "" << endl; } } - d.remove(absOutFile); + d.remove(absOutFile.str()); } diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp index aafca34..4960cf4 100644 --- a/src/dotfilepatcher.cpp +++ b/src/dotfilepatcher.cpp @@ -18,13 +18,13 @@ #include "qstring.h" #include "config.h" -#include "qdir.h" #include "message.h" #include "ftextstream.h" #include "docparser.h" #include "doxygen.h" #include "util.h" #include "dot.h" +#include "dir.h" static const char svgZoomHeader[] = "\n" @@ -312,25 +312,26 @@ bool DotFilePatcher::run() const //printf("DotFilePatcher::addSVGConversion: file=%s zoomable=%d\n", // m_patchFile.data(),map->zoomable); } - QCString tmpName = m_patchFile+".tmp"; - QCString patchFile = m_patchFile; - if (!QDir::current().rename(patchFile,tmpName)) + std::string tmpName = m_patchFile.str()+".tmp"; + std::string patchFile = m_patchFile.str(); + Dir thisDir; + if (!thisDir.rename(patchFile,tmpName)) { - err("Failed to rename file %s to %s!\n",m_patchFile.data(),tmpName.data()); + err("Failed to rename file %s to %s!\n",m_patchFile.data(),tmpName.c_str()); return FALSE; } - QFile fi(tmpName); - QFile fo(patchFile); + QFile fi(tmpName.c_str()); + QFile fo(patchFile.c_str()); if (!fi.open(IO_ReadOnly)) { - err("problem opening file %s for patching!\n",tmpName.data()); - QDir::current().rename(tmpName,patchFile); + err("problem opening file %s for patching!\n",tmpName.c_str()); + thisDir.rename(tmpName,patchFile); return FALSE; } if (!fo.open(IO_WriteOnly)) { err("problem opening file %s for patching!\n",m_patchFile.data()); - QDir::current().rename(tmpName,patchFile); + thisDir.rename(tmpName,patchFile); return FALSE; } FTextStream t(&fo); @@ -481,11 +482,11 @@ bool DotFilePatcher::run() const fo.close(); // keep original SVG file so we can refer to it, we do need to replace // dummy link by real ones - fi.setName(tmpName); + fi.setName(tmpName.c_str()); fo.setName(orgName); if (!fi.open(IO_ReadOnly)) { - err("problem opening file %s for reading!\n",tmpName.data()); + err("problem opening file %s for reading!\n",tmpName.c_str()); return FALSE; } if (!fo.open(IO_WriteOnly)) @@ -510,7 +511,7 @@ bool DotFilePatcher::run() const fo.close(); } // remove temporary file - QDir::current().remove(tmpName); + thisDir.remove(tmpName); return TRUE; } diff --git a/src/dotgfxhierarchytable.cpp b/src/dotgfxhierarchytable.cpp index 9f81e22..9a14cb4 100644 --- a/src/dotgfxhierarchytable.cpp +++ b/src/dotgfxhierarchytable.cpp @@ -20,6 +20,7 @@ #include "message.h" #include "doxygen.h" #include "classlist.h" +#include "dir.h" QCString DotGfxHierarchyTable::getBaseName() const { @@ -77,7 +78,7 @@ void DotGfxHierarchyTable::writeGraph(FTextStream &out, if (m_rootSubgraphs.empty()) return; - QDir d(path); + Dir d(path); // store the original directory if (!d.exists()) { diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp index baa523f..e044bec 100644 --- a/src/dotgraph.cpp +++ b/src/dotgraph.cpp @@ -115,13 +115,13 @@ QCString DotGraph::writeGraph( { m_graphFormat = gf; m_textFormat = ef; - m_dir = QDir(path); + m_dir = Dir(path); m_fileName = fileName; m_relPath = relPath; m_generateImageMap = generateImageMap; m_graphId = graphId; - m_absPath = QCString(m_dir.absPath().data()) + "/"; + m_absPath = m_dir.absPath() + "/"; m_baseName = getBaseName(); computeTheGraph(); @@ -139,7 +139,7 @@ bool DotGraph::prepareDotFile() { if (!m_dir.exists()) { - term("Output dir %s does not exist!\n", m_dir.path().data()); + term("Output dir %s does not exist!\n", m_dir.path().c_str()); } QCString sigStr(33); diff --git a/src/dotgraph.h b/src/dotgraph.h index b90d980..ea3891b 100644 --- a/src/dotgraph.h +++ b/src/dotgraph.h @@ -18,7 +18,7 @@ #include #include -#include +#include "dir.h" class FTextStream; class DotNode; @@ -77,7 +77,7 @@ class DotGraph // the following variables are used while writing the graph to a .dot file GraphOutputFormat m_graphFormat = GOF_BITMAP; EmbeddedOutputFormat m_textFormat = EOF_Html; - QDir m_dir; + Dir m_dir; QCString m_fileName; QCString m_relPath; bool m_generateImageMap = false; diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp index a1bbc52..727b44e 100644 --- a/src/dotrunner.cpp +++ b/src/dotrunner.cpp @@ -24,6 +24,7 @@ #include "message.h" #include "ftextstream.h" #include "config.h" +#include "dir.h" // the graphicx LaTeX has a limitation of maximum size of 16384 // To be on the save side we take it a little bit smaller i.e. 150 inch * 72 dpi @@ -66,25 +67,26 @@ static void checkPngResult(const char *imgName) static bool resetPDFSize(const int width,const int height, const char *base) { - QCString tmpName = QCString(base)+".tmp"; - QCString patchFile = QCString(base)+".dot"; - if (!QDir::current().rename(patchFile,tmpName)) + std::string tmpName = std::string(base)+".tmp"; + std::string patchFile = std::string(base)+".dot"; + Dir thisDir; + if (!thisDir.rename(patchFile,tmpName)) { err("Failed to rename file %s to %s!\n",patchFile.data(),tmpName.data()); return FALSE; } - QFile fi(tmpName); - QFile fo(patchFile); + QFile fi(tmpName.c_str()); + QFile fo(patchFile.c_str()); if (!fi.open(IO_ReadOnly)) { err("problem opening file %s for patching!\n",tmpName.data()); - QDir::current().rename(tmpName,patchFile); + thisDir.rename(tmpName,patchFile); return FALSE; } if (!fo.open(IO_WriteOnly)) { err("problem opening file %s for patching!\n",patchFile.data()); - QDir::current().rename(tmpName,patchFile); + thisDir.rename(tmpName,patchFile); fi.close(); return FALSE; } @@ -110,7 +112,7 @@ static bool resetPDFSize(const int width,const int height, const char *base) fi.close(); fo.close(); // remove temporary file - QDir::current().remove(tmpName); + thisDir.remove(tmpName); return TRUE; } diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 76406b5..89ca1aa 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -106,6 +106,7 @@ #include "symbolresolver.h" #include "regex.h" #include "fileinfo.h" +#include "dir.h" #if USE_SQLITE3 #include @@ -9598,7 +9599,7 @@ static QCString resolveSymlink(QCString path) bool isRelative = FileInfo(target.str()).isRelative(); if (isRelative) { - target = QDir::cleanDirPath(oldPrefix+"/"+target.data()).utf8(); + target = Dir::cleanDirPath(oldPrefix.str()+"/"+target.str()); } if (sepPos!=-1) { @@ -9608,7 +9609,7 @@ static QCString resolveSymlink(QCString path) } target+=result.mid(sepPos); } - result = QDir::cleanDirPath(target).data(); + result = Dir::cleanDirPath(target.str()); sepPos = 0; if (known.find(result.str())!=known.end()) return QCString(); // recursive symlink! known.insert(result.str()); @@ -9631,7 +9632,7 @@ static QCString resolveSymlink(QCString path) } } while (sepPos!=-1); - return QDir::cleanDirPath(result).data(); + return Dir::cleanDirPath(result.str()); } static std::mutex g_pathsVisitedMutex; @@ -9643,7 +9644,7 @@ static StringUnorderedSet g_pathsVisited(1009); // The directory is read iff the recursiveFlag is set. // The contents of all files is append to the input string -static int readDir(QFileInfo *fi, +static void readDir(FileInfo *fi, FileNameLinkedMap *fnMap, StringUnorderedSet *exclSet, const StringVector *patList, @@ -9656,84 +9657,72 @@ static int readDir(QFileInfo *fi, StringSet *paths ) { - QCString dirName = fi->absFilePath().utf8(); - if (paths && !dirName.isEmpty()) + std::string dirName = fi->absFilePath(); + if (paths && !dirName.empty()) { - paths->insert(dirName.data()); + paths->insert(dirName); } if (fi->isSymLink()) { - dirName = resolveSymlink(dirName.data()); - if (dirName.isEmpty()) return 0; // recursive symlink + dirName = resolveSymlink(dirName); + if (dirName.empty()) return; // recursive symlink std::lock_guard lock(g_pathsVisitedMutex); - if (g_pathsVisited.find(dirName.str())!=g_pathsVisited.end()) return 0; // already visited path - g_pathsVisited.insert(dirName.str()); + if (g_pathsVisited.find(dirName)!=g_pathsVisited.end()) return; // already visited path + g_pathsVisited.insert(dirName); } - QDir dir(dirName); - dir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); - int totalSize=0; + Dir dir(dirName); msg("Searching for files in directory %s\n", fi->absFilePath().data()); //printf("killSet=%p count=%d\n",killSet,killSet ? (int)killSet->count() : -1); - const QFileInfoList *list = dir.entryInfoList(); - if (list) + for (const auto &dirEntry : dir.iterator()) { - QFileInfoListIterator it( *list ); - QFileInfo *cfi; - - while ((cfi=it.current())) - { - if (exclSet==0 || exclSet->find(cfi->absFilePath().utf8().data())==exclSet->end()) - { // file should not be excluded - //printf("killSet->find(%s)\n",cfi->absFilePath().data()); - if (!cfi->exists() || !cfi->isReadable()) + FileInfo cfi(dirEntry.path()); + if (exclSet==0 || exclSet->find(cfi.absFilePath())==exclSet->end()) + { // file should not be excluded + //printf("killSet->find(%s)\n",cfi->absFilePath().data()); + if (!cfi.exists() || !cfi.isReadable()) + { + if (errorIfNotExist) { - if (errorIfNotExist) - { - warn_uncond("source '%s' is not a readable file or directory... skipping.\n",cfi->absFilePath().data()); - } + warn_uncond("source '%s' is not a readable file or directory... skipping.\n",cfi.absFilePath().c_str()); } - else if (cfi->isFile() && - (!Config_getBool(EXCLUDE_SYMLINKS) || !cfi->isSymLink()) && - (patList==0 || patternMatch(*cfi,*patList)) && - (exclPatList==0 || !patternMatch(*cfi,*exclPatList)) && - (killSet==0 || killSet->find(cfi->absFilePath().utf8().data())==killSet->end()) - ) + } + else if (cfi.isFile() && + (!Config_getBool(EXCLUDE_SYMLINKS) || !cfi.isSymLink()) && + (patList==0 || patternMatch(cfi,*patList)) && + (exclPatList==0 || !patternMatch(cfi,*exclPatList)) && + (killSet==0 || killSet->find(cfi.absFilePath())==killSet->end()) + ) + { + std::string name=cfi.fileName(); + if (fnMap) { - totalSize+=cfi->size()+cfi->absFilePath().length()+4; - QCString name=cfi->fileName().utf8(); - //printf("New file %s\n",name.data()); - if (fnMap) + std::unique_ptr fd { createFileDef(cfi.dirPath()+"/",name) }; + FileName *fn=0; + if (!name.empty()) { - std::unique_ptr fd { createFileDef(cfi->dirPath().utf8().str()+"/",name.str()) }; - FileName *fn=0; - if (!name.isEmpty()) - { - fn = fnMap->add(name,cfi->absFilePath().utf8()); - fn->push_back(std::move(fd)); - } + fn = fnMap->add(name.c_str(),cfi.absFilePath().c_str()); + fn->push_back(std::move(fd)); } - if (resultList) resultList->push_back(cfi->absFilePath().utf8().data()); - if (resultSet) resultSet->insert(cfi->absFilePath().utf8().data()); - if (killSet) killSet->insert(cfi->absFilePath().utf8().data()); - } - else if (recursive && - (!Config_getBool(EXCLUDE_SYMLINKS) || !cfi->isSymLink()) && - cfi->isDir() && - (exclPatList==0 || !patternMatch(*cfi,*exclPatList)) && - cfi->fileName().at(0)!='.') // skip "." ".." and ".dir" - { - cfi->setFile(cfi->absFilePath()); - totalSize+=readDir(cfi,fnMap,exclSet, - patList,exclPatList,resultList,resultSet,errorIfNotExist, - recursive,killSet,paths); } + if (resultList) resultList->push_back(cfi.absFilePath()); + if (resultSet) resultSet->insert(cfi.absFilePath()); + if (killSet) killSet->insert(cfi.absFilePath()); + } + else if (recursive && + (!Config_getBool(EXCLUDE_SYMLINKS) || !cfi.isSymLink()) && + cfi.isDir() && + (exclPatList==0 || !patternMatch(cfi,*exclPatList)) && + cfi.fileName().at(0)!='.') // skip "." ".." and ".dir" + { + FileInfo acfi(cfi.absFilePath()); + readDir(&acfi,fnMap,exclSet, + patList,exclPatList,resultList,resultSet,errorIfNotExist, + recursive,killSet,paths); } - ++it; } } - return totalSize; } @@ -9741,7 +9730,7 @@ static int readDir(QFileInfo *fi, // read a file or all files in a directory and append their contents to the // input string. The names of the files are appended to the 'fiList' list. -int readFileOrDirectory(const char *s, +void readFileOrDirectory(const char *s, FileNameLinkedMap *fnMap, StringUnorderedSet *exclSet, const StringVector *patList, @@ -9756,16 +9745,12 @@ int readFileOrDirectory(const char *s, { //printf("killSet count=%d\n",killSet ? (int)killSet->size() : -1); // strip trailing slashes - if (s==0) return 0; - QCString fs = s; - char lc = fs.at(fs.length()-1); - if (lc=='/' || lc=='\\') fs = fs.left(fs.length()-1); + if (s==0) return; - QFileInfo fi(fs); + FileInfo fi(s); //printf("readFileOrDirectory(%s)\n",s); - int totalSize=0; { - if (exclSet==0 || exclSet->find(fi.absFilePath().utf8().data())==exclSet->end()) + if (exclSet==0 || exclSet->find(fi.absFilePath())==exclSet->end()) { if (!fi.exists() || !fi.isReadable()) { @@ -9778,47 +9763,43 @@ int readFileOrDirectory(const char *s, { if (fi.isFile()) { - QCString dirPath = fi.dirPath(TRUE).utf8(); - QCString filePath = fi.absFilePath().utf8(); - if (paths && !dirPath.isEmpty()) + std::string dirPath = fi.dirPath(true); + std::string filePath = fi.absFilePath(); + if (paths && !dirPath.empty()) { - paths->insert(dirPath.data()); + paths->insert(dirPath); } //printf("killSet.find(%s)=%d\n",fi.absFilePath().data(),killSet.find(fi.absFilePath())!=killSet.end()); - if (killSet==0 || killSet->find(filePath.data())==killSet->end()) + if (killSet==0 || killSet->find(filePath)==killSet->end()) { - totalSize+=fi.size()+fi.absFilePath().length()+4; //readFile(&fi,fiList,input); - //fiList->inSort(new FileInfo(fi)); - QCString name=fi.fileName().utf8(); - //printf("New file %s\n",name.data()); + std::string name=fi.fileName(); if (fnMap) { - std::unique_ptr fd { createFileDef(dirPath.str()+"/",name.str()) }; - if (!name.isEmpty()) + std::unique_ptr fd { createFileDef(dirPath+"/",name) }; + if (!name.empty()) { - FileName *fn = fnMap->add(name,filePath); + FileName *fn = fnMap->add(name.c_str(),filePath.c_str()); fn->push_back(std::move(fd)); } } if (resultList || resultSet) { - if (resultList) resultList->push_back(filePath.data()); - if (resultSet) resultSet->insert(filePath.data()); + if (resultList) resultList->push_back(filePath); + if (resultSet) resultSet->insert(filePath); } - if (killSet) killSet->insert(fi.absFilePath().utf8().data()); + if (killSet) killSet->insert(fi.absFilePath()); } } else if (fi.isDir()) // readable dir { - totalSize+=readDir(&fi,fnMap,exclSet,patList, + readDir(&fi,fnMap,exclSet,patList, exclPatList,resultList,resultSet,errorIfNotExist, recursive,killSet,paths); } } } } - return totalSize; } //---------------------------------------------------------------------------- @@ -10669,11 +10650,11 @@ void adjustConfiguration() #ifdef HAS_SIGNALS static void stopDoxygen(int) { - QDir thisDir; + Dir thisDir; msg("Cleaning up...\n"); if (!Doxygen::filterDBFileName.isEmpty()) { - thisDir.remove(Doxygen::filterDBFileName); + thisDir.remove(Doxygen::filterDBFileName.str()); } killpg(0,SIGINT); exit(1); @@ -10767,11 +10748,11 @@ static void exitDoxygen() { if (!g_successfulRun) // premature exit { - QDir thisDir; + Dir thisDir; msg("Exiting...\n"); if (!Doxygen::filterDBFileName.isEmpty()) { - thisDir.remove(Doxygen::filterDBFileName); + thisDir.remove(Doxygen::filterDBFileName.str()); } } } @@ -10789,8 +10770,8 @@ static QCString createOutputDirectory(const QCString &baseDirName, { result.prepend(baseDirName+'/'); } - QDir formatDir(result); - if (!formatDir.exists() && !formatDir.mkdir(result)) + Dir formatDir(result.str()); + if (!formatDir.exists() && !formatDir.mkdir(result.str())) { err("Could not create output directory %s\n", result.data()); cleanUpDoxygen(); @@ -11014,15 +10995,15 @@ void parseInput() QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY); if (outputDirectory.isEmpty()) { - outputDirectory = Config_updateString(OUTPUT_DIRECTORY,QDir::currentDirPath().utf8()); + outputDirectory = Config_updateString(OUTPUT_DIRECTORY,Dir::currentDirPath().c_str()); } else { - QDir dir(outputDirectory); + Dir dir(outputDirectory.str()); if (!dir.exists()) { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) + dir.setPath(Dir::currentDirPath()); + if (!dir.mkdir(outputDirectory.str())) { err("tag OUTPUT_DIRECTORY: Output directory '%s' does not " "exist and cannot be created\n",outputDirectory.data()); @@ -11034,9 +11015,9 @@ void parseInput() msg("Notice: Output directory '%s' does not exist. " "I have created it for you.\n", outputDirectory.data()); } - dir.cd(outputDirectory); + dir.setPath(outputDirectory.str()); } - outputDirectory = Config_updateString(OUTPUT_DIRECTORY,dir.absPath().utf8()); + outputDirectory = Config_updateString(OUTPUT_DIRECTORY,dir.absPath().c_str()); } /************************************************************************** @@ -11453,8 +11434,6 @@ void parseInput() namespaceComp); g_s.end(); - QDir thisDir; - g_s.begin("Determining which enums are documented\n"); findDocumentedEnumValues(); g_s.end(); @@ -11674,11 +11653,11 @@ void generateOutput() if (generateHtml && searchEngine) { QCString searchDirName = Config_getString(HTML_OUTPUT)+"/search"; - QDir searchDir(searchDirName); - if (!searchDir.exists() && !searchDir.mkdir(searchDirName)) + Dir searchDir(searchDirName.str()); + if (!searchDir.exists() && !searchDir.mkdir(searchDirName.str())) { term("Could not create search results directory '%s' $PWD='%s'\n", - searchDirName.data(),QDir::currentDirPath().data()); + searchDirName.data(),Dir::currentDirPath().c_str()); } HtmlGenerator::writeSearchData(searchDirName); if (!serverBasedSearch) // client side search index @@ -11876,8 +11855,8 @@ void generateOutput() !Config_getString(HHC_LOCATION).isEmpty()) { g_s.begin("Running html help compiler...\n"); - QString oldDir = QDir::currentDirPath(); - QDir::setCurrent(Config_getString(HTML_OUTPUT)); + std::string oldDir = Dir::currentDirPath(); + Dir::setCurrent(Config_getString(HTML_OUTPUT).str()); Portable::setShortDir(); Portable::sysTimerStart(); if (Portable::system(Config_getString(HHC_LOCATION), "index.hhp", Debug::isFlagSet(Debug::ExtCmd))!=1) @@ -11885,7 +11864,7 @@ void generateOutput() err("failed to run html help compiler on index.hhp\n"); } Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); g_s.end(); } @@ -11896,19 +11875,19 @@ void generateOutput() !Config_getString(QHG_LOCATION).isEmpty()) { g_s.begin("Running qhelpgenerator...\n"); - QCString const qhpFileName = Qhp::getQhpFileName(); - QCString const qchFileName = getQchFileName(); + QCString qhpFileName = Qhp::getQhpFileName(); + QCString qchFileName = getQchFileName(); - QCString const args = QCString().sprintf("%s -o \"%s\"", qhpFileName.data(), qchFileName.data()); - QString const oldDir = QDir::currentDirPath(); - QDir::setCurrent(Config_getString(HTML_OUTPUT)); + QCString args = QCString().sprintf("%s -o \"%s\"", qhpFileName.data(), qchFileName.data()); + std::string oldDir = Dir::currentDirPath(); + Dir::setCurrent(Config_getString(HTML_OUTPUT).str()); Portable::sysTimerStart(); if (Portable::system(Config_getString(QHG_LOCATION), args.data(), FALSE)) { err("failed to run qhelpgenerator on index.qhp\n"); } Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); g_s.end(); } @@ -11945,8 +11924,8 @@ void generateOutput() cleanUpDoxygen(); finalizeSearchIndexer(); - QDir thisDir; - thisDir.remove(Doxygen::filterDBFileName); + Dir thisDir; + thisDir.remove(Doxygen::filterDBFileName.str()); finishWarnExit(); Config::deinit(); delete Doxygen::clangUsrMap; diff --git a/src/doxygen.h b/src/doxygen.h index 227efcc..137fb8c 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -130,7 +130,7 @@ void generateOutput(); void readAliases(); void readFormulaRepository(QCString dir, bool cmp = FALSE); void cleanUpDoxygen(); -int readFileOrDirectory(const char *s, +void readFileOrDirectory(const char *s, FileNameLinkedMap *fnDict, StringUnorderedSet *exclSet, const StringVector *patList, diff --git a/src/fileinfo.cpp b/src/fileinfo.cpp index 09da147..8d0a332 100644 --- a/src/fileinfo.cpp +++ b/src/fileinfo.cpp @@ -20,27 +20,37 @@ namespace fs = ghc::filesystem; size_t FileInfo::size() const { - return static_cast(fs::file_size(fs::path(m_name))); + std::error_code ec; + size_t result = static_cast(fs::file_size(fs::path(m_name),ec)); + return ec ? 0 : result; } bool FileInfo::exists() const { - return fs::exists(fs::status(m_name)); + std::error_code ec; + bool result = fs::exists(fs::path(m_name),ec); + return !ec && result; } bool FileInfo::isWritable() const { - return (fs::status(m_name).permissions() & fs::perms::owner_write)!=fs::perms::none; + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && (status.permissions() & fs::perms::owner_write)!=fs::perms::none; } bool FileInfo::isReadable() const { - return (fs::status(m_name).permissions() & fs::perms::owner_read)!=fs::perms::none; + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && (status.permissions() & fs::perms::owner_read)!=fs::perms::none; } bool FileInfo::isExecutable() const { - return (fs::status(m_name).permissions() & fs::perms::owner_exec)!=fs::perms::none; + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && (status.permissions() & fs::perms::owner_exec)!=fs::perms::none; } bool FileInfo::isRelative() const @@ -50,22 +60,30 @@ bool FileInfo::isRelative() const bool FileInfo::isFile() const { - return fs::is_regular_file(fs::status(m_name)); + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && fs::is_regular_file(status); } bool FileInfo::isDir() const { - return fs::is_directory(fs::status(m_name)); + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && fs::is_directory(status); } bool FileInfo::isSymLink() const { - return fs::is_symlink(fs::status(m_name)); + std::error_code ec; + fs::file_status status = fs::status(m_name,ec); + return !ec && fs::is_symlink(status); } std::string FileInfo::readLink() const { - return fs::read_symlink(fs::path(m_name)).string(); + std::error_code ec; + fs::path targetPath = fs::read_symlink(fs::path(m_name)); + return !ec ? targetPath.string() : std::string(); } std::string FileInfo::filePath() const @@ -81,13 +99,15 @@ void FileInfo::correctPath(std::string &s) std::string FileInfo::absFilePath() const { std::string result; - if (fs::exists(fs::status(m_name))) + std::error_code ec; + fs::path path(m_name); + if (fs::exists(path,ec)) { - result = fs::canonical(m_name).string(); + result = fs::canonical(path,ec).string(); } else { - result = (fs::current_path() / m_name).string(); + result = (fs::current_path(ec) / m_name).string(); } correctPath(result); return result; @@ -117,14 +137,25 @@ std::string FileInfo::dirPath(bool absPath) const std::string result; if (absPath) { - result = fs::canonical(m_name).parent_path().string(); + result = absFilePath(); } else { - result = fs::relative(m_name).parent_path().string(); - if (result.empty()) result="."; + result = m_name; + correctPath(result); + } + size_t pos = result.rfind('/'); + if (pos==std::string::npos) + { + return "."; + } + else if (pos==0) + { + return "/"; + } + else + { + return result.substr(0,pos); } - correctPath(result); - return result; } diff --git a/src/fileinfo.h b/src/fileinfo.h index a65378c..3ab684f 100644 --- a/src/fileinfo.h +++ b/src/fileinfo.h @@ -38,7 +38,7 @@ class FileInfo std::string fileName() const; std::string baseName() const; std::string extension(bool complete) const; - std::string dirPath(bool absPath = false) const; + std::string dirPath(bool absPath = true) const; private: static void correctPath(std::string &s); std::string m_name; diff --git a/src/formula.cpp b/src/formula.cpp index fbed2f7..82bcc3f 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -21,9 +21,9 @@ #include "portable.h" #include "image.h" #include "fileinfo.h" +#include "dir.h" #include -#include #include #include @@ -35,7 +35,7 @@ #include "doxygen.h" // for Doxygen::indexList #include "index.h" // for Doxygen::indexList -static int determineInkscapeVersion(QDir &thisDir); +static int determineInkscapeVersion(Dir &thisDir); // Remove the temporary files #define RM_TMP_FILES (true) @@ -132,13 +132,13 @@ void FormulaManager::readFormulas(const char *dir,bool doCompare) void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) const { - QDir d(path); + Dir d(path); // store the original directory if (!d.exists()) { term("Output directory '%s' does not exist!\n",path); } - QCString oldDir = QDir::currentDirPath().utf8(); + std::string oldDir = Dir::currentDirPath(); QCString macroFile = Config_getString(FORMULA_MACROFILE); QCString stripMacroFile; if (!macroFile.isEmpty()) @@ -149,8 +149,8 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c } // go to the html output directory (i.e. path) - QDir::setCurrent(d.absPath()); - QDir thisDir; + Dir::setCurrent(d.absPath()); + Dir thisDir; // generate a latex file containing one formula per page. QCString texName="_formulas.tex"; IntVector formulasToGenerate; @@ -202,7 +202,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c err("Problems running latex. Check your installation or look " "for typos in _formulas.tex and check _formulas.log!\n"); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -222,7 +222,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running dvips. Check your installation!\n"); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -235,7 +235,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running %s. Check your installation!\n",Portable::ghostScriptCommand()); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -245,7 +245,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c FileInfo fi((formBase+"_tmp.epsi").str()); if (fi.exists()) { - QString eps = fileToString(formBase+"_tmp.epsi"); + QCString eps = fileToString(formBase+"_tmp.epsi"); int i = eps.find("%%BoundingBox:"); if (i!=-1) { @@ -279,7 +279,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running %s. Check your installation!\n",Portable::ghostScriptCommand()); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -293,7 +293,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running pdf2svg. Check your installation!\n"); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -304,7 +304,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c if (inkscapeVersion == -1) { err("Problems determining the version of inkscape. Check your installation!\n"); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } else if (inkscapeVersion == 0) @@ -320,7 +320,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running inkscape. Check your installation!\n"); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); @@ -333,7 +333,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c if (RM_TMP_FILES) { - thisDir.remove(formBase+"_tmp.pdf"); + thisDir.remove(formBase.str()+"_tmp.pdf"); } } else // format==Format::Bitmap @@ -346,7 +346,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running %s. Check your installation!\n",Portable::ghostScriptCommand()); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } @@ -385,7 +385,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems correcting the eps files from %s_tmp.eps to %s_tmp_corr.eps\n", formBase.data(),formBase.data()); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } @@ -403,23 +403,23 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { err("Problems running %s. Check your installation!\n",Portable::ghostScriptCommand()); Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return; } Portable::sysTimerStop(); if (RM_TMP_FILES) { - thisDir.remove(formBase+"_tmp.eps"); - thisDir.remove(formBase+"_tmp_corr.eps"); + thisDir.remove(formBase.str()+"_tmp.eps"); + thisDir.remove(formBase.str()+"_tmp_corr.eps"); } } // remove intermediate image files if (RM_TMP_FILES) { - thisDir.remove(formBase+"_tmp.ps"); - thisDir.remove(formBase+"_tmp.epsi"); + thisDir.remove(formBase.str()+"_tmp.ps"); + thisDir.remove(formBase.str()+"_tmp.epsi"); } pageIndex++; } @@ -455,7 +455,7 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c f.close(); } // reset the directory to the original location. - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); } void FormulaManager::clear() @@ -499,7 +499,7 @@ FormulaManager::DisplaySize FormulaManager::displaySize(int formulaId) const // helper function to detect and return the major version of inkscape. // return -1 if the version cannot be determined. -static int determineInkscapeVersion(QDir &thisDir) +static int determineInkscapeVersion(Dir &thisDir) { // The command line interface (CLI) of Inkscape 1.0 has changed in comparison to // previous versions. In order to invokine Inkscape, the used version is detected @@ -563,7 +563,7 @@ static int determineInkscapeVersion(QDir &thisDir) } if (RM_TMP_FILES) { - thisDir.remove(inkscapeVersionFile); + thisDir.remove(inkscapeVersionFile.str()); } Portable::sysTimerStop(); } diff --git a/src/htags.cpp b/src/htags.cpp index 7be9e48..fdde0f3 100644 --- a/src/htags.cpp +++ b/src/htags.cpp @@ -18,19 +18,17 @@ #include #include -#include - #include "htags.h" #include "util.h" #include "message.h" #include "config.h" #include "portable.h" #include "fileinfo.h" - +#include "qdir.h" bool Htags::useHtags = FALSE; -static QDir g_inputDir; +static Dir g_inputDir; static std::unordered_map g_symbolMap; /*! constructs command line of htags(1) and executes it. @@ -46,14 +44,13 @@ bool Htags::execute(const QCString &htmldir) QCString projectName = Config_getString(PROJECT_NAME); QCString projectNumber = Config_getString(PROJECT_NUMBER); - QCString cwd = QDir::currentDirPath().utf8(); if (inputSource.empty()) { - g_inputDir.setPath(cwd); + g_inputDir.setPath(Dir::currentDirPath()); } else if (inputSource.size()==1) { - g_inputDir.setPath(inputSource.back().c_str()); + g_inputDir.setPath(inputSource.back()); if (!g_inputDir.exists()) err("Cannot find directory %s. " "Check the value of the INPUT tag in the configuration file.\n", @@ -89,8 +86,8 @@ bool Htags::execute(const QCString &htmldir) commandLine += "\" "; } commandLine += " \"" + htmldir + "\""; - QCString oldDir = QDir::currentDirPath().utf8(); - QDir::setCurrent(g_inputDir.absPath()); + std::string oldDir = Dir::currentDirPath(); + Dir::setCurrent(g_inputDir.absPath()); //printf("CommandLine=[%s]\n",commandLine.data()); Portable::sysTimerStart(); bool result=Portable::system("htags",commandLine,FALSE)==0; @@ -99,7 +96,7 @@ bool Htags::execute(const QCString &htmldir) err("Problems running %s. Check your installation\n", "htags"); } Portable::sysTimerStop(); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return result; } @@ -165,7 +162,7 @@ bool Htags::loadFilemap(const QCString &htmlDir) QCString Htags::path2URL(const QCString &path) { QCString url,symName=path; - QCString dir = g_inputDir.absPath().utf8(); + QCString dir = g_inputDir.absPath(); int dl=dir.length(); if ((int)symName.length()>dl+1) { diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 768d758..79bda74 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -20,7 +20,6 @@ #include -#include #include "message.h" #include "htmlgen.h" #include "config.h" @@ -52,6 +51,7 @@ #include "tooltip.h" #include "growbuf.h" #include "fileinfo.h" +#include "dir.h" //#define DBG_HTML(x) x; #define DBG_HTML(x) @@ -878,8 +878,8 @@ HtmlGenerator::~HtmlGenerator() void HtmlGenerator::init() { QCString dname = Config_getString(HTML_OUTPUT); - QDir d(dname); - if (!d.exists() && !d.mkdir(dname)) + Dir d(dname.str()); + if (!d.exists() && !d.mkdir(dname.str())) { term("Could not create output directory %s\n",dname.data()); } diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 36b01bc..a74e3ed 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -481,8 +481,8 @@ static void writeMakeBat() void LatexGenerator::init() { QCString dname = Config_getString(LATEX_OUTPUT); - QDir d(dname); - if (!d.exists() && !d.mkdir(dname)) + Dir d(dname.str()); + if (!d.exists() && !d.mkdir(dname.str())) { term("Could not create output directory %s\n",dname.data()); } diff --git a/src/mangen.cpp b/src/mangen.cpp index 9139aa8..09f20a7 100644 --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -20,7 +20,6 @@ #include -#include #include "message.h" #include "mangen.h" #include "config.h" @@ -30,6 +29,7 @@ #include "docparser.h" #include "mandocvisitor.h" #include "language.h" +#include "dir.h" static QCString getExtension() { @@ -101,13 +101,13 @@ void ManGenerator::init() { QCString manOutput = Config_getString(MAN_OUTPUT); - QDir d(manOutput); - if (!d.exists() && !d.mkdir(manOutput)) + Dir d(manOutput.str()); + if (!d.exists() && !d.mkdir(manOutput.str())) { term("Could not create output directory %s\n",manOutput.data()); } - d.setPath(manOutput + "/" + getSubdir()); - if (!d.exists() && !d.mkdir(manOutput + "/" + getSubdir())) + std::string manDir = manOutput.str()+"/"+getSubdir().str(); + if (!d.exists(manDir) && !d.mkdir(manDir)) { term("Could not create output directory %s/%s\n",manOutput.data(), getSubdir().data()); } diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 81520a2..11547c8 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -227,7 +227,7 @@ class MemberDefImpl : public DefinitionMixin virtual const MemberDef *categoryRelation() const; virtual QCString displayName(bool=TRUE) const; virtual QCString getDeclType() const; - virtual void getLabels(QStrList &sl,const Definition *container) const; + virtual StringVector getLabels(const Definition *container) const; virtual const ArgumentList &typeConstraints() const; virtual QCString documentation() const; virtual QCString briefDescription(bool abbr=FALSE) const; @@ -717,8 +717,8 @@ class MemberDefAliasImpl : public DefinitionAliasMixin { return getMdAlias()->displayName(b); } virtual QCString getDeclType() const { return getMdAlias()->getDeclType(); } - virtual void getLabels(QStrList &sl,const Definition *container) const - { return getMdAlias()->getLabels(sl,container); } + virtual StringVector getLabels(const Definition *container) const + { return getMdAlias()->getLabels(container); } virtual const ArgumentList &typeConstraints() const { return getMdAlias()->typeConstraints(); } virtual QCString documentation() const @@ -2355,23 +2355,26 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.writeLatexSpacing(); ol.startTypewriter(); ol.docify(" ["); - QStrList sl; + StringVector sl; - if (isGettable()) sl.append("get"); - if (isProtectedGettable()) sl.append("protected get"); - if (isSettable()) sl.append("set"); - if (isProtectedSettable()) sl.append("protected set"); + if (isGettable()) sl.push_back("get"); + if (isProtectedGettable()) sl.push_back("protected get"); + if (isSettable()) sl.push_back("set"); + if (isProtectedSettable()) sl.push_back("protected set"); if (extractPrivate) { - if (isPrivateGettable()) sl.append("private get"); - if (isPrivateSettable()) sl.append("private set"); + if (isPrivateGettable()) sl.push_back("private get"); + if (isPrivateSettable()) sl.push_back("private set"); } - const char *s=sl.first(); - while (s) + bool first=true; + for (const auto &s : sl) { - ol.docify(s); - s=sl.next(); - if (s) ol.docify(", "); + if (!first) + { + ol.docify(", "); + first=false; + } + ol.docify(s.c_str()); } ol.docify("]"); ol.endTypewriter(); @@ -2382,16 +2385,19 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.writeLatexSpacing(); ol.startTypewriter(); ol.docify(" ["); - QStrList sl; - if (isAddable()) sl.append("add"); - if (isRemovable()) sl.append("remove"); - if (isRaisable()) sl.append("raise"); - const char *s=sl.first(); - while (s) + StringVector sl; + if (isAddable()) sl.push_back("add"); + if (isRemovable()) sl.push_back("remove"); + if (isRaisable()) sl.push_back("raise"); + bool first=true; + for (const auto &s : sl) { - ol.docify(s); - s=sl.next(); - if (s) ol.docify(", "); + if (!first) + { + ol.docify(", "); + first=false; + } + ol.docify(s.c_str()); } ol.docify("]"); ol.endTypewriter(); @@ -2534,8 +2540,9 @@ bool MemberDefImpl::isDetailedSectionVisible(bool inGroup,bool inFile) const return result; } -void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const +StringVector MemberDefImpl::getLabels(const Definition *container) const { + StringVector sl; static bool inlineInfo = Config_getBool(INLINE_INFO); Specifier lvirt=virtualness(); @@ -2559,82 +2566,82 @@ void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const static bool extractPrivate = Config_getBool(EXTRACT_PRIVATE); if (optVhdl) { - sl.append(theTranslator->trVhdlType(getMemberSpecifiers(),TRUE)); + sl.push_back(theTranslator->trVhdlType(getMemberSpecifiers(),TRUE).str()); } else { - if (isFriend()) sl.append("friend"); - else if (isRelated()) sl.append("related"); + if (isFriend()) sl.push_back("friend"); + else if (isRelated()) sl.push_back("related"); else { - if (isExternal()) sl.append("extern"); - if (inlineInfo && isInline()) sl.append("inline"); - if (isExplicit()) sl.append("explicit"); - if (isMutable()) sl.append("mutable"); - if (isStatic()) sl.append("static"); - if (isGettable()) sl.append("get"); - if (isProtectedGettable()) sl.append("protected get"); - if (isSettable()) sl.append("set"); - if (isProtectedSettable()) sl.append("protected set"); + if (isExternal()) sl.push_back("extern"); + if (inlineInfo && isInline()) sl.push_back("inline"); + if (isExplicit()) sl.push_back("explicit"); + if (isMutable()) sl.push_back("mutable"); + if (isStatic()) sl.push_back("static"); + if (isGettable()) sl.push_back("get"); + if (isProtectedGettable()) sl.push_back("protected get"); + if (isSettable()) sl.push_back("set"); + if (isProtectedSettable()) sl.push_back("protected set"); if (extractPrivate) { - if (isPrivateGettable()) sl.append("private get"); - if (isPrivateSettable()) sl.append("private set"); + if (isPrivateGettable()) sl.push_back("private get"); + if (isPrivateSettable()) sl.push_back("private set"); } - if (isConstExpr()) sl.append("constexpr"); - if (isAddable()) sl.append("add"); - if (!isUNOProperty() && isRemovable()) sl.append("remove"); - if (isRaisable()) sl.append("raise"); - if (isReadable()) sl.append("read"); - if (isWritable()) sl.append("write"); - if (isFinal()) sl.append("final"); - if (isAbstract()) sl.append("abstract"); - if (isOverride()) sl.append("override"); - if (isInitonly()) sl.append("initonly"); - if (isSealed()) sl.append("sealed"); - if (isNew()) sl.append("new"); - if (isOptional()) sl.append("optional"); - if (isRequired()) sl.append("required"); - - if (isNonAtomic()) sl.append("nonatomic"); - else if (isObjCProperty()) sl.append("atomic"); + if (isConstExpr()) sl.push_back("constexpr"); + if (isAddable()) sl.push_back("add"); + if (!isUNOProperty() && isRemovable()) sl.push_back("remove"); + if (isRaisable()) sl.push_back("raise"); + if (isReadable()) sl.push_back("read"); + if (isWritable()) sl.push_back("write"); + if (isFinal()) sl.push_back("final"); + if (isAbstract()) sl.push_back("abstract"); + if (isOverride()) sl.push_back("override"); + if (isInitonly()) sl.push_back("initonly"); + if (isSealed()) sl.push_back("sealed"); + if (isNew()) sl.push_back("new"); + if (isOptional()) sl.push_back("optional"); + if (isRequired()) sl.push_back("required"); + + if (isNonAtomic()) sl.push_back("nonatomic"); + else if (isObjCProperty()) sl.push_back("atomic"); // mutual exclusive Objective 2.0 property attributes - if (isAssign()) sl.append("assign"); - else if (isCopy()) sl.append("copy"); - else if (isRetain()) sl.append("retain"); - else if (isWeak()) sl.append("weak"); - else if (isStrong()) sl.append("strong"); - else if (isUnretained()) sl.append("unsafe_unretained"); + if (isAssign()) sl.push_back("assign"); + else if (isCopy()) sl.push_back("copy"); + else if (isRetain()) sl.push_back("retain"); + else if (isWeak()) sl.push_back("weak"); + else if (isStrong()) sl.push_back("strong"); + else if (isUnretained()) sl.push_back("unsafe_unretained"); if (!isObjCMethod()) { - if (protection()==Protected) sl.append("protected"); - else if (protection()==Private) sl.append("private"); - else if (protection()==Package) sl.append("package"); - - if (lvirt==Virtual) sl.append("virtual"); - else if (lvirt==Pure) sl.append("pure virtual"); - if (isSignal()) sl.append("signal"); - if (isSlot()) sl.append("slot"); - if (isDefault()) sl.append("default"); - if (isDelete()) sl.append("delete"); - if (isNoExcept()) sl.append("noexcept"); - if (isAttribute()) sl.append("attribute"); - if (isUNOProperty()) sl.append("property"); - if (isReadonly()) sl.append("readonly"); - if (isBound()) sl.append("bound"); - if (isUNOProperty() && isRemovable()) sl.append("removable"); - if (isConstrained()) sl.append("constrained"); - if (isTransient()) sl.append("transient"); - if (isMaybeVoid()) sl.append("maybevoid"); - if (isMaybeDefault()) sl.append("maybedefault"); - if (isMaybeAmbiguous()) sl.append("maybeambiguous"); - if (isPublished()) sl.append("published"); // enum + if (protection()==Protected) sl.push_back("protected"); + else if (protection()==Private) sl.push_back("private"); + else if (protection()==Package) sl.push_back("package"); + + if (lvirt==Virtual) sl.push_back("virtual"); + else if (lvirt==Pure) sl.push_back("pure virtual"); + if (isSignal()) sl.push_back("signal"); + if (isSlot()) sl.push_back("slot"); + if (isDefault()) sl.push_back("default"); + if (isDelete()) sl.push_back("delete"); + if (isNoExcept()) sl.push_back("noexcept"); + if (isAttribute()) sl.push_back("attribute"); + if (isUNOProperty()) sl.push_back("property"); + if (isReadonly()) sl.push_back("readonly"); + if (isBound()) sl.push_back("bound"); + if (isUNOProperty() && isRemovable()) sl.push_back("removable"); + if (isConstrained()) sl.push_back("constrained"); + if (isTransient()) sl.push_back("transient"); + if (isMaybeVoid()) sl.push_back("maybevoid"); + if (isMaybeDefault()) sl.push_back("maybedefault"); + if (isMaybeAmbiguous()) sl.push_back("maybeambiguous"); + if (isPublished()) sl.push_back("published"); // enum } if (isObjCProperty() && isImplementation()) { - sl.append("implementation"); + sl.push_back("implementation"); } } if (getClassDef() && @@ -2643,14 +2650,15 @@ void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const !isRelated() ) { - sl.append("inherited"); + sl.push_back("inherited"); } } } else if (isObjCMethod() && isImplementation()) { - sl.append("implementation"); + sl.push_back("implementation"); } + return sl; } void MemberDefImpl::_writeCallGraph(OutputList &ol) const @@ -3199,8 +3207,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.pushGeneratorState(); bool htmlEndLabelTable=FALSE; - QStrList sl; - getLabels(sl,scopedContainer); + StringVector sl = getLabels(scopedContainer); static const reg::Ex r(R"(@\d+)"); reg::Match match; @@ -3303,7 +3310,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, } } - if (sl.count()>0) + if (!sl.empty()) { ol.pushGeneratorState(); ol.disableAll(); @@ -3407,15 +3414,14 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.pushGeneratorState(); ol.disable(OutputGenerator::Html); - if (sl.count()>0) + if (!sl.empty()) { ol.startLabels(); - const char *s=sl.first(); - while (s) + size_t count=0; + for (const auto &s : sl) { - const char *ns = sl.next(); - ol.writeLabel(s,ns==0); - s=ns; + count++; + ol.writeLabel(s.c_str(),count==sl.size()); } ol.endLabels(); } @@ -3441,12 +3447,11 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.writeString(" \n"); ol.writeString(" \n"); ol.startLabels(); - const char *s=sl.first(); - while (s) + size_t count=0; + for (const auto &s : sl) { - const char *ns = sl.next(); - ol.writeLabel(s,ns==0); - s=ns; + count++; + ol.writeLabel(s.c_str(),count==sl.size()); } ol.endLabels(); ol.writeString(" \n"); diff --git a/src/memberdef.h b/src/memberdef.h index abaf3ff..e6afcb3 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -36,7 +36,6 @@ class MemberGroup; class ExampleList; class OutputList; class GroupDef; -class QStrList; struct TagInfo; class MemberDefMutable; class MemberGroupList; @@ -258,7 +257,7 @@ class MemberDef : public Definition virtual QCString displayName(bool=TRUE) const = 0; virtual QCString getDeclType() const = 0; - virtual void getLabels(QStrList &sl,const Definition *container) const = 0; + virtual StringVector getLabels(const Definition *container) const = 0; virtual const ArgumentList &typeConstraints() const = 0; diff --git a/src/msc.cpp b/src/msc.cpp index 29c9334..17a7a5d 100644 --- a/src/msc.cpp +++ b/src/msc.cpp @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -25,8 +25,7 @@ #include "util.h" #include "ftextstream.h" #include "mscgen_api.h" - -#include +#include "dir.h" static const int maxCmdLine = 40960; @@ -160,7 +159,7 @@ static QCString getMscImageMapFromFile(const QCString& inFile, const QCString& o QGString result; FTextStream tmpout(&result); convertMapFile(tmpout, outFile, relPath, context); - QDir().remove(outFile); + Dir().remove(outFile.str()); return result.data(); } diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index d8010a4..80a90cd 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "perlmodgen.h" @@ -43,6 +42,7 @@ #include "util.h" #include "htmlentity.h" #include "emoji.h" +#include "dir.h" #define PERLOUTPUT_MAX_INDENTATION 40 @@ -1483,7 +1483,7 @@ static QCString pathDoxyExec; void setPerlModDoxyfile(const QCString &qs) { pathDoxyfile = qs; - pathDoxyExec = QDir::currentDirPath().utf8(); + pathDoxyExec = Dir::currentDirPath(); } class PerlModGenerator @@ -1519,7 +1519,7 @@ public: void generatePerlModForPage(PageDef *pi); bool createOutputFile(QFile &f, const char *s); - bool createOutputDir(QDir &perlModDir); + bool createOutputDir(Dir &perlModDir); bool generateDoxyLatexTex(); bool generateDoxyFormatTex(); bool generateDoxyStructurePM(); @@ -2199,45 +2199,9 @@ bool PerlModGenerator::createOutputFile(QFile &f, const char *s) return true; } -bool PerlModGenerator::createOutputDir(QDir &perlModDir) +bool PerlModGenerator::createOutputDir(Dir &perlModDir) { - QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY); - if (outputDirectory.isEmpty()) - { - outputDirectory=QDir::currentDirPath().utf8(); - } - else - { - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - term("tag OUTPUT_DIRECTORY: Output directory '%s' does not " - "exist and cannot be created\n",outputDirectory.data()); - } - else - { - msg("Notice: Output directory '%s' does not exist. " - "I have created it for you.\n", outputDirectory.data()); - } - dir.cd(outputDirectory); - } - outputDirectory=dir.absPath().utf8(); - } - - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - err("Cannot create directory %s\n",outputDirectory.data()); - return false; - } - } - + std::string outputDirectory = Config_getString(OUTPUT_DIRECTORY).str(); perlModDir.setPath(outputDirectory+"/perlmod"); if (!perlModDir.exists() && !perlModDir.mkdir(outputDirectory+"/perlmod")) { @@ -2911,13 +2875,13 @@ void PerlModGenerator::generate() // + related pages // - examples - QDir perlModDir; + Dir perlModDir; if (!createOutputDir(perlModDir)) return; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); - QCString perlModAbsPath = perlModDir.absPath().utf8(); + QCString perlModAbsPath = perlModDir.absPath(); pathDoxyDocsPM = perlModAbsPath + "/DoxyDocs.pm"; pathDoxyStructurePM = perlModAbsPath + "/DoxyStructure.pm"; pathMakefile = perlModAbsPath + "/Makefile"; diff --git a/src/portable.cpp b/src/portable.cpp index de713e8..a1f1e96 100644 --- a/src/portable.cpp +++ b/src/portable.cpp @@ -17,13 +17,13 @@ extern char **environ; #endif #include -#include #include #include #include "fileinfo.h" #include "util.h" +#include "dir.h" #ifndef NODEBUG #include "debug.h" #endif @@ -519,14 +519,14 @@ void Portable::setShortDir() long length = 0; TCHAR* buffer = NULL; // First obtain the size needed by passing NULL and 0. - length = GetShortPathName(QDir::currentDirPath().data(), NULL, 0); + length = GetShortPathName(Dir::currentDirPath().c_str(), NULL, 0); // Dynamically allocate the correct size // (terminating null char was included in length) buffer = new TCHAR[length]; // Now simply call again using same (long) path. - length = GetShortPathName(QDir::currentDirPath().data(), buffer, length); + length = GetShortPathName(Dir::currentDirPath().c_str(), buffer, length); // Set the correct directory (short name) - QDir::setCurrent(buffer); + Dir::setCurrent(buffer); delete [] buffer; #endif } diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index debda5c..636d278 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -21,8 +21,6 @@ #include #include -#include - #include "rtfgen.h" #include "config.h" #include "message.h" @@ -47,6 +45,7 @@ #include "classlist.h" #include "filename.h" #include "namespacedef.h" +#include "dir.h" //#define DBG_RTF(x) x; @@ -171,8 +170,8 @@ void RTFGenerator::writeExtensionsFile(QFile &file) void RTFGenerator::init() { QCString dir=Config_getString(RTF_OUTPUT); - QDir d(dir); - if (!d.exists() && !d.mkdir(dir)) + Dir d(dir.str()); + if (!d.exists() && !d.mkdir(dir.str())) { term("Could not create output directory %s\n",dir.data()); } @@ -2374,7 +2373,7 @@ static void encodeForOutput(FTextStream &t,const char *s) * VERY brittle routine inline RTF's included by other RTF's. * it is recursive and ugly. */ -static bool preProcessFile(QDir &d,QCString &infName, FTextStream &t, bool bIncludeHeader=TRUE) +static bool preProcessFile(Dir &d,QCString &infName, FTextStream &t, bool bIncludeHeader=TRUE) { QFile f(infName); if (!f.open(IO_ReadOnly)) @@ -2444,7 +2443,7 @@ static bool preProcessFile(QDir &d,QCString &infName, FTextStream &t, bool bIncl } f.close(); // remove temporary file - d.remove(infName); + d.remove(infName.str()); return TRUE; } @@ -2596,18 +2595,18 @@ err: */ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) { - QDir d(path); + Dir d(path); // store the original directory if (!d.exists()) { err("Output dir %s does not exist!\n",path); return FALSE; } - QCString oldDir = QDir::currentDirPath().utf8(); + std::string oldDir = Dir::currentDirPath(); // go to the html output directory (i.e. path) - QDir::setCurrent(d.absPath()); - QDir thisDir; + Dir::setCurrent(d.absPath()); + Dir thisDir; QCString combinedName = (QCString)path+"/combined.rtf"; QCString mainRTFName = (QCString)path+"/"+name; @@ -2616,7 +2615,7 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) if (!outf.open(IO_WriteOnly)) { err("Failed to open %s for writing!\n",combinedName.data()); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return FALSE; } FTextStream outt(&outf); @@ -2625,19 +2624,19 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) { // it failed, remove the temp file outf.close(); - thisDir.remove(combinedName); - QDir::setCurrent(oldDir); + thisDir.remove(combinedName.str()); + Dir::setCurrent(oldDir); return FALSE; } // everything worked, move the files outf.close(); - thisDir.remove(mainRTFName); - thisDir.rename(combinedName,mainRTFName); + thisDir.remove(mainRTFName.str()); + thisDir.rename(combinedName.str(),mainRTFName.str()); testRTFOutput(mainRTFName); - QDir::setCurrent(oldDir); + Dir::setCurrent(oldDir); return TRUE; } diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 315941c..de30544 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -45,9 +45,9 @@ #include "dirdef.h" #include "section.h" #include "fileinfo.h" +#include "dir.h" #include -#include #include #include @@ -2393,7 +2393,6 @@ static sqlite3* openDbConnection() { QCString outputDirectory = Config_getString(SQLITE3_OUTPUT); - QDir sqlite3Dir(outputDirectory); sqlite3 *db; int rc; @@ -2411,7 +2410,7 @@ static sqlite3* openDbConnection() { if (Config_getBool(SQLITE3_RECREATE_DB)) { - QDir().remove(fi.absFilePath().c_str()); + Dir().remove(fi.absFilePath()); } else { diff --git a/src/template.cpp b/src/template.cpp index 989b596..ae55fc4 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -22,7 +22,6 @@ #include #include -#include #include "ftextstream.h" #include "message.h" @@ -31,6 +30,7 @@ #include "portable.h" #include "regex.h" #include "fileinfo.h" +#include "dir.h" #define ENABLE_TRACING 0 @@ -2772,36 +2772,35 @@ template class TemplateNodeCreator : public TemplateNode return dynamic_cast(root); } protected: - void mkpath(TemplateContextImpl *ci,const QCString &fileName) + void mkpath(TemplateContextImpl *ci,const std::string &fileName) { - int i=fileName.find('/'); - QCString outputDir = ci->outputDirectory(); - QDir d(outputDir); + size_t i=fileName.find('/'); + std::string outputDir = ci->outputDirectory().str(); + Dir d(outputDir); if (!d.exists()) { - QDir rootDir; - rootDir.setPath(QDir::currentDirPath()); + Dir rootDir; if (!rootDir.mkdir(outputDir)) { err("tag OUTPUT_DIRECTORY: Output directory '%s' does not " - "exist and cannot be created\n",outputDir.data()); + "exist and cannot be created\n",outputDir.c_str()); return; } d.setPath(outputDir); } - int j=0; - while (i!=-1) // fileName contains path part + size_t j=0; + while (i!=std::string::npos) // fileName contains path part { if (d.exists()) { - bool ok = d.mkdir(fileName.mid(j,i-j)); + bool ok = d.mkdir(fileName.substr(j,i-j)); if (!ok) { - err("Failed to create directory '%s'\n",(fileName.mid(j,i-j)).data()); + err("Failed to create directory '%s'\n",(fileName.substr(j,i-j)).c_str()); break; } - QCString dirName = outputDir+'/'+fileName.left(i); - d = QDir(dirName); + std::string dirName = outputDir+'/'+fileName.substr(0,i); + d = Dir(dirName); j = i+1; } i=fileName.find('/',i+1); @@ -3629,7 +3628,7 @@ class TemplateNodeCreate : public TemplateNodeCreator TemplateImpl *createTemplate = ct ? dynamic_cast(ct) : 0; if (createTemplate) { - mkpath(ci,outputFile); + mkpath(ci,outputFile.str()); if (!ci->outputDirectory().isEmpty()) { outputFile.prepend(ci->outputDirectory()+"/"); @@ -4338,7 +4337,7 @@ class TemplateNodeResource : public TemplateNodeCreator if (m_asExpr) { QCString targetFile = m_asExpr->resolve(c).toString(); - mkpath(ci,targetFile); + mkpath(ci,targetFile.str()); if (targetFile.isEmpty()) { ci->warn(m_templateName,m_line,"invalid parameter at right side of 'as' for resource command\n"); } diff --git a/src/util.cpp b/src/util.cpp index a016e3d..3cdcdfe 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3318,7 +3318,7 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) cachedResult = g_findFileDefCache.insert(key.str(),FindFileCacheElem(0,FALSE)); } - QCString name=QDir::cleanDirPath(n).utf8(); + QCString name=Dir::cleanDirPath(n); QCString path; int slashPos; const FileName *fn; @@ -3328,12 +3328,11 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) { path=name.left(slashPos+1); name=name.right(name.length()-slashPos-1); - //printf("path=%s name=%s\n",path.data(),name.data()); } if (name.isEmpty()) goto exit; if ((fn=fnMap->find(name))) { - //printf("fn->count()=%d\n",fn->count()); + //printf("fn->size()=%zu\n",fn->size()); if (fn->size()==1) { const std::unique_ptr &fd = fn->front(); @@ -3785,7 +3784,7 @@ QCString relativePathToRoot(const char *name) return result; } -void createSubDirs(QDir &d) +void createSubDirs(const Dir &d) { if (Config_getBool(CREATE_SUBDIRS)) { @@ -3795,7 +3794,7 @@ void createSubDirs(QDir &d) { QCString subdir; subdir.sprintf("d%x",l1); - if (!d.exists(subdir) && !d.mkdir(subdir)) + if (!d.exists(subdir.str()) && !d.mkdir(subdir.str())) { term("Failed to create output directory '%s'\n",subdir.data()); } @@ -3803,7 +3802,7 @@ void createSubDirs(QDir &d) { QCString subsubdir; subsubdir.sprintf("d%x/d%02x",l1,l2); - if (!d.exists(subsubdir) && !d.mkdir(subsubdir)) + if (!d.exists(subsubdir.str()) && !d.mkdir(subsubdir.str())) { term("Failed to create output directory '%s'\n",subsubdir.data()); } @@ -7251,11 +7250,11 @@ bool openOutputFile(const char *outFile,QFile &f) FileInfo fi(outFile); if (fi.exists()) // create a backup { - QDir dir; + Dir dir; FileInfo backup(fi.fileName()+".bak"); if (backup.exists()) // remove existing backup - dir.remove(backup.fileName().c_str()); - dir.rename(QCString(fi.fileName()),QCString(fi.fileName()+".bak")); + dir.remove(backup.fileName()); + dir.rename(fi.fileName(),fi.fileName()+".bak"); } f.setName(outFile); fileOpened = f.open(IO_WriteOnly|IO_Translate); diff --git a/src/util.h b/src/util.h index c7fe0a1..f57b827 100644 --- a/src/util.h +++ b/src/util.h @@ -36,6 +36,7 @@ #include "namespacedef.h" #include "outputgen.h" #include "regex.h" +#include "dir.h" //-------------------------------------------------------------------- @@ -52,12 +53,10 @@ class GroupDef; struct TagInfo; class PageDef; class SectionInfo; -class QDir; class Definition; class BufStr; class FileInfo; class QFileInfo; -class QStrList; class FTextStream; class QFile; @@ -350,7 +349,7 @@ void addDirPrefix(QCString &fileName); QCString relativePathToRoot(const char *name); -void createSubDirs(QDir &d); +void createSubDirs(const Dir &d); QCString stripPath(const char *s); diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index 7b9a638..ac4e2db 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -252,8 +252,9 @@ static int idCounter; * end; */ -QString VHDLOutlineParser::getNameID(){ - return QString::number(idCounter++,10); +QCString VHDLOutlineParser::getNameID() +{ + return QCString().setNum(idCounter++); } void VHDLOutlineParser::handleFlowComment(const char* doc) diff --git a/src/vhdljjparser.h b/src/vhdljjparser.h index b074511..6942aa0 100755 --- a/src/vhdljjparser.h +++ b/src/vhdljjparser.h @@ -66,7 +66,7 @@ class VHDLOutlineParser : public OutlineParserInterface void setMultCommentLine(); bool checkMultiComment(QCString& qcs,int line); void insertEntryAtLine(std::shared_ptr ce,int line); - QString getNameID(); + QCString getNameID(); int checkInlineCode(QCString & doc); private: struct Private; diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 3f74da1..a4881af 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -15,7 +15,6 @@ #include -#include #include #include "xmlgen.h" @@ -47,6 +46,7 @@ #include "section.h" #include "htmlentity.h" #include "resourcemgr.h" +#include "dir.h" // no debug info #define XML_DB(x) do {} while(0) @@ -1832,7 +1832,7 @@ void generateXML() // - examples QCString outputDirectory = Config_getString(XML_OUTPUT); - QDir xmlDir(outputDirectory); + Dir xmlDir(outputDirectory.str()); createSubDirs(xmlDir); ResourceMgr::instance().copyResource("xml.xsd",outputDirectory); -- cgit v0.12