mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-05 05:26:55 +01:00
added directoryListFiles
This commit is contained in:
parent
bbfec42976
commit
6a1e98994c
2 changed files with 25 additions and 0 deletions
|
@ -16,9 +16,11 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "LuaEngineOS.h"
|
#include "LuaEngineOS.h"
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
LuaEngineOS::LuaEngineOS(QObject *parent, bool loadBaseLibraries) : LuaEngine(parent, loadBaseLibraries)
|
LuaEngineOS::LuaEngineOS(QObject *parent, bool loadBaseLibraries) : LuaEngine(parent, loadBaseLibraries)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +30,9 @@ LuaEngineOS::LuaEngineOS(QObject *parent, bool loadBaseLibraries) : LuaEngine(pa
|
||||||
|
|
||||||
void LuaEngineOS::pushClass(lua_State *L_p)
|
void LuaEngineOS::pushClass(lua_State *L_p)
|
||||||
{
|
{
|
||||||
|
// Directory
|
||||||
|
pushFunction(L_p, "directoryListFiles", directoryListFiles);
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
pushFunction(L_p, "executeProcess", executeProcess);
|
pushFunction(L_p, "executeProcess", executeProcess);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +42,25 @@ void LuaEngineOS::pushClass(LuaEngine *luaEngine)
|
||||||
pushClass(luaEngine->luaState());
|
pushClass(luaEngine->luaState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LuaEngineOS::directoryListFiles(lua_State *L_p)
|
||||||
|
{
|
||||||
|
if (getArgumentCount(L_p) >= 1) {
|
||||||
|
QStringList directories;
|
||||||
|
QStringList nameFilters;
|
||||||
|
QString directory = getVariant(L_p, 1).toString();
|
||||||
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
|
nameFilters << getVariant(L_p, 2).toString();
|
||||||
|
}
|
||||||
|
QDirIterator dirIterator(directory, nameFilters, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||||
|
while (dirIterator.hasNext()) {
|
||||||
|
directories << dirIterator.next();
|
||||||
|
}
|
||||||
|
pushVariant(L_p, directories.join('\n'));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int LuaEngineOS::executeProcess(lua_State *L_p)
|
int LuaEngineOS::executeProcess(lua_State *L_p)
|
||||||
{
|
{
|
||||||
if (getArgumentCount(L_p) >= 1) {
|
if (getArgumentCount(L_p) >= 1) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ public:
|
||||||
LuaEngineOS(QObject *parent = nullptr, bool loadBaseLibraries = true);
|
LuaEngineOS(QObject *parent = nullptr, bool loadBaseLibraries = true);
|
||||||
static void pushClass(lua_State *L_p);
|
static void pushClass(lua_State *L_p);
|
||||||
static void pushClass(LuaEngine *luaEngine);
|
static void pushClass(LuaEngine *luaEngine);
|
||||||
|
static int directoryListFiles(lua_State *L_p);
|
||||||
static int executeProcess(lua_State *L_p);
|
static int executeProcess(lua_State *L_p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue