Commit b210943b authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Fixed a problem with adding files when final newline is missing

When there was no final newline in the .files file, the name of the
first new file would get appended to the name of the last file. This
patch fixes that by simply rewriting the whole file.

Also switched to writing out native line endings.
parent 79e21086
...@@ -170,18 +170,22 @@ static QStringList readLines(const QString &absoluteFileName) ...@@ -170,18 +170,22 @@ static QStringList readLines(const QString &absoluteFileName)
bool GenericProject::addFiles(const QStringList &filePaths) bool GenericProject::addFiles(const QStringList &filePaths)
{ {
// Make sure we can open the file for writing
QFile file(filesFileName()); QFile file(filesFileName());
if (file.open(QFile::Append)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QStringList newFileList = m_files;
newFileList.append(filePaths);
QTextStream stream(&file); QTextStream stream(&file);
QDir baseDir(QFileInfo(m_fileName).dir()); QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, filePaths) { foreach (const QString &filePath, newFileList)
stream << baseDir.relativeFilePath(filePath) << "\n"; stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n');
}
file.close(); file.close();
refresh(GenericProject::Files); refresh(GenericProject::Files);
return true; return true;
}
return false;
} }
void GenericProject::parseProject(RefreshOptions options) void GenericProject::parseProject(RefreshOptions options)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment