fix: new text file

This commit is contained in:
kateleet 2021-12-27 01:39:12 +08:00
parent d733c9d55c
commit 3ba1d05073

View file

@ -932,13 +932,13 @@ void FolderModel::newTextFile()
m_newDocumentUrl = QUrl(rootItem().url().toString() + "/" + newName);
QFile srcFile(":/templates/TextFile.txt");
if (!srcFile.open(QIODevice::ReadOnly)) {
return;
QFile file(m_newDocumentUrl.toLocalFile());
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream stream(&file);
stream << "\n";
::chmod(m_newDocumentUrl.toLocalFile().toStdString().c_str(), 0700);
file.close();
}
srcFile.copy(m_newDocumentUrl.toLocalFile());
}
void FolderModel::rename(int row, const QString &name)