Showing the changes to libraries/script-engine/src/FileScriptingInterface.cpp (1 of 84 files). Show all
Unified · Split
| @@ -22,9 +22,10 @@ · 21 unmodified lines | |||
| 22 | #include <QFileInfo> | 22 | #include <QFileInfo> |
| 23 | #include <quazip5/quazip.h> | 23 | #include <quazip5/quazip.h> |
| 24 | #include <quazip5/JlCompress.h> | 24 | #include <quazip5/JlCompress.h> |
| 25 | #include "ResourceManager.h" | ||
| 26 | 25 | ||
| 27 | #include "FileScriptingInterface.h" | 26 | #include "FileScriptingInterface.h" |
| 27 | #include "ResourceManager.h" | ||
| 28 | #include "ScriptEngineLogging.h" | ||
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent) { | 31 | FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent) { |
| @@ -32,26 +33,26 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent · 1 unmodified line | |||
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | void FileScriptingInterface::runUnzip(QString path, QUrl url) { | 35 | void FileScriptingInterface::runUnzip(QString path, QUrl url) { |
| 35 | qDebug() << "Url that was downloaded: " + url.toString(); | 36 | qCDebug(scriptengine) << "Url that was downloaded: " + url.toString(); |
| 36 | qDebug() << "Path where download is saved: " + path; | 37 | qCDebug(scriptengine) << "Path where download is saved: " + path; |
| 37 | QString fileName = "/" + path.section("/", -1); | 38 | QString fileName = "/" + path.section("/", -1); |
| 38 | QString tempDir = path; | 39 | QString tempDir = path; |
| 39 | tempDir.remove(fileName); | 40 | tempDir.remove(fileName); |
| 40 | qDebug() << "Temporary directory at: " + tempDir; | 41 | qCDebug(scriptengine) << "Temporary directory at: " + tempDir; |
| 41 | if (!isTempDir(tempDir)) { | 42 | if (!isTempDir(tempDir)) { |
| 42 | qDebug() << "Temporary directory mismatch; risk of losing files"; | 43 | qCDebug(scriptengine) << "Temporary directory mismatch; risk of losing files"; |
| 43 | return; | 44 | return; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | QString file = unzipFile(path, tempDir); | 47 | QString file = unzipFile(path, tempDir); |
| 47 | if (file != "") { | 48 | if (file != "") { |
| 48 | qDebug() << "Object file to upload: " + file; | 49 | qCDebug(scriptengine) << "Object file to upload: " + file; |
| 49 | QUrl url = QUrl::fromLocalFile(file); | 50 | QUrl url = QUrl::fromLocalFile(file); |
| 50 | emit unzipSuccess(url.toString()); | 51 | emit unzipSuccess(url.toString()); |
| 51 | } else { | 52 | } else { |
| 52 | qDebug() << "unzip failed"; | 53 | qCDebug(scriptengine) << "unzip failed"; |
| 53 | } | 54 | } |
| 54 | qDebug() << "Removing temporary directory at: " + tempDir; | 55 | qCDebug(scriptengine) << "Removing temporary directory at: " + tempDir; |
| 55 | QDir(tempDir).removeRecursively(); | 56 | QDir(tempDir).removeRecursively(); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| @@ -94,7 +95,7 @@ QString FileScriptingInterface::convertUrlToPath(QUrl url) { · 36 unmodified lines | |||
| 94 | QString newUrl; | 95 | QString newUrl; |
| 95 | QString oldUrl = url.toString(); | 96 | QString oldUrl = url.toString(); |
| 96 | newUrl = oldUrl.section("filename=", 1, 1); | 97 | newUrl = oldUrl.section("filename=", 1, 1); |
| 97 | qDebug() << "Filename should be: " + newUrl; | 98 | qCDebug(scriptengine) << "Filename should be: " + newUrl; |
| 98 | return newUrl; | 99 | return newUrl; |
| 99 | } | 100 | } |
| 100 | 101 | ||
| @@ -116,12 +117,12 @@ QString FileScriptingInterface::unzipFile(QString path, QString tempDir) { · 15 unmodified lines | |||
| 116 | QString target = tempDir + "/model_repo"; | 117 | QString target = tempDir + "/model_repo"; |
| 117 | QStringList list = JlCompress::extractDir(dirName, target); | 118 | QStringList list = JlCompress::extractDir(dirName, target); |
| 118 | 119 | ||
| 119 | qDebug() << list; | 120 | qCDebug(scriptengine) << list; |
| 120 | 121 | ||
| 121 | if (!list.isEmpty()) { | 122 | if (!list.isEmpty()) { |
| 122 | return list.front(); | 123 | return list.front(); |
| 123 | } else { | 124 | } else { |
| 124 | qDebug() << "Extraction failed"; | 125 | qCDebug(scriptengine) << "Extraction failed"; |
| 125 | return ""; | 126 | return ""; |
| 126 | } | 127 | } |
| 127 | 128 | ||
| @@ -130,13 +131,13 @@ QString FileScriptingInterface::unzipFile(QString path, QString tempDir) { · 2 unmodified lines | |||
| 130 | // this function is not in use | 131 | // this function is not in use |
| 131 | void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { | 132 | void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { |
| 132 | /*if (!file.isDir()) { | 133 | /*if (!file.isDir()) { |
| 133 | qDebug() << "Regular file logged: " + file.fileName(); | 134 | qCDebug(scriptengine) << "Regular file logged: " + file.fileName(); |
| 134 | return; | 135 | return; |
| 135 | }*/ | 136 | }*/ |
| 136 | QFileInfoList files; | 137 | QFileInfoList files; |
| 137 | 138 | ||
| 138 | if (file.fileName().contains(".zip")) { | 139 | if (file.fileName().contains(".zip")) { |
| 139 | qDebug() << "Extracting archive: " + file.fileName(); | 140 | qCDebug(scriptengine) << "Extracting archive: " + file.fileName(); |
| 140 | JlCompress::extractDir(file.fileName()); | 141 | JlCompress::extractDir(file.fileName()); |
| 141 | } | 142 | } |
| 142 | files = file.dir().entryInfoList(); | 143 | files = file.dir().entryInfoList(); |
| @@ -146,7 +147,7 @@ void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) · 3 unmodified lines | |||
| 146 | }*/ | 147 | }*/ |
| 147 | 148 | ||
| 148 | foreach (QFileInfo file, files) { | 149 | foreach (QFileInfo file, files) { |
| 149 | qDebug() << "Looking into file: " + file.fileName(); | 150 | qCDebug(scriptengine) << "Looking into file: " + file.fileName(); |
| 150 | recursiveFileScan(file, dirName); | 151 | recursiveFileScan(file, dirName); |
| 151 | } | 152 | } |
| 152 | return; | 153 | return; |