| 191 | } |
| 192 | |
| 193 | void appendSafe(const QString& filename, const QByteArray& data) |
| 194 | { |
| 195 | ensureExists(QFileInfo(filename).dir()); |
| 196 | QByteArray buffer; |
| 197 | try { |
| 198 | buffer = read(filename); |
| 199 | } catch (FileSystemException&) { |
| 200 | buffer = QByteArray(); |
| 201 | } |
| 202 | buffer.append(data); |
| 203 | PSaveFile file(filename); |
| 204 | if (!file.open(PSaveFile::WriteOnly)) { |
| 205 | throw FileSystemException("Couldn't open " + filename + " for writing: " + file.errorString()); |
| 206 | } |
| 207 | if (buffer.size() != file.write(buffer)) { |
| 208 | throw FileSystemException("Error writing data to " + filename + ": " + file.errorString()); |
| 209 | } |
| 210 | if (!file.commit()) { |
| 211 | throw FileSystemException("Error while committing data to " + filename + ": " + file.errorString()); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | void append(const QString& filename, const QByteArray& data) |
| 216 | { |
nothing calls this directly
no test coverage detected