file.finddir broken?

so i’ve been trying to use this function with no results, i’m sure i used it in the past, when i last got into lua, however it seems to be just erroring now

has it been depreciated or something?
i’ve tried the sample script on the wiki page of resource.addfile along with some obvious tests, such as something like
local temptable=file.finddir
printtable(temptable)

just from putting “lua_run file.FindDir(”/*") i get the error “[ERROR] lua_run:1: attempt to call field ‘FindDir’ (a nil value)” and similar errors in places such as init.lua for gamemodes
i also tried looking through the change notes for the file library for gmod13, it said some functions had changed but couldnt find anything on finddir
also wanted to search the forums for anyone else asking this question, but i guess search is disabled

anyway i can live without the function, it’s just that i’ll be adding alot of custom materials/models and would save time if i could automate resource adding

any help is appreciated

local files, dirs = file.Find("/*")

Now, use file.Find(“DIR”, “DATA”)
DIR = The Folder name
DATA = The Root Folder (data,mod,materials,models)

I don’t understand. Im having the same problem.

[editline]27th December 2012[/editline]

function AddDir(dir)
local list = file.Find("*", dir)
for _, fdir in pairs(list) do
if fdir != “.svn” then
AddDir(dir…"/"…fdir)
end
end

for k,v in pairs(file.Find("*", "/"..dir.."/*")) do
    resource.AddFile(dir.."/"..v)
end

end

AddDir(“donator/models/materials/models/player/merc”)
AddDir(“donator/models/models/player”)
AddDir(“donator/models/lua”)

Doesn’t work for me.

I haven’t used the new file searching but this should work:

[lua]function AddDir(dir)

local files, dirs = file.Find(dir…"/*", GAME)

for _, fdir in pairs(dirs) do
if fdir != “.svn” then
AddDir(dir…"/"…fdir)
end
end

for k,v in pairs(files) do
resource.AddFile(dir…"/"…v)
end

end

AddDir(“materials/donator/models/materials/models/player/merc”)
AddDir(“models/donator/models/models/player”)
AddDir(“WHATEVER/donator/models/lua”)
[/lua]

Note it searches from the base game folder so you need to add in the first folder on the bottom lines (e.g. materials, maps etc)

Hi, just got your message. That bit of code is incorrect, it says invalid argument 2, expected string (Im assuming thats where you put GAME in the code, but im not sure what to replace it with.)

[LUA]
function AddDir(dir)

local files, dirs = file.Find(dir…"/*", “GAME”)

for _, fdir in pairs(dirs) do
if fdir != “.svn” then
AddDir(dir…"/"…fdir)
end
end

for k,v in pairs(files) do
resource.AddFile(dir…"/"…v)
end

end

AddDir(“materials/donator/models/materials/models/player/merc”)
AddDir(“models/donator/models/models/player”)
AddDir(“WHATEVER/donator/models/lua”)
[/LUA]