lua-users home
lua-l archive

LuaInterface, Recursion and arrays

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi There,
I have the following function that should list all directory names under a specified root:
local listFiles
listFiles = function(name)
	Console.Error:WriteLine(name)
	local subdirs = luanet.System.IO.DirectoryInfo(name):GetDirectories()
	local subdir_count = subdirs:get_Length()
	local i
	for i = 0, subdir_count-1 do
		listFiles(subdirs[i].FullName)
	end
end
listFiles("c:\\test\\lua\\a")
My test directories are organized as follows:
c:\test\lua
c:\test\lua\a
c:\test\lua\a\aa
c:\test\lua\a\ab
c:\test\lua\b
when calling the function with "c:\test\lua\a" the following (correct) results are obtained:
c:\test\lua\a
c:\test\lua\a\aa
c:\test\lua\a\ab
but calling listFiles("c:\test\lua") causes a stack overflow exception. and only prints
c:\test\lua\a
over and over again...
I'm totally stuck, but probably some simple thing I'm missing. It looks like the subdirs variable is not correctly assigned a new array value..
Any ideas ?
Thanks in advance
Frank
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

AltStyle によって変換されたページ (->オリジナル) /