MCPcopy Create free account
hub / github.com/KDE/kdevelop / createNewFileAndWrite

Method createNewFileAndWrite

kdevplatform/util/filesystemhelpers.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <QStringList>
17
18bool FilesystemHelpers::createNewFileAndWrite(const QString& filePath,
19 const QByteArray& fileContents)
20{
21 QFile file(filePath);
22
23 if (!file.open(QIODevice::NewOnly)) {
24 qCritical() << Q_FUNC_INFO << file.error() << file.errorString();
25 return false;
26 }
27
28 if (!fileContents.isEmpty() && file.write(fileContents) == -1) {
29 qCritical() << Q_FUNC_INFO << file.error() << file.errorString();
30 return false;
31 }
32 return true;
33}
34
35QString FilesystemHelpers::makeAbsoluteCreateAndWrite(const QString& dirPath, QString& filePath,
36 const QByteArray& fileContents)

Callers

nothing calls this directly

Calls 5

openMethod · 0.45
errorMethod · 0.45
errorStringMethod · 0.45
isEmptyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected