directoyListFiles generates now a table

This commit is contained in:
Syping 2019-10-01 05:28:37 +02:00
parent 6a1e98994c
commit 98f65a669f
2 changed files with 13 additions and 1 deletions

View file

@ -210,6 +210,18 @@ void LuaEngine::pushVariant(lua_State *L_p, const QVariant &variant)
else if (variant.type() == QVariant::String) {
lua_pushstring(L_p, variant.toString().toUtf8().data());
}
else if (variant.type() == QVariant::StringList) {
QStringList stringList = variant.toStringList();
lua_createtable(L_p, 0, stringList.count());
int top = lua_gettop(L_p);
int currentId = 1;
for (const QString &string : stringList) {
lua_pushnumber(L_p, currentId);
lua_pushstring(L_p, string.toUtf8().data());
lua_settable(L_p, top);
currentId++;
}
}
else if ((QMetaType::Type)variant.type() == QMetaType::Void || (QMetaType::Type)variant.type() == QMetaType::VoidStar) {
lua_pushlightuserdata(L_p, variant.value<void*>());
}

View file

@ -55,7 +55,7 @@ int LuaEngineOS::directoryListFiles(lua_State *L_p)
while (dirIterator.hasNext()) {
directories << dirIterator.next();
}
pushVariant(L_p, directories.join('\n'));
pushVariant(L_p, directories);
return 1;
}
return 0;