MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / appendSafe

Function appendSafe

launcher/FileSystem.cpp:206–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206void 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
228void append(const QString& filename, const QByteArray& data)
229{

Callers

nothing calls this directly

Calls 10

ensureExistsFunction · 0.85
QFileInfoClass · 0.85
readFunction · 0.85
FileSystemExceptionClass · 0.85
dirMethod · 0.80
appendMethod · 0.80
openMethod · 0.80
errorStringMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected