| 204 | } |
| 205 | |
| 206 | void appendSafe(const QString& filename, const QByteArray& data) |
| 207 | { |
| 208 | ensureExists(QFileInfo(filename).dir()); |
| 209 | QByteArray buffer; |
| 210 | try { |
| 211 | buffer = read(filename); |
| 212 | } catch (FileSystemException&) { |
| 213 | buffer = QByteArray(); |
| 214 | } |
| 215 | buffer.append(data); |
| 216 | PSaveFile file(filename); |
| 217 | if (!file.open(PSaveFile::WriteOnly)) { |
| 218 | throw FileSystemException("Couldn't open " + filename + " for writing: " + file.errorString()); |
| 219 | } |
| 220 | if (buffer.size() != file.write(buffer)) { |
| 221 | throw FileSystemException("Error writing data to " + filename + ": " + file.errorString()); |
| 222 | } |
| 223 | if (!file.commit()) { |
| 224 | throw FileSystemException("Error while committing data to " + filename + ": " + file.errorString()); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void append(const QString& filename, const QByteArray& data) |
| 229 | { |
nothing calls this directly
no test coverage detected