Forum

> > CS2D > Scripts > How to use io.enumdir
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to use io.enumdir

6 replies
To the start Previous 1 Next To the start

old How to use io.enumdir

Waldin
User Off Offline

Quote
Im trying to use this function but i get stack overflows and errors everytime, please help me, how may i use this function?
edited 1×, last 21.09.16 01:49:13 am

old Re: How to use io.enumdir

Zeik
User Off Offline

Quote
Where did you learn about its existance? I can't find that function anywhere.

EDIT:
I've found out it's only named in a changelog of CS2D. It doesn't say what it does nor how it works.
edited 2×, last 21.09.16 04:17:58 am

old Re: How to use io.enumdir

Cure Pikachu
User Off Offline

Quote
Is this how you experiment with the functions?
1
2
3
4
5
6
7
dir = "sys/lua/"
if io.isdir(dir) then
	print(dir.." is a directory")
	for file in io.enumdir(dir) do
		print(dir..""..file)
	end
end
edited 1×, last 21.09.16 07:09:46 am

old Re: How to use io.enumdir

VADemon
User Off Offline

Quote
Scans a directory and outputs files and directories.
Note that for this function dir must end with a forward slash.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function scanDir(dir)
	print("Scanning dir: ".. dir)
	
	for name in io.enumdir(dir) do
		if name ~= "." and name ~= ".." then
		
			if io.isdir(dir .. name) then
				--addDirQueue(dir .. name .."/")
				print(name)
			else
				--addFileQueue(dir .. name)
				print(name)
			end
			
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview