diff options
author | Alexander Holland <alexander.holland@live.de> | 2016-02-14 20:31:55 +0100 |
---|---|---|
committer | Alexander Holland <alexander.holland@live.de> | 2016-02-14 20:31:55 +0100 |
commit | e65838f2d0fde14e85ae7cc664da403376127663 (patch) | |
tree | 798502d5fc1786143304db98b94e1bf75b9fc0d1 /doc | |
parent | 260380be45a1db86ca373d89bfd4f6c2088fcb1b (diff) |
some doc for directory
Diffstat (limited to 'doc')
-rw-r--r-- | doc/base/classes.xml | 28 |
1 files changed, 27 insertions, 1 deletions
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 </class> <class name="Directory" inherits="Reference" category="Core"> <brief_description> + Directory type. </brief_description> - <description> + <description>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?") </description> <methods> <method name="open"> @@ -9590,28 +9607,34 @@ This approximation makes straight segments between each point, then subdivides t <argument index="0" name="path" type="String"> </argument> <description> +Opens a directory to work with. Needs a path, example "res://folder" </description> </method> <method name="list_dir_begin"> <return type="bool"> </return> <description> +Loads all file names of the current directory (prepares the get_next() function). </description> </method> <method name="get_next"> <return type="String"> </return> <description> +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. </description> </method> <method name="current_is_dir" qualifiers="const"> <return type="bool"> </return> <description> +Returns true if the current file you are looking at with get_next() is a directory or "." or ".." otherwise false. </description> </method> <method name="list_dir_end"> <description> +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. </description> </method> <method name="get_drive_count"> @@ -9634,12 +9657,14 @@ This approximation makes straight segments between each point, then subdivides t <argument index="0" name="todir" type="String"> </argument> <description> +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" </description> </method> <method name="get_current_dir"> <return type="String"> </return> <description> +Returns a path to the current directory, example: "res://folder" </description> </method> <method name="make_dir"> @@ -9672,6 +9697,7 @@ This approximation makes straight segments between each point, then subdivides t <argument index="0" name="name" type="String"> </argument> <description> +Returns true if directory exists otherwise false. Needs a path, example: "res://folder" </description> </method> <method name="get_space_left"> |