Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -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))
QTextStream stream(&file); return false;
QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, filePaths) { QStringList newFileList = m_files;
stream << baseDir.relativeFilePath(filePath) << "\n"; newFileList.append(filePaths);
}
file.close(); QTextStream stream(&file);
refresh(GenericProject::Files); QDir baseDir(QFileInfo(m_fileName).dir());
return true; foreach (const QString &filePath, newFileList)
} stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n');
return false;
file.close();
refresh(GenericProject::Files);
return true;
} }
void GenericProject::parseProject(RefreshOptions options) void GenericProject::parseProject(RefreshOptions options)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment