Prepare for 1.9.6 add deflate patch This is a combination of the following commits from the Release_1_9_6 tag, rebased onto the Release_1_9_5 tag, so that the patch for Release_1_9_6 that adds the deflate patch can be applied to the Release_1_9_5 tag: 293d3beaf issue #9319 Doc build fails with cairo 1.17.6 Implementing the use of the environment variable so that always the non compressed version is written. This commit was an early workaround for the problem, included in doxygen-1.9.6, but as it did not work very well and was no longer necessary once the deflate detection and support was added, the patch for adding the support implicitly reverted this commit. Add this commit so the patch applies cleanly. e002e293d issue #1166: Read error when multi-byte characters in file path name (Origin: bugzilla #145186) This commit adds some methods to the Portable class that the patch for doxygen-1.9.6 requires. There were some conflicts that needed to be resolved, usually updates to sections not present in Release_1_9_5, and so could be safely ignored. Most of the conflicts were in adding an include "portable.h" line to a list of includes that had changed, and could simply be resolved by adding include "portable.h" to the equivalent location. The patch for doxygen-1.9.6 that this prepares for adds patched deflate detection and support to doxygen-1.9.6, to fix Gentoo bug #884185 (doxygen fails to emerge with cairo-1.17.6). diff --git a/src/cite.cpp b/src/cite.cpp --- a/src/cite.cpp +++ b/src/cite.cpp @@ -123,7 +123,7 @@ void CitationManager::insertCrossReferencesForBibFile(const QCString &bibFile) err("bib file %s not found!\n",qPrint(bibFile)); return; } - std::ifstream f(bibFile.str(), std::ifstream::in); + std::ifstream f = Portable::openInputStream(bibFile); if (!f.is_open()) { err("could not open file %s for reading\n",qPrint(bibFile)); @@ -217,7 +217,7 @@ void CitationManager::generatePage() QCString outputDir = Config_getString(OUTPUT_DIRECTORY); QCString citeListFile = outputDir+"/citelist.doc"; { - std::ofstream t(citeListFile.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(citeListFile); if (!t.is_open()) { err("could not open file %s for writing\n",qPrint(citeListFile)); @@ -292,7 +292,7 @@ void CitationManager::generatePage() // 6. read back the file QCString doc; { - std::ifstream f(citeListFile.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(citeListFile); if (!f.is_open()) { err("could not open file %s for reading\n",qPrint(citeListFile)); diff --git a/src/configimpl.l b/src/configimpl.l --- a/src/configimpl.l +++ b/src/configimpl.l @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -1554,7 +1553,7 @@ static QCString configFileToString(const QCString &name) } else // read from file { - std::ifstream f(name.str(),std::istream::in); + std::ifstream f = Portable::openInputStream(name); if (!f.is_open()) { config_term("file '%s' not found or could not be opened\n",qPrint(name)); diff --git a/src/defgen.cpp b/src/defgen.cpp --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -18,8 +18,7 @@ #include -#include - +#include "portable.h" #include "defgen.h" #include "doxygen.h" #include "message.h" @@ -534,7 +533,7 @@ void generateDEF() } QCString fileName=outputDirectory+"/doxygen.def"; - std::ofstream f(fileName.str(),std::ostream::out | std::ostream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); diff --git a/src/diagram.cpp b/src/diagram.cpp --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include "diagram.h" @@ -1090,7 +1089,7 @@ void ClassDiagram::writeFigure(TextStream &output,const QCString &path, QCString epsBaseName=QCString(path)+"/"+fileName; QCString epsName=epsBaseName+".eps"; - std::ofstream f(epsName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(epsName); if (!f.is_open()) { term("Could not open file %s for writing\n",qPrint(epsName)); diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -13,8 +13,6 @@ * */ -#include - #include "docbookvisitor.h" #include "docparser.h" #include "language.h" @@ -35,6 +33,7 @@ #include "plantuml.h" #include "growbuf.h" #include "fileinfo.h" +#include "portable.h" #if 0 #define DB_VIS_C DB_VIS_C1(m_t) @@ -371,17 +370,17 @@ DB_VIS_C qPrint(Config_getString(DOCBOOK_OUTPUT)+"/inline_dotgraph_"), dotindex++ ); - std::string fileName = baseName.str()+".dot"; - std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + QCString fileName = baseName+".dot"; + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { - err("Could not open file %s for writing\n",fileName.c_str()); + err("Could not open file %s for writing\n",qPrint(fileName)); } file.write( stext.data(), stext.length() ); file.close(); writeDotFile(baseName, s); m_t << "\n"; - if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } break; case DocVerbatim::Msc: @@ -396,11 +395,11 @@ DB_VIS_C (Config_getString(DOCBOOK_OUTPUT)+"/inline_mscgraph_").data(), mscindex++ ); - std::string fileName = baseName.str()+".msc"; - std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + QCString fileName = baseName+".msc"; + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { - err("Could not open file %s for writing\n",fileName.c_str()); + err("Could not open file %s for writing\n",qPrint(fileName)); } QCString text = "msc {"; text+=stext; @@ -409,7 +408,7 @@ DB_VIS_C file.close(); writeMscFile(baseName,s); m_t << "\n"; - if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } break; case DocVerbatim::PlantUML: diff --git a/src/docsets.cpp b/src/docsets.cpp --- a/src/docsets.cpp +++ b/src/docsets.cpp @@ -15,7 +15,6 @@ #include #include -#include #include "docsets.h" #include "config.h" @@ -28,6 +27,7 @@ #include "namespacedef.h" #include "util.h" #include "textstream.h" +#include "portable.h" struct DocSets::Private { @@ -66,7 +66,7 @@ void DocSets::initialize() // -- write Makefile { QCString mfName = Config_getString(HTML_OUTPUT) + "/Makefile"; - std::ofstream ts(mfName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream ts = Portable::openOutputStream(mfName); if (!ts.is_open()) { term("Could not open file %s for writing\n",qPrint(mfName)); @@ -115,7 +115,7 @@ void DocSets::initialize() // -- write Info.plist { QCString plName = Config_getString(HTML_OUTPUT) + "/Info.plist"; - std::ofstream ts(plName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream ts = Portable::openOutputStream(plName); if (!ts.is_open()) { term("Could not open file %s for writing\n",qPrint(plName)); @@ -151,7 +151,7 @@ void DocSets::initialize() // -- start Nodes.xml QCString notes = Config_getString(HTML_OUTPUT) + "/Nodes.xml"; - p->ntf.open(notes.str(),std::ofstream::out | std::ofstream::binary); + p->ntf = Portable::openOutputStream(notes); if (!p->ntf.is_open()) { term("Could not open file %s for writing\n",qPrint(notes)); @@ -169,7 +169,7 @@ void DocSets::initialize() p->indentStack.push(true); QCString tokens = Config_getString(HTML_OUTPUT) + "/Tokens.xml"; - p->ttf.open(tokens.str(),std::ofstream::out | std::ofstream::binary); + p->ttf = Portable::openOutputStream(tokens); if (!p->ttf.is_open()) { term("Could not open file %s for writing\n",qPrint(tokens)); diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp --- a/src/dotfilepatcher.cpp +++ b/src/dotfilepatcher.cpp @@ -13,8 +13,6 @@ * */ -#include - #include "dotfilepatcher.h" #include "dotrunner.h" #include "config.h" @@ -25,6 +23,7 @@ #include "util.h" #include "dot.h" #include "dir.h" +#include "portable.h" static const char svgZoomHeader[] = "\n" @@ -218,7 +217,7 @@ bool DotFilePatcher::convertMapFile(TextStream &t,const QCString &mapName, const QCString &relPath, bool urlOnly, const QCString &context) { - std::ifstream f(mapName.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(mapName); if (!f.is_open()) { err("problems opening map file %s for inclusion in the docs!\n" @@ -308,26 +307,25 @@ bool DotFilePatcher::run() const //printf("DotFilePatcher::addSVGConversion: file=%s zoomable=%d\n", // qPrint(m_patchFile),map->zoomable); } - std::string tmpName = m_patchFile.str()+".tmp"; - std::string patchFile = m_patchFile.str(); + QCString tmpName = m_patchFile+".tmp"; Dir thisDir; - if (!thisDir.rename(patchFile,tmpName)) + if (!thisDir.rename(m_patchFile.str(),tmpName.str())) { - err("Failed to rename file %s to %s!\n",qPrint(m_patchFile),tmpName.c_str()); + err("Failed to rename file %s to %s!\n",qPrint(m_patchFile),qPrint(tmpName)); return FALSE; } - std::ifstream fi(tmpName, std::ifstream::in); - std::ofstream fo(patchFile, std::ofstream::out | std::ofstream::binary); + std::ifstream fi = Portable::openInputStream(tmpName); + std::ofstream fo = Portable::openOutputStream(m_patchFile); if (!fi.is_open()) { - err("problem opening file %s for patching!\n",tmpName.c_str()); - thisDir.rename(tmpName,patchFile); + err("problem opening file %s for patching!\n",qPrint(tmpName)); + thisDir.rename(tmpName.str(),m_patchFile.str()); return FALSE; } if (!fo.is_open()) { err("problem opening file %s for patching!\n",qPrint(m_patchFile)); - thisDir.rename(tmpName,patchFile); + thisDir.rename(tmpName.str(),m_patchFile.str()); return FALSE; } TextStream t(&fo); @@ -474,11 +472,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.open(tmpName,std::ifstream::in); - fo.open(orgName.str(),std::ofstream::out | std::ofstream::binary); + fi = Portable::openInputStream(tmpName); + fo = Portable::openOutputStream(orgName); if (!fi.is_open()) { - err("problem opening file %s for reading!\n",tmpName.c_str()); + err("problem opening file %s for reading!\n",qPrint(tmpName)); return FALSE; } if (!fo.is_open()) @@ -498,7 +496,7 @@ bool DotFilePatcher::run() const fo.close(); } // remove temporary file - thisDir.remove(tmpName); + thisDir.remove(tmpName.str()); return TRUE; } @@ -509,7 +507,7 @@ bool DotFilePatcher::run() const static bool readSVGSize(const QCString &fileName,int *width,int *height) { bool found=FALSE; - std::ifstream f(fileName.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(fileName); if (!f.is_open()) { return false; diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp --- a/src/dotgraph.cpp +++ b/src/dotgraph.cpp @@ -13,7 +13,6 @@ * */ -#include #include #include @@ -30,6 +29,7 @@ #include "dotnode.h" #include "dotfilepatcher.h" #include "fileinfo.h" +#include "portable.h" #define MAP_CMD "cmapx" @@ -46,7 +46,7 @@ static bool sameMd5Signature(const QCString &baseName, bool same = false; char md5stored[33]; md5stored[0]=0; - std::ifstream f(baseName.str()+".md5",std::ifstream::in | std::ifstream::binary); + std::ifstream f = Portable::openInputStream(baseName+".md5",true); if (f.is_open()) { // read checksum @@ -177,7 +177,7 @@ bool DotGraph::prepareDotFile() // need to rebuild the image // write .dot file because image was new or has changed - std::ofstream f(absDotName().str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(absDotName()); if (!f.is_open()) { err("Could not open file %s for writing\n",qPrint(absDotName())); diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp --- a/src/dotrunner.cpp +++ b/src/dotrunner.cpp @@ -66,26 +66,26 @@ static void checkPngResult(const QCString &imgName) static bool resetPDFSize(const int width,const int height, const QCString &base) { - std::string tmpName = base.str()+".tmp"; - std::string patchFile = base.str()+".dot"; + QCString tmpName = base+".tmp"; + QCString patchFile = base+".dot"; Dir thisDir; - if (!thisDir.rename(patchFile,tmpName)) + if (!thisDir.rename(patchFile.str(),tmpName.str())) { err("Failed to rename file %s to %s!\n",qPrint(patchFile),qPrint(tmpName)); return FALSE; } - std::ifstream fi(tmpName,std::ifstream::in); - std::ofstream t(patchFile,std::ofstream::out | std::ofstream::binary); + std::ifstream fi = Portable::openInputStream(tmpName); + std::ofstream t = Portable::openOutputStream(patchFile); if (!fi.is_open()) { err("problem opening file %s for patching!\n",qPrint(tmpName)); - thisDir.rename(tmpName,patchFile); + thisDir.rename(tmpName.str(),patchFile.str()); return FALSE; } if (!t.is_open()) { err("problem opening file %s for patching!\n",qPrint(patchFile)); - thisDir.rename(tmpName,patchFile); + thisDir.rename(tmpName.str(),patchFile.str()); return FALSE; } std::string line; @@ -102,7 +102,7 @@ static bool resetPDFSize(const int width,const int height, const QCString &base) fi.close(); t.close(); // remove temporary file - thisDir.remove(tmpName); + thisDir.remove(tmpName.str()); return TRUE; } diff --git a/src/doxygen.cpp b/src/doxygen.cpp --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -10699,7 +10699,7 @@ static void dumpSymbol(TextStream &t,Definition *d) static void dumpSymbolMap() { - std::ofstream f("symbols.sql",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream("symbols.sql"); if (f.is_open()) { TextStream t(&f); @@ -11527,7 +11527,7 @@ static void writeTagFile() QCString generateTagFile = Config_getString(GENERATE_TAGFILE); if (generateTagFile.isEmpty()) return; - std::ofstream f(generateTagFile.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(generateTagFile); if (!f.is_open()) { err("cannot open tag file %s for writing\n", @@ -11982,6 +11982,8 @@ void parseInput() { Portable::setenv("DOTFONTPATH",qPrint(curFontPath)); } + // issue 9319 + Portable::setenv("CAIRO_DEBUG_PDF","1"); } diff --git a/src/eclipsehelp.cpp b/src/eclipsehelp.cpp --- a/src/eclipsehelp.cpp +++ b/src/eclipsehelp.cpp @@ -13,13 +13,12 @@ * */ -#include - #include "eclipsehelp.h" #include "util.h" #include "config.h" #include "message.h" #include "doxygen.h" +#include "portable.h" struct EclipseHelp::Private { @@ -71,7 +70,7 @@ void EclipseHelp::initialize() { // -- open the contents file QCString name = Config_getString(HTML_OUTPUT) + "/toc.xml"; - p->tocstream.open(name.str(), std::ofstream::out | std::ofstream::binary); + p->tocstream = Portable::openOutputStream(name); if (!p->tocstream.is_open()) { term("Could not open file %s for writing\n", qPrint(name)); @@ -107,7 +106,7 @@ void EclipseHelp::finalize() p->tocstream.close(); QCString name = Config_getString(HTML_OUTPUT) + "/plugin.xml"; - std::ofstream t(name.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(name); if (t.is_open()) { QCString docId = Config_getString(ECLIPSE_DOC_ID); diff --git a/src/formula.cpp b/src/formula.cpp --- a/src/formula.cpp +++ b/src/formula.cpp @@ -13,6 +13,11 @@ * */ +#include +#include +#include +#include + #include "formula.h" #include "message.h" #include "config.h" @@ -23,12 +28,7 @@ #include "dir.h" #include "regex.h" #include "linkedmap.h" - -#include -#include -#include -#include -#include +#include "portable.h" // TODO: remove these dependencies #include "doxygen.h" // for Doxygen::indexList @@ -60,7 +60,7 @@ FormulaManager &FormulaManager::instance() void FormulaManager::initFromRepository(const QCString &dir) { - std::ifstream f(dir.str()+"/formula.repository",std::ifstream::in); + std::ifstream f = Portable::openInputStream(dir+"/formula.repository"); if (f.is_open()) { uint formulaCount=0; @@ -196,7 +196,7 @@ void FormulaManager::createLatexFile(const QCString &fileName,Format format,Mode // generate a latex file containing one formula per page. QCString texName=fileName+".tex"; - std::ofstream f(texName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(texName); if (f.is_open()) { TextStream t(&f); @@ -442,8 +442,8 @@ static bool updateEPSBoundingBox(const QCString &formBase, { // read back %s_tmp.eps and replace // bounding box values with x1,y1,x2,y2 and remove the HiResBoundingBox - std::ifstream epsIn(formBase.str()+"_tmp.eps",std::ifstream::in); - std::ofstream epsOut(formBase.str()+"_tmp_corr.eps",std::ofstream::out | std::ofstream::binary); + std::ifstream epsIn = Portable::openInputStream(formBase+"_tmp.eps"); + std::ofstream epsOut = Portable::openOutputStream(formBase+"_tmp_corr.eps"); if (epsIn.is_open() && epsOut.is_open()) { std::string line; @@ -592,8 +592,7 @@ void FormulaManager::createFormulasTexFile(Dir &thisDir,Format format,HighDPI hd // generated images represent (we use this next time to avoid regeneration // of the images, and to avoid forcing the user to delete all images in order // to let a browser refresh the images). - std::ofstream f; - f.open("formula.repository",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream("formula.repository"); if (f.is_open()) { TextStream t(&f); @@ -709,7 +708,7 @@ static int determineInkscapeVersion(Dir &thisDir) } } // read version file and determine major version - std::ifstream inkscapeVersionIn(inkscapeVersionFile.str(),std::ifstream::in); + std::ifstream inkscapeVersionIn = Portable::openInputStream(inkscapeVersionFile); if (inkscapeVersionIn.is_open()) { std::string line; diff --git a/src/ftvhelp.cpp b/src/ftvhelp.cpp --- a/src/ftvhelp.cpp +++ b/src/ftvhelp.cpp @@ -36,6 +36,7 @@ #include "classdef.h" #include "util.h" #include "resourcemgr.h" +#include "portable.h" static int folderId=1; @@ -627,7 +628,7 @@ static bool generateJSTree(NavIndexEntryList &navIndex,TextStream &t, fileId+="_dup"; } QCString fileName = htmlOutput+"/"+fileId+".js"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (f.is_open()) { TextStream tt(&f); @@ -661,7 +662,7 @@ static bool generateJSTree(NavIndexEntryList &navIndex,TextStream &t, static void generateJSNavTree(const FTVNodes &nodeList) { QCString htmlOutput = Config_getString(HTML_OUTPUT); - std::ofstream f(htmlOutput.str()+"/navtreedata.js",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(htmlOutput+"/navtreedata.js"); NavIndexEntryList navIndex; if (f.is_open()) { @@ -713,7 +714,7 @@ static void generateJSNavTree(const FTVNodes &nodeList) int subIndex=0; int elemCount=0; const int maxElemCount=250; - std::ofstream tsidx(htmlOutput.str()+"/navtreeindex0.js",std::ofstream::out | std::ofstream::binary); + std::ofstream tsidx = Portable::openOutputStream(htmlOutput+"/navtreeindex0.js"); if (tsidx.is_open()) { t << "var NAVTREEINDEX =\n"; @@ -750,7 +751,7 @@ static void generateJSNavTree(const FTVNodes &nodeList) tsidx.close(); subIndex++; QCString fileName = htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js"; - tsidx.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + tsidx = Portable::openOutputStream(fileName); if (!tsidx.is_open()) break; tsidx << "var NAVTREEINDEX" << subIndex << " =\n"; tsidx << "{\n"; @@ -791,7 +792,7 @@ void FTVHelp::generateTreeViewScripts() // copy resize.js & navtree.css auto &mgr = ResourceMgr::instance(); { - std::ofstream f(htmlOutput.str()+"/resize.js",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(htmlOutput+"/resize.js"); if (f.is_open()) { TextStream t(&f); @@ -799,7 +800,7 @@ void FTVHelp::generateTreeViewScripts() } } { - std::ofstream f(htmlOutput.str()+"/navtree.css",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(htmlOutput+"/navtree.css"); if (f.is_open()) { TextStream t(&f); diff --git a/src/htags.cpp b/src/htags.cpp --- a/src/htags.cpp +++ b/src/htags.cpp @@ -123,7 +123,7 @@ bool Htags::loadFilemap(const QCString &htmlDir) */ if (fi.exists() && fi.isReadable()) { - std::ifstream f(fileMapName.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(fileMapName); if (f.is_open()) { std::string lineStr; diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -36,6 +36,7 @@ #include "fileinfo.h" #include "indexlist.h" #include "growbuf.h" +#include "portable.h" static const int NUM_HTML_LIST_TYPES = 4; static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}; @@ -605,7 +606,7 @@ void HtmlDocVisitor::operator()(const DocVerbatim &s) dotindex++, ".dot" ); - std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { err("Could not open file %s for writing\n",qPrint(fileName)); @@ -637,7 +638,7 @@ void HtmlDocVisitor::operator()(const DocVerbatim &s) qPrint(Config_getString(HTML_OUTPUT)+"/inline_mscgraph_"), mscindex++ ); - std::ofstream file(baseName.str()+".msc",std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(baseName.str()+".msc"); if (!file.is_open()) { err("Could not open file %s.msc for writing\n",qPrint(baseName)); diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -17,7 +17,6 @@ #include #include -#include #include "message.h" #include "htmlgen.h" @@ -55,6 +54,7 @@ #include "utf8.h" #include "textstream.h" #include "indexlist.h" +#include "portable.h" //#define DBG_HTML(x) x; #define DBG_HTML(x) @@ -1088,7 +1088,7 @@ void HtmlGenerator::init() tabsCss = mgr.getAsString("fixed_tabs.css"); } - std::ofstream f(dname.str()+"/tabs.css",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(dname+"/tabs.css"); if (f.is_open()) { TextStream t(&f); @@ -1111,7 +1111,7 @@ void HtmlGenerator::init() if (colorStyle==HTML_COLORSTYLE_t::TOGGLE) { //mgr.copyResource("darkmode_toggle.js",dname); - std::ofstream f(dname.str()+"/darkmode_toggle.js",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(dname+"/darkmode_toggle.js"); if (f.is_open()) { TextStream t(&f); @@ -1120,7 +1120,7 @@ void HtmlGenerator::init() } { - std::ofstream f(dname.str()+"/dynsections.js",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(dname+"/dynsections.js"); if (f.is_open()) { TextStream t(&f); @@ -1200,7 +1200,7 @@ void HtmlGenerator::writeSearchData(const QCString &dname) Doxygen::indexList->addImageFile("search/mag_seld.svg"); QCString searchDirName = dname; - std::ofstream f(searchDirName.str()+"/search.css",std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(searchDirName+"/search.css"); if (f.is_open()) { TextStream t(&f); @@ -2844,7 +2844,7 @@ void HtmlGenerator::writeSearchPage() // OPENSEARCH_PROVIDER { QCString configFileName = htmlOutput+"/search_config.php"; - std::ofstream f(configFileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(configFileName); if (f.is_open()) { TextStream t(&f); @@ -2875,7 +2875,7 @@ void HtmlGenerator::writeSearchPage() // OPENSEARCH_PROVIDER } QCString fileName = htmlOutput+"/search.php"; - f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(fileName); if (f.is_open()) { TextStream t(&f); @@ -2914,7 +2914,7 @@ void HtmlGenerator::writeSearchPage() f.close(); QCString scriptName = htmlOutput+"/search/search.js"; - f.open(scriptName.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(scriptName); if (f.is_open()) { TextStream t(&f); @@ -2931,7 +2931,7 @@ void HtmlGenerator::writeExternalSearchPage() bool generateTreeView = Config_getBool(GENERATE_TREEVIEW); QCString dname = Config_getString(HTML_OUTPUT); QCString fileName = dname+"/search"+Doxygen::htmlFileExtension; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (f.is_open()) { TextStream t(&f); @@ -2987,7 +2987,7 @@ void HtmlGenerator::writeExternalSearchPage() f.close(); QCString scriptName = dname+"/search/search.js"; - f.open(scriptName.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(scriptName); if (f.is_open()) { TextStream t(&f); diff --git a/src/htmlhelp.cpp b/src/htmlhelp.cpp --- a/src/htmlhelp.cpp +++ b/src/htmlhelp.cpp @@ -347,7 +347,7 @@ void HtmlHelp::initialize() /* open the contents file */ QCString fName = Config_getString(HTML_OUTPUT) + "/" + hhcFileName; - p->cts.open(fName.str(),std::ofstream::out | std::ofstream::binary); + p->cts = Portable::openOutputStream(fName); if (!p->cts.is_open()) { term("Could not open file %s for writing\n",qPrint(fName)); @@ -362,7 +362,7 @@ void HtmlHelp::initialize() /* open the index file */ fName = Config_getString(HTML_OUTPUT) + "/" + hhkFileName; - p->kts.open(fName.str(),std::ofstream::out | std::ofstream::binary); + p->kts = Portable::openOutputStream(fName); if (!p->kts.is_open()) { term("Could not open file %s for writing\n",qPrint(fName)); @@ -381,7 +381,7 @@ void HtmlHelp::Private::createProjectFile() { /* Write the project file */ QCString fName = Config_getString(HTML_OUTPUT) + "/" + hhpFileName; - std::ofstream t(fName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(fName); if (t.is_open()) { QCString hhcFile = "\"" + hhcFileName + "\""; diff --git a/src/index.cpp b/src/index.cpp --- a/src/index.cpp +++ b/src/index.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include @@ -49,6 +48,7 @@ #include "filename.h" #include "tooltip.h" #include "utf8.h" +#include "portable.h" #define MAX_ITEMS_BEFORE_MULTIPAGE_INDEX 200 #define MAX_ITEMS_BEFORE_QUICK_INDEX 30 @@ -5159,7 +5159,7 @@ static void writeMenuData() if (!Config_getBool(GENERATE_HTML) || Config_getBool(DISABLE_INDEX)) return; QCString outputDir = Config_getBool(HTML_OUTPUT); LayoutNavEntry *root = LayoutDocManager::instance().rootNavEntry(); - std::ofstream t(outputDir.str()+"/menudata.js",std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(outputDir+"/menudata.js"); if (t.is_open()) { t << JAVASCRIPT_LICENSE_TEXT; diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -1,9 +1,6 @@ /****************************************************************************** * - * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2022 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 @@ -39,6 +36,7 @@ #include "plantuml.h" #include "fileinfo.h" #include "regex.h" +#include "portable.h" const int maxLevels=5; static const char *secLabels[maxLevels] = @@ -436,7 +434,7 @@ void LatexDocVisitor::operator()(const DocVerbatim &s) dotindex++, ".dot" ); - std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { err("Could not open file %s for writing\n",qPrint(fileName)); @@ -463,11 +461,11 @@ void LatexDocVisitor::operator()(const DocVerbatim &s) qPrint(Config_getString(LATEX_OUTPUT)+"/inline_mscgraph_"), mscindex++ ); - std::string fileName = baseName.str()+".msc"; - std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + QCString fileName = baseName+".msc"; + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { - err("Could not open file %s for writing\n",fileName.c_str()); + err("Could not open file %s for writing\n",qPrint(fileName)); } else { @@ -479,7 +477,7 @@ void LatexDocVisitor::operator()(const DocVerbatim &s) writeMscFile(baseName, s); - if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } } break; diff --git a/src/latexgen.cpp b/src/latexgen.cpp --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -14,7 +14,6 @@ */ #include -#include #include "latexgen.h" #include "config.h" @@ -44,6 +43,7 @@ #include "portable.h" #include "fileinfo.h" #include "utf8.h" +#include "portable.h" static QCString g_header; static QCString g_footer; @@ -287,7 +287,7 @@ static void writeLatexMakefile() { bool generateBib = !CitationManager::instance().isEmpty(); QCString fileName=Config_getString(LATEX_OUTPUT)+"/Makefile"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { term("Could not open file %s for writing\n",qPrint(fileName)); @@ -393,7 +393,7 @@ static void writeMakeBat() QCString manual_file = "refman"; const int latex_count = 8; bool generateBib = !CitationManager::instance().isEmpty(); - std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(fileName); if (!t.is_open()) { term("Could not open file %s for writing\n",qPrint(fileName)); diff --git a/src/mangen.cpp b/src/mangen.cpp --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2022 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 @@ -19,18 +17,19 @@ nice introductions to groff and man pages. */ #include +#include #include "message.h" #include "mangen.h" #include "config.h" #include "util.h" #include "doxygen.h" -#include #include "docparser.h" #include "mandocvisitor.h" #include "language.h" #include "dir.h" #include "utf8.h" +#include "portable.h" static QCString getExtension() { @@ -444,7 +443,7 @@ void ManGenerator::startDoxyAnchor(const QCString &,const QCString &manName, FileInfo fi(fileName.str()); if (!fi.exists()) { - std::ofstream linkStream(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream linkStream = Portable::openOutputStream(fileName); if (linkStream.is_open()) { linkStream << ".so " << getSubdir() << "/" << buildFileName( manName ) << "\n"; diff --git a/src/msc.cpp b/src/msc.cpp --- a/src/msc.cpp +++ b/src/msc.cpp @@ -13,8 +13,6 @@ * */ -#include - #include "msc.h" #include "portable.h" #include "config.h" @@ -33,7 +31,7 @@ static const int maxCmdLine = 40960; static bool convertMapFile(TextStream &t,const QCString &mapName,const QCString &relPath, const QCString &context) { - std::ifstream f(mapName.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(mapName); if (!f.is_open()) { err("failed to open map file %s for inclusion in the docs!\n" diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -17,9 +17,6 @@ #include #include -#include -#include - #include "perlmodgen.h" #include "docparser.h" #include "docnode.h" @@ -41,6 +38,7 @@ #include "htmlentity.h" #include "emoji.h" #include "dir.h" +#include "portable.h" #define PERLOUTPUT_MAX_INDENTATION 40 @@ -2124,7 +2122,7 @@ bool PerlModGenerator::generatePerlModOutput() bool PerlModGenerator::createOutputFile(std::ofstream &f, const QCString &s) { - f.open(s.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(s); if (!f.is_open()) { err("Cannot open file %s for writing!\n", qPrint(s)); diff --git a/src/plantuml.cpp b/src/plantuml.cpp --- a/src/plantuml.cpp +++ b/src/plantuml.cpp @@ -233,7 +233,7 @@ static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, cachedContent = fileToString(puFileName); } - std::ofstream file(puFileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(puFileName); if (!file.is_open()) { err_full(nb.srcFile,nb.srcLine,"Could not open file %s for writing\n",puFileName.data()); diff --git a/src/portable.cpp b/src/portable.cpp --- a/src/portable.cpp +++ b/src/portable.cpp @@ -614,4 +614,26 @@ size_t Portable::recodeUtf8StringToW(const QCString &inputStr,uint16_t **outBuf) return len; } +//---------------------------------------------------------------------------------------- +// We need to do this part last as including filesystem.hpp earlier +// causes the code above to fail to compile on Windows. + +#include "filesystem.hpp" + +namespace fs = ghc::filesystem; + +std::ofstream Portable::openOutputStream(const QCString &fileName,bool append) +{ + std::ios_base::openmode mode = std::ofstream::out | std::ofstream::binary; + if (append) mode |= std::ofstream::app; + return std::ofstream(fs::path(fileName.str()), mode); +} + +std::ifstream Portable::openInputStream(const QCString &fileName,bool binary, bool openAtEnd) +{ + std::ios_base::openmode mode = std::ifstream::in | std::ifstream::binary; + if (binary) mode |= std::ios::binary; + if (openAtEnd) mode |= std::ios::ate; + return std::ifstream(fs::path(fileName.str()), mode); +} diff --git a/src/portable.h b/src/portable.h --- a/src/portable.h +++ b/src/portable.h @@ -5,6 +5,8 @@ #include #include +#include + #include "qcstring.h" class Buf; @@ -49,6 +51,8 @@ namespace Portable const char * devNull(); bool checkForExecutable(const QCString &fileName); size_t recodeUtf8StringToW(const QCString &inputStr,uint16_t **buf); + std::ofstream openOutputStream(const QCString &name,bool append=false); + std::ifstream openInputStream(const QCString &name,bool binary=false,bool openAtEnd=false); } diff --git a/src/qhp.cpp b/src/qhp.cpp --- a/src/qhp.cpp +++ b/src/qhp.cpp @@ -12,7 +12,6 @@ */ #include -#include #include #include #include @@ -27,6 +26,7 @@ #include "qhp.h" #include "textstream.h" #include "util.h" +#include "portable.h" static inline void writeIndent(TextStream &t,int indent) { @@ -207,7 +207,7 @@ void Qhp::initialize() .. */ QCString fileName = Config_getString(HTML_OUTPUT) + "/" + qhpFileName; - p->docFile.open( fileName.str(), std::ofstream::out | std::ofstream::binary); + p->docFile = Portable::openOutputStream(fileName); if (!p->docFile.is_open()) { term("Could not open file %s for writing\n", fileName.data()); diff --git a/src/resourcemgr.cpp b/src/resourcemgr.cpp --- a/src/resourcemgr.cpp +++ b/src/resourcemgr.cpp @@ -15,13 +15,13 @@ #include #include -#include #include "resourcemgr.h" #include "util.h" #include "version.h" #include "message.h" #include "config.h" +#include "portable.h" class ResourceMgr::Private { @@ -58,8 +58,8 @@ bool ResourceMgr::writeCategory(const QCString &categoryName,const QCString &tar Resource &res = kv.second; if (res.category==categoryName) { - std::string pathName = targetDir.str()+"/"+res.name; - std::ofstream f(pathName,std::ofstream::out | std::ofstream::binary); + QCString pathName = targetDir+"/"+res.name; + std::ofstream f = Portable::openOutputStream(pathName); bool ok=false; if (f.is_open()) { @@ -78,9 +78,7 @@ bool ResourceMgr::writeCategory(const QCString &categoryName,const QCString &tar bool ResourceMgr::copyResourceAs(const QCString &name,const QCString &targetDir,const QCString &targetName,bool append) const { - std::string pathName = targetDir.str()+"/"+targetName.str(); - std::ios_base::openmode mode = std::ofstream::out | std::ofstream::binary; - if (append) mode |= std::ofstream::app; + QCString pathName = targetDir+"/"+targetName; const Resource *res = get(name); if (res) { @@ -88,7 +86,7 @@ bool ResourceMgr::copyResourceAs(const QCString &name,const QCString &targetDir, { case Resource::Verbatim: { - std::ofstream f(pathName,mode); + std::ofstream f = Portable::openOutputStream(pathName,append); bool ok=false; if (f.is_open()) { @@ -139,7 +137,7 @@ bool ResourceMgr::copyResourceAs(const QCString &name,const QCString &targetDir, break; case Resource::CSS: { - std::ofstream t(pathName,mode); + std::ofstream t = Portable::openOutputStream(pathName,append); if (t.is_open()) { QCString buf(res->size+1); @@ -159,7 +157,7 @@ bool ResourceMgr::copyResourceAs(const QCString &name,const QCString &targetDir, break; case Resource::SVG: { - std::ofstream t(pathName,mode); + std::ofstream t = Portable::openOutputStream(pathName,append); if (t.is_open()) { QCString buf(res->size+1); diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -1,9 +1,6 @@ /****************************************************************************** * - * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2022 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 @@ -37,6 +34,7 @@ #include "emoji.h" #include "plantuml.h" #include "fileinfo.h" +#include "portable.h" //#define DBG_RTF(x) m_t << x #define DBG_RTF(x) do {} while(0) @@ -351,7 +349,7 @@ void RTFDocVisitor::operator()(const DocVerbatim &s) dotindex++, ".dot" ); - std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(fileName); if (!file.is_open()) { err("Could not open file %s for writing\n",qPrint(fileName)); @@ -380,7 +378,7 @@ void RTFDocVisitor::operator()(const DocVerbatim &s) mscindex++, ".msc" ); - std::ofstream file(baseName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream file = Portable::openOutputStream(baseName); if (!file.is_open()) { err("Could not open file %s for writing\n",qPrint(baseName)); diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -2050,7 +2050,7 @@ static void encodeForOutput(TextStream &t,const QCString &s) static bool preProcessFile(Dir &d,const QCString &infName, TextStream &t, bool bIncludeHeader=TRUE) { static bool rtfDebug = Debug::isFlagSet(Debug::Rtf); - std::ifstream f(infName.str(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(infName); if (!f.is_open()) { err("problems opening rtf file '%s' for reading\n",infName.data()); @@ -2220,7 +2220,7 @@ void testRTFOutput(const QCString &name) int bcount=0; int line=1; int c; - std::ifstream f(name.data(),std::ifstream::in); + std::ifstream f = Portable::openInputStream(name); if (f.is_open()) { while ((c=f.get())!=-1) @@ -2279,7 +2279,7 @@ bool RTFGenerator::preProcessFileInplace(const QCString &path,const QCString &na QCString combinedName = path+"/combined.rtf"; QCString mainRTFName = path+"/"+name; - std::ofstream f(combinedName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(combinedName); if (!f.is_open()) { err("Failed to open %s for writing!\n",combinedName.data()); diff --git a/src/searchindex.cpp b/src/searchindex.cpp --- a/src/searchindex.cpp +++ b/src/searchindex.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -32,6 +31,7 @@ #include "message.h" #include "groupdef.h" #include "filedef.h" +#include "portable.h" // file format: (all multi-byte values are stored in big endian format) @@ -318,7 +318,7 @@ void SearchIndex::write(const QCString &fileName) } //printf("Total size %x bytes (word=%x stats=%x urls=%x)\n",size,wordsOffset,statsOffset,urlsOffset); - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (f.is_open()) { // write header @@ -499,7 +499,7 @@ void SearchIndexExternal::addWord(const QCString &word,bool hiPriority) void SearchIndexExternal::write(const QCString &fileName) { - std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(fileName); if (t.is_open()) { t << "\n"; diff --git a/src/searchindex_js.cpp b/src/searchindex_js.cpp --- a/src/searchindex_js.cpp +++ b/src/searchindex_js.cpp @@ -15,7 +15,6 @@ #include #include -#include #include "searchindex_js.h" #include "doxygen.h" @@ -33,6 +32,7 @@ #include "message.h" #include "resourcemgr.h" #include "indexlist.h" +#include "portable.h" QCString searchName(const Definition *d) { @@ -409,7 +409,7 @@ void writeJavaScriptSearchIndex() QCString dataFileName = searchDirName + "/"+baseName+".js"; - std::ofstream ti(dataFileName.str(), std::ofstream::out | std::ofstream::binary); + std::ofstream ti = Portable::openOutputStream(dataFileName); if (ti.is_open()) { @@ -582,8 +582,7 @@ void writeJavaScriptSearchIndex() } { - std::ofstream t(searchDirName.str()+"/searchdata.js", - std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(searchDirName+"/searchdata.js"); if (t.is_open()) { t << "var indexSectionsWithContent =\n"; diff --git a/src/template.cpp b/src/template.cpp --- a/src/template.cpp +++ b/src/template.cpp @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include "message.h" #include "util.h" @@ -3893,7 +3891,7 @@ class TemplateNodeCreate : public TemplateNodeCreator outputFile.prepend(ci->outputDirectory()+"/"); } //printf("NoteCreate(%s)\n",qPrint(outputFile)); - std::ofstream f(outputFile.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(outputFile); if (f.is_open()) { TextStream ts(&f); @@ -5260,7 +5258,7 @@ class TemplateEngine::Private if (kv==m_templateCache.end()) // first time template is referenced { QCString filePath = m_templateDirName+"/"+fileName; - std::ifstream f(filePath.str(),std::ifstream::in | std::ifstream::binary); + std::ifstream f = Portable::openInputStream(filePath,true); if (f.is_open()) // read template from disk { FileInfo fi(filePath.str()); diff --git a/src/util.cpp b/src/util.cpp --- a/src/util.cpp +++ b/src/util.cpp @@ -6269,7 +6269,7 @@ bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSou QCString filterName = getFileFilter(fileName,isSourceCode); if (filterName.isEmpty() || !filter) { - std::ifstream f(fileName.str(),std::ifstream::in | std::ifstream::binary); + std::ifstream f = Portable::openInputStream(fileName,true); if (!f.is_open()) { err("could not open file %s\n",qPrint(fileName)); @@ -7195,7 +7195,7 @@ bool openOutputFile(const QCString &outFile,std::ofstream &f) dir.remove(backup.fileName()); dir.rename(fi.fileName(),fi.fileName()+".bak"); } - f.open(outFile.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(outFile); fileOpened = f.is_open(); } return fileOpened; diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -27,7 +27,6 @@ #include #include - /* --------------------------------------------------------------- */ // local includes @@ -188,7 +187,7 @@ void VhdlDocGen::writeOverview() QCString ov =Config_getString(HTML_OUTPUT); QCString fileName=ov+"/vhdl_design.dot"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Warning: Cannot open file %s for writing\n",qPrint(fileName)); @@ -3426,7 +3425,7 @@ void FlowChart::writeFlowChart() QCString ov = Config_getString(HTML_OUTPUT); QCString fileName = ov+"/flow_design.dot"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing\n",qPrint(fileName)); diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -47,6 +47,7 @@ #include "resourcemgr.h" #include "dir.h" #include "utf8.h" +#include "portable.h" // no debug info #define XML_DB(x) do {} while(0) @@ -162,7 +163,7 @@ static void writeCombineScript() { QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/combine.xslt"; - std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream t = Portable::openOutputStream(fileName); if (!t.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1271,7 +1272,7 @@ static void generateXMLForClass(const ClassDef *cd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+ classOutputFileBase(cd)+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1435,7 +1436,7 @@ static void generateXMLForConcept(const ConceptDef *cd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+cd->getOutputFileBase()+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1488,7 +1489,7 @@ static void generateXMLForNamespace(const NamespaceDef *nd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+nd->getOutputFileBase()+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1563,7 +1564,7 @@ static void generateXMLForFile(FileDef *fd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+fd->getOutputFileBase()+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1674,7 +1675,7 @@ static void generateXMLForGroup(const GroupDef *gd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+gd->getOutputFileBase()+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1729,7 +1730,7 @@ static void generateXMLForDir(DirDef *dd,TextStream &ti) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+dd->getOutputFileBase()+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1782,7 +1783,7 @@ static void generateXMLForPage(PageDef *pd,TextStream &ti,bool isExample) QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+pageName+".xml"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1915,7 +1916,7 @@ void generateXML() ResourceMgr::instance().copyResource("doxyfile.xsd",outputDirectory); QCString fileName=outputDirectory+"/compound.xsd"; - std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); + std::ofstream f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName)); @@ -1951,7 +1952,7 @@ void generateXML() f.close(); fileName=outputDirectory+"/Doxyfile.xml"; - f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing\n",fileName.data()); @@ -1965,7 +1966,7 @@ void generateXML() f.close(); fileName=outputDirectory+"/index.xml"; - f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + f = Portable::openOutputStream(fileName); if (!f.is_open()) { err("Cannot open file %s for writing!\n",qPrint(fileName));