file.Find includes files with excess ~s for no reason.
1 replies, posted
[code]] lua_run PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lua~"))
> PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lua~"))...
1 = cl_entity.lua~
2 = sv_entity.lua~
] lua_run PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lu"))
> PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lu"))...
] lua_run PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lua"))
> PrintTable(file.FindInLua(GAMEMODE.LuaFolder.."/gamemode/core/libraries/*.lua"))...
1 = cl_chatbox.lua
2 = cl_entity.lua
3 = cl_entity.lua~
4 = cl_inventory.lua
5 = sh_help.lua
6 = sh_hook.lua
7 = sh_item.lua
8 = sh_laws.lua
9 = sh_log.lua
10 = sh_plugin.lua
11 = sh_team.lua
12 = sv_chatbox.lua
13 = sv_commands.lua
14 = sv_container.lua
15 = sv_entity.lua
16 = sv_entity.lua~
17 = sv_inventory.lua
18 = sv_item.lua
19 = sv_player.lua
20 = sv_propprotection.lua[/code]I've started sharing my lua files with my netbook so I can code when I get bored on the go.
However, since it uses linux, it has an annoying habit of creating backups with ~s on the end of their filename, which dropbox picks up and shares, meaning they end up in my gamemodes folder.
I wouldn't really care about this if it wasn't for the fact that file.FindInLua seems to think that sv_entity.lua~ matches the pattern "*.lua", which it quite clearly doesn't.
I tested if it was including anything after the pattern by searching for "*.lu", but that came up with nothing.
So why is this happening, and how do I stop it, other than routinely culling the unwanted files?
Try placing this in autorun:
[lua]local FindInLua = file.FindInLua
function file.FindInLua(path)
local tab = FindInLua(path)
local ext = path:match(".+%.(.+)$")
if not ext then
return tab
end
for k, f in ipairs(tab) do
if !f:find(".+%."..ext.."&") then
table.remove(tab, k)
end
end
return tab
end[/lua]
Untested code, so probably fails.
Sorry, you need to Log In to post a reply to this thread.