From b738668e9c3ecca95d61b931478945ced4049923 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Tue, 22 Nov 2022 11:58:30 +0800 Subject: [PATCH] Only show deprecation notice of using slash in require if the file is found. --- src/modules/filesystem/wrap_Filesystem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/filesystem/wrap_Filesystem.cpp b/src/modules/filesystem/wrap_Filesystem.cpp index c90d9495e..bce02af5a 100644 --- a/src/modules/filesystem/wrap_Filesystem.cpp +++ b/src/modules/filesystem/wrap_Filesystem.cpp @@ -866,9 +866,7 @@ static void replaceAll(std::string &str, const std::string &substr, const std::s int loader(lua_State *L) { std::string modulename = luax_checkstring(L, 1); - - if (modulename.find('/') != std::string::npos) - luax_markdeprecated(L, 2, "character in require string (forward slashes), use dots instead.", API_CUSTOM); + bool hasSlash = modulename.find('/') != std::string::npos; for (char &c : modulename) { @@ -884,6 +882,9 @@ int loader(lua_State *L) Filesystem::Info info = {}; if (inst->getInfo(element.c_str(), info) && info.type != Filesystem::FILETYPE_DIRECTORY) { + if (hasSlash) + luax_markdeprecated(L, 2, "character in require string (forward slashes), use dots instead.", API_CUSTOM); + lua_pop(L, 1); lua_pushstring(L, element.c_str()); return w_load(L);