mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-09-08 01:42:04 +02:00
add getDirectoryPath
This commit is contained in:
parent
e1c5e46af5
commit
be98a790e5
8 changed files with 93 additions and 13 deletions
|
@ -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