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)
bool GenericProject::addFiles(const QStringList &filePaths)
{
// Make sure we can open the file for writing
QFile file(filesFileName());
if (file.open(QFile::Append)) {
QTextStream stream(&file);
QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, filePaths) {
stream << baseDir.relativeFilePath(filePath) << "\n";
}
file.close();
refresh(GenericProject::Files);
return true;
}
return false;
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QStringList newFileList = m_files;
newFileList.append(filePaths);
QTextStream stream(&file);
QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, newFileList)
stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n');
file.close();
refresh(GenericProject::Files);
return true;
}
void GenericProject::parseProject(RefreshOptions options)
......
Markdown is supported
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