AP_Scripting: ignore hidden Lua files

On macOS, sometimes ._script.lua is created to store metadata when the
user copies script.lua over to their SD card. Previously, the scripting
engine would barf since the file is not Lua. Now, these files are
ignored.

Also avoids a case where a hidden and valid script might be loaded
without the user's knowledge.
This commit is contained in:
Thomas Watson 2024-06-30 12:20:05 -05:00 committed by Andrew Tridgell
parent e2ef47b221
commit 717c5ff863
1 changed files with 2 additions and 2 deletions

View File

@ -268,8 +268,8 @@ void lua_scripts::load_all_scripts_in_dir(lua_State *L, const char *dirname) {
continue; continue;
} }
if (strncmp(&de->d_name[length-4], ".lua", 4)) { if ((de->d_name[0] == '.') || strncmp(&de->d_name[length-4], ".lua", 4)) {
// doesn't end in .lua // starts with . (hidden file) or doesn't end in .lua
continue; continue;
} }