Skip to content

Commit

Permalink
Added lispUploadFromPath to codeloader
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Nov 2, 2024
1 parent 85f5a58 commit 25795e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions QCodeEditor/resources/languages/qml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@
<name>ParamList</name>
<name>TcpHub</name>
<name>QMiniMp3</name>
<name>CodeLoader</name>
</section>
</root>
19 changes: 19 additions & 0 deletions codeloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,25 @@ bool CodeLoader::lispUpload(QString codeStr, QString editorPath)
return lispUpload(vb);
}

bool CodeLoader::lispUploadFromPath(QString path)
{
QFile f(path);
if (f.open(QIODevice::ReadOnly)) {
QFileInfo fi(f);
VByteArray lispData = lispPackImports(f.readAll(), fi.canonicalPath());
f.close();

if (!lispData.isEmpty()) {
bool ok = lispErase(lispData.size() + 100);
if (ok) {
return lispUpload(lispData);
}
}
}

return false;
}

bool CodeLoader::lispStream(VByteArray vb, qint8 mode)
{
if (!mVesc->isPortConnected()) {
Expand Down
1 change: 1 addition & 0 deletions codeloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CodeLoader : public QObject
QPair<QString, QList<QPair<QString, QByteArray> > > lispUnpackImports(QByteArray data);
bool lispUpload(VByteArray vb);
bool lispUpload(QString codeStr, QString editorPath = QDir::currentPath());
Q_INVOKABLE bool lispUploadFromPath(QString path);
bool lispStream(VByteArray vb, qint8 mode);
QString lispRead(QWidget *parent, QString &lispPath);

Expand Down

0 comments on commit 25795e5

Please sign in to comment.