* @brief Appends content to an 'AI/' file, creating it if needed. */
| 624 | * @brief Appends content to an 'AI/' file, creating it if needed. |
| 625 | */ |
| 626 | QJsonObject AI::FileSandbox::append(const QJsonObject& args) const |
| 627 | { |
| 628 | const auto resolved = resolveWrite(args.value(QStringLiteral("path")).toString()); |
| 629 | if (!resolved.ok) |
| 630 | return failure(resolved.error, resolved.hint); |
| 631 | |
| 632 | const auto payload = args.value(QStringLiteral("content")).toString().toUtf8(); |
| 633 | const QFileInfo info(resolved.path); |
| 634 | const qint64 existing = info.isFile() ? info.size() : 0; |
| 635 | if (existing + payload.size() > kMaxWriteBytes) |
| 636 | return failure(QStringLiteral("too_large"), |
| 637 | QStringLiteral("Resulting file would exceed the 4 MB cap.")); |
| 638 | |
| 639 | return writeBytes(resolved.path, payload, true, workspaceRoot()); |
| 640 | } |
| 641 | |
| 642 | //-------------------------------------------------------------------------------------------------- |
| 643 | // remove |