From 78a80001223af290c7c7321ad2d210fb3cd16f11 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 19 Sep 2015 16:46:54 +0200 Subject: [Bug 755225] On Windows, generated layout is with UNIX EOL --- src/doxygen.cpp | 25 ------------------------- src/layout.cpp | 3 ++- src/util.cpp | 26 ++++++++++++++++++++++++++ src/util.h | 2 ++ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 841ad56..f92d8b4 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -9097,31 +9097,6 @@ static QCString fixSlashes(QCString &s) //---------------------------------------------------------------------------- -static bool openOutputFile(const char *outFile,QFile &f) -{ - bool fileOpened=FALSE; - bool writeToStdout=(outFile[0]=='-' && outFile[1]=='\0'); - if (writeToStdout) // write to stdout - { - fileOpened = f.open(IO_WriteOnly,stdout); - } - else // write to file - { - QFileInfo fi(outFile); - if (fi.exists()) // create a backup - { - QDir dir=fi.dir(); - QFileInfo backup(fi.fileName()+".bak"); - if (backup.exists()) // remove existing backup - dir.remove(backup.fileName()); - dir.rename(fi.fileName(),fi.fileName()+".bak"); - } - f.setName(outFile); - fileOpened = f.open(IO_WriteOnly|IO_Translate); - } - return fileOpened; -} - /*! Generate a template version of the configuration file. * If the \a shortList parameter is TRUE a configuration file without * comments will be generated. diff --git a/src/layout.cpp b/src/layout.cpp index 1f45631..2835e77 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -1397,7 +1397,8 @@ void LayoutDocManager::parse(QTextStream &t,const char *fileName) void writeDefaultLayoutFile(const char *fileName) { QFile f(fileName); - if (!f.open(IO_WriteOnly)) + bool ok = openOutputFile(fileName,f); + if (!ok) { err("Failed to open file %s for writing!\n",fileName); return; diff --git a/src/util.cpp b/src/util.cpp index e6ea287..3ea10ee 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -8559,3 +8559,29 @@ void initFilePattern(void) } } } + +bool openOutputFile(const char *outFile,QFile &f) +{ + bool fileOpened=FALSE; + bool writeToStdout=(outFile[0]=='-' && outFile[1]=='\0'); + if (writeToStdout) // write to stdout + { + fileOpened = f.open(IO_WriteOnly,stdout); + } + else // write to file + { + QFileInfo fi(outFile); + if (fi.exists()) // create a backup + { + QDir dir=fi.dir(); + QFileInfo backup(fi.fileName()+".bak"); + if (backup.exists()) // remove existing backup + dir.remove(backup.fileName()); + dir.rename(fi.fileName(),fi.fileName()+".bak"); + } + f.setName(outFile); + fileOpened = f.open(IO_WriteOnly|IO_Translate); + } + return fileOpened; +} + diff --git a/src/util.h b/src/util.h index 6c72594..51a5da1 100755 --- a/src/util.h +++ b/src/util.h @@ -57,6 +57,7 @@ class BufStr; class QFileInfo; class QStrList; class FTextStream; +class QFile; //-------------------------------------------------------------------- @@ -473,6 +474,7 @@ void convertProtectionLevel( bool mainPageHasTitle(); void initFilePattern(void); +bool openOutputFile(const char *outFile,QFile &f); #endif -- cgit v0.12