Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lua-functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ using namespace luabridge;
#include "SDL_syswm.h"
#include <vector>
#include <algorithm>
#include <regex>

int listDirectoryFull(lua_State *L, int mode) {
const char *dirname = lua_tostring(L, 1);

lua_newtable(L);

if (!lua_isstring(L, 1))
return 1;

const char *dirname = lua_tostring(L, 1);

WIN32_FIND_DATAA fdFile;
HANDLE handle = NULL;

std::string path = format(".\\%s\\*.*", dirname);
std::regex startsWithDriveLetter("^.:.*$");
std::string path;

if (!std::regex_match(dirname, startsWithDriveLetter))
path = format(".\\%s\\*.*", dirname);
else
path = format("%s\\*.*", dirname);

if((handle = FindFirstFileA(path.c_str(), &fdFile)) == INVALID_HANDLE_VALUE) {
return 1;
}
Expand Down