[keyboard] Check for successful file-write

This commit is contained in:
Adriaan de Groot 2020-11-04 13:39:23 +01:00
parent 2535d8ccbd
commit 3e51d77782

View File

@ -210,7 +210,11 @@ SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const
} }
// Write out the existing lines and replace the KEYMAP= line // Write out the existing lines and replace the KEYMAP= line
file.open( QIODevice::WriteOnly | QIODevice::Text ); if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
cError() << "Could not open" << file.fileName() << "for writing.";
return false;
}
QTextStream stream( &file ); QTextStream stream( &file );
bool found = false; bool found = false;
foreach ( const QString& existingLine, existingLines ) foreach ( const QString& existingLine, existingLines )
@ -243,7 +247,11 @@ bool
SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
{ {
QFile file( keyboardConfPath ); QFile file( keyboardConfPath );
file.open( QIODevice::WriteOnly | QIODevice::Text ); if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
cError() << "Could not open" << file.fileName() << "for writing.";
return false;
}
QTextStream stream( &file ); QTextStream stream( &file );
stream << "# Read and parsed by systemd-localed. It's probably wise not to edit this file\n" stream << "# Read and parsed by systemd-localed. It's probably wise not to edit this file\n"