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 committed Jun 30, 2024
1 parent 077c5f3 commit 8d7d7f0
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 8d7d7f0

Please sign in to comment.