mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-09-06 00:42:05 +02:00
add getDirectoryPath
This commit is contained in:
parent
e1c5e46af5
commit
be98a790e5
8 changed files with 93 additions and 13 deletions
|
@ -17,7 +17,6 @@
|
|||
|
||||
QT += widgets
|
||||
TARGET = luaengine
|
||||
win32: TARGET = LuaEngine
|
||||
CONFIG += c++11
|
||||
VERSION = 0.1
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (arguments.length() >= 2) {
|
||||
QVariant rtPath = arguments.first();
|
||||
arguments.removeFirst();
|
||||
QFile luaScript(arguments.first().toString());
|
||||
if (!luaScript.open(QIODevice::ReadOnly)) {
|
||||
|
@ -60,6 +61,7 @@ int main(int argc, char *argv[])
|
|||
LuaEngineGui luaEngineGui;
|
||||
LuaEngineIO::pushClass(&luaEngineGui);
|
||||
LuaEngineOS::pushClass(&luaEngineGui);
|
||||
luaEngineGui.pushVariant("_LuaEngineRT", rtPath);
|
||||
luaEngineGui.executeLuaScript(luaScript.readAll());
|
||||
|
||||
if (luaEngineGui.executeLuaFunction("main", arguments, true)) {
|
||||
|
|
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
#else
|
||||
{
|
||||
QFile executable(a.arguments().at(0));
|
||||
QFile executable(a.arguments().first());
|
||||
if (executable.open(QIODevice::ReadOnly)) {
|
||||
qint64 executableSize = executable.size();
|
||||
executable.seek(executableSize - 6);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "LuaEngineIO.h"
|
||||
#include <QDirIterator>
|
||||
#include <QTextStream>
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
|
@ -38,6 +39,7 @@ void LuaEngineIO::pushClass(lua_State *L_p)
|
|||
{
|
||||
// Directory
|
||||
pushFunction(L_p, "directoryListFiles", directoryListFiles);
|
||||
pushFunction(L_p, "getDirectoryPath", getDirectoryPath);
|
||||
|
||||
// File
|
||||
pushFunction(L_p, "linkFile", linkFile);
|
||||
|
@ -102,6 +104,18 @@ int LuaEngineIO::linkFile(lua_State *L_p)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LuaEngineIO::getDirectoryPath(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
QFileInfo fileInfo(getVariant(L_p, 1).toString());
|
||||
if (fileInfo.exists()) {
|
||||
pushVariant(L_p, fileInfo.absoluteDir().absolutePath());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString LuaEngineIO::nameForPointer(void *pointer)
|
||||
{
|
||||
QString nameStorage;
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
static void pushClass(LuaEngine *luaEngine);
|
||||
static int directoryListFiles(lua_State *L_p);
|
||||
static int linkFile(lua_State *L_p);
|
||||
static int getDirectoryPath(lua_State *L_p);
|
||||
|
||||
private:
|
||||
lua_State *L;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue