some doc for directory

This commit is contained in:
Alexander Holland 2016-02-14 20:31:55 +01:00
parent 260380be45
commit e65838f2d0

View file

@ -9580,8 +9580,25 @@ This approximation makes straight segments between each point, then subdivides t
</class> </class>
<class name="Directory" inherits="Reference" category="Core"> <class name="Directory" inherits="Reference" category="Core">
<brief_description> <brief_description>
Directory type.
</brief_description> </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> </description>
<methods> <methods>
<method name="open"> <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 index="0" name="path" type="String">
</argument> </argument>
<description> <description>
Opens a directory to work with. Needs a path, example "res://folder"
</description> </description>
</method> </method>
<method name="list_dir_begin"> <method name="list_dir_begin">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Loads all file names of the current directory (prepares the get_next() function).
</description> </description>
</method> </method>
<method name="get_next"> <method name="get_next">
<return type="String"> <return type="String">
</return> </return>
<description> <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> </description>
</method> </method>
<method name="current_is_dir" qualifiers="const"> <method name="current_is_dir" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Returns true if the current file you are looking at with get_next() is a directory or "." or ".." otherwise false.
</description> </description>
</method> </method>
<method name="list_dir_end"> <method name="list_dir_end">
<description> <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> </description>
</method> </method>
<method name="get_drive_count"> <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 index="0" name="todir" type="String">
</argument> </argument>
<description> <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> </description>
</method> </method>
<method name="get_current_dir"> <method name="get_current_dir">
<return type="String"> <return type="String">
</return> </return>
<description> <description>
Returns a path to the current directory, example: "res://folder"
</description> </description>
</method> </method>
<method name="make_dir"> <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 index="0" name="name" type="String">
</argument> </argument>
<description> <description>
Returns true if directory exists otherwise false. Needs a path, example: "res://folder"
</description> </description>
</method> </method>
<method name="get_space_left"> <method name="get_space_left">