Skip to content

Commit

Permalink
[Bug 755225] On Windows, generated layout is with UNIX EOL
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Sep 19, 2015
1 parent 0aa2734 commit 78a8000
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
25 changes: 0 additions & 25 deletions src/doxygen.cpp
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/layout.cpp
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions src/util.cpp
Expand Up @@ -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;
}

2 changes: 2 additions & 0 deletions src/util.h
Expand Up @@ -57,6 +57,7 @@ class BufStr;
class QFileInfo;
class QStrList;
class FTextStream;
class QFile;

//--------------------------------------------------------------------

Expand Down Expand Up @@ -473,6 +474,7 @@ void convertProtectionLevel(

bool mainPageHasTitle();
void initFilePattern(void);
bool openOutputFile(const char *outFile,QFile &f);

#endif

0 comments on commit 78a8000

Please sign in to comment.