mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-02 00:36:42 +00:00
[Server] Fix getCaseInsensitiveFilename, simplify Players.size()
This commit is contained in:
parent
378d30834b
commit
b7e5e77166
2 changed files with 4 additions and 4 deletions
|
@ -19,9 +19,7 @@ void Players::Init(LuaState &lua)
|
||||||
func(player);
|
func(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
playersTable.set_function("size", [](){
|
playersTable.set_function("size", &Players::size);
|
||||||
return store.size();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -145,13 +145,15 @@ LuaState::LuaState()
|
||||||
lua->set_function("getCaseInsensitiveFilename", [](const char *folderPath, const char *filename) {
|
lua->set_function("getCaseInsensitiveFilename", [](const char *folderPath, const char *filename) {
|
||||||
if (!boost::filesystem::exists(folderPath)) return "invalid";
|
if (!boost::filesystem::exists(folderPath)) return "invalid";
|
||||||
|
|
||||||
|
static std::string foundFilename;
|
||||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
||||||
|
|
||||||
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
|
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
|
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
|
||||||
{
|
{
|
||||||
return itr->path().filename().string().c_str();
|
foundFilename = itr->path().filename().string();
|
||||||
|
return foundFilename.c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
Loading…
Reference in a new issue