Skip to content

Commit

Permalink
AP_Scripting: ignore hidden Lua files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tpwrules authored and tridge committed Jul 2, 2024
1 parent e2ef47b commit 717c5ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/AP_Scripting/lua_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ void lua_scripts::load_all_scripts_in_dir(lua_State *L, const char *dirname) {
continue;
}

if (strncmp(&de->d_name[length-4], ".lua", 4)) {
// doesn't end in .lua
if ((de->d_name[0] == '.') || strncmp(&de->d_name[length-4], ".lua", 4)) {
// starts with . (hidden file) or doesn't end in .lua
continue;
}

Expand Down

0 comments on commit 717c5ff

Please sign in to comment.