diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 0c7bbba85e..f6b9b9f446 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -9580,8 +9580,25 @@ This approximation makes straight segments between each point, then subdivides t + Directory type. - + Directory type. Is used to manage directories and their content (not restricted to the project folder). + +How to iterate through the files of a directory example: + +func dir(path): + var d = Directory.new() + if d.open( path )==0: + d.list_dir_begin() + var file_name = d.get_next() + while(file_name!=""): + if d.current_is_dir(): + print("Is directory: " + file_name) + else: + print("Is File:" + file_name) + file_name = d.get_next() + else: + print("Some open Error, maybe directory not found?") @@ -9590,28 +9607,34 @@ This approximation makes straight segments between each point, then subdivides t +Opens a directory to work with. Needs a path, example "res://folder" +Loads all file names of the current directory (prepares the get_next() function). +Is used to iterate through the files of the current directory. Returns the name(no path) of the current file/directory, it also contains "." and ".." . +Returns an empty String "" at the end of the list. +Returns true if the current file you are looking at with get_next() is a directory or "." or ".." otherwise false. +Run this to empty the list of remaining files in get_next(). You can use it to end the iteration, as soon as your goal is reached. @@ -9634,12 +9657,14 @@ This approximation makes straight segments between each point, then subdivides t +Needs a path or name to the next directory. When the target directory is in the current directory you can use "newfolder" otherwise you need the full path "res://currentfolder/newfolder" +Returns a path to the current directory, example: "res://folder" @@ -9672,6 +9697,7 @@ This approximation makes straight segments between each point, then subdivides t +Returns true if directory exists otherwise false. Needs a path, example: "res://folder"