Q_INVOKABLE
| 299 | |
| 300 | //Q_INVOKABLE |
| 301 | int ScriptAPI::writeFile(const QString& filename, const QString& content) const |
| 302 | { |
| 303 | // relative paths are taken to be relative to the folder containing the |
| 304 | // executing script's file |
| 305 | QDir scriptDir(QFileInfo(m_script->getFilename()).dir()); |
| 306 | QString path = scriptDir.absoluteFilePath(filename); |
| 307 | |
| 308 | if (!mayWriteFile(path, m_target)) |
| 309 | return ScriptAPI::SystemAccess_PermissionDenied; |
| 310 | |
| 311 | QFile fout(path); |
| 312 | qint64 numBytes = -1; |
| 313 | |
| 314 | if (!fout.open(QIODevice::WriteOnly | QIODevice::Text)) |
| 315 | return ScriptAPI::SystemAccess_Failed; |
| 316 | |
| 317 | numBytes = fout.write(content.toUtf8()); |
| 318 | fout.close(); |
| 319 | |
| 320 | return (numBytes < 0 ? ScriptAPI::SystemAccess_Failed : ScriptAPI::SystemAccess_OK); |
| 321 | } |
| 322 | |
| 323 | //Q_INVOKABLE |
| 324 | QMap<QString, QVariant> ScriptAPI::readFile(const QString& filename) const |
nothing calls this directly
no test coverage detected