Last active
December 19, 2015 09:59
-
-
Save m1el/5937163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/ariya/phantomjs.git | |
cd phantomjs | |
git checkout f6abcfe67620f8fdceae89cc4ba0451c37a3ef9d | |
wget https://gist.github.com/m1el/5937163/raw/68f1b1f34296ccf68008c1c0b28bdb1faf3371fe/phantomjs-exec-patch.diff | |
patch -p1 < phantomjs-exec-patch.diff | |
# configure, make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/build.sh b/build.sh | |
index 44a1d91..3816267 100755 | |
--- a/build.sh | |
+++ b/build.sh | |
@@ -88,4 +88,4 @@ fi | |
cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS --qt-config "$QT_CFG" && cd ../.. | |
src/qt/bin/qmake $QMAKE_ARGS | |
-make -j$COMPILE_JOBS | |
+make -j$COMPILE_JOBS CC=gcc-4.6 CXX=g++-4.6 | |
diff --git a/src/filesystem.cpp b/src/filesystem.cpp | |
index 938fa60..f449031 100644 | |
--- a/src/filesystem.cpp | |
+++ b/src/filesystem.cpp | |
@@ -34,6 +34,7 @@ | |
#include <QDir> | |
#include <QDebug> | |
#include <QDateTime> | |
+#include <QProcess> | |
// File | |
// public: | |
@@ -331,6 +332,33 @@ bool FileSystem::_removeTree(const QString &path) const | |
return true; | |
} | |
+QVariant FileSystem::exec(const QString cmd) const | |
+{ | |
+ return FileSystem::exec(cmd, QStringList(), QString("")); | |
+} | |
+ | |
+QVariant FileSystem::exec(const QString cmd, const QStringList args) const | |
+{ | |
+ return FileSystem::exec(cmd, args, QString("")); | |
+} | |
+ | |
+QVariant FileSystem::exec(const QString cmd, const QStringList args, const QString in) const | |
+{ | |
+ QProcess prog; | |
+ prog.start(cmd, args); | |
+ if (!prog.waitForStarted()) | |
+ return QVariant::Invalid; | |
+ QString in_ = in; | |
+ prog.write(in.toLocal8Bit()); | |
+ prog.closeWriteChannel(); | |
+ | |
+ if (!prog.waitForFinished()) | |
+ return QVariant::Invalid; | |
+ | |
+ QByteArray result = prog.readAll(); | |
+ return QString(result); | |
+} | |
+ | |
QStringList FileSystem::list(const QString &path) const | |
{ | |
return QDir(path).entryList(); | |
@@ -451,6 +479,7 @@ void FileSystem::initCompletions() | |
addCompletion("workingDirectory"); | |
// functions | |
addCompletion("list"); | |
+ addCompletion("exec"); | |
addCompletion("absolute"); | |
addCompletion("readLink"); | |
addCompletion("exists"); | |
diff --git a/src/filesystem.h b/src/filesystem.h | |
index 346f62f..f3f3d1f 100644 | |
--- a/src/filesystem.h | |
+++ b/src/filesystem.h | |
@@ -109,6 +109,9 @@ public slots: | |
// Listing | |
QStringList list(const QString &path) const; | |
+ QVariant exec(const QString cmd) const; | |
+ QVariant exec(const QString cmd, const QStringList args) const; | |
+ QVariant exec(const QString cmd, const QStringList args, const QString in) const; | |
// Paths | |
QString separator() const; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment