123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/DirAccess.xml.
- .. _class_DirAccess:
- DirAccess
- =========
- **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
- Provides methods for managing directories and their content.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- This class is used to manage directories and their content, even outside of the project folder.
- \ **DirAccess** can't be instantiated directly. Instead it is created with a static method that takes a path for which it will be opened.
- Most of the methods have a static alternative that can be used without creating a **DirAccess**. Static methods only support absolute paths (including ``res://`` and ``user://``).
- ::
- # Standard
- var dir = DirAccess.open("user://levels")
- dir.make_dir("world1")
- # Static
- DirAccess.make_dir_absolute("user://levels/world1")
- \ **Note:** Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. Use :ref:`ResourceLoader<class_ResourceLoader>` to access imported resources.
- Here is an example on how to iterate through the files of a directory:
- .. tabs::
- .. code-tab:: gdscript
- func dir_contents(path):
- var dir = DirAccess.open(path)
- if dir:
- dir.list_dir_begin()
- var file_name = dir.get_next()
- while file_name != "":
- if dir.current_is_dir():
- print("Found directory: " + file_name)
- else:
- print("Found file: " + file_name)
- file_name = dir.get_next()
- else:
- print("An error occurred when trying to access the path.")
- .. code-tab:: csharp
- public void DirContents(string path)
- {
- using var dir = DirAccess.Open(path);
- if (dir != null)
- {
- dir.ListDirBegin();
- string fileName = dir.GetNext();
- while (fileName != "")
- {
- if (dir.CurrentIsDir())
- {
- GD.Print($"Found directory: {fileName}");
- }
- else
- {
- GD.Print($"Found file: {fileName}");
- }
- fileName = dir.GetNext();
- }
- }
- else
- {
- GD.Print("An error occurred when trying to access the path.");
- }
- }
- .. rst-class:: classref-introduction-group
- Tutorials
- ---------
- - :doc:`File system <../tutorials/scripting/filesystem>`
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +-------------------------+----------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`include_hidden<class_DirAccess_property_include_hidden>` |
- +-------------------------+----------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`include_navigational<class_DirAccess_property_include_navigational>` |
- +-------------------------+----------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`change_dir<class_DirAccess_method_change_dir>` **(** :ref:`String<class_String>` to_dir **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`copy<class_DirAccess_method_copy>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`int<class_int>` chmod_flags=-1 **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`copy_absolute<class_DirAccess_method_copy_absolute>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`int<class_int>` chmod_flags=-1 **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`current_is_dir<class_DirAccess_method_current_is_dir>` **(** **)** |const| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`dir_exists<class_DirAccess_method_dir_exists>` **(** :ref:`String<class_String>` path **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`dir_exists_absolute<class_DirAccess_method_dir_exists_absolute>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`file_exists<class_DirAccess_method_file_exists>` **(** :ref:`String<class_String>` path **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_current_dir<class_DirAccess_method_get_current_dir>` **(** :ref:`bool<class_bool>` include_drive=true **)** |const| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_current_drive<class_DirAccess_method_get_current_drive>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_directories<class_DirAccess_method_get_directories>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_directories_at<class_DirAccess_method_get_directories_at>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_drive_count<class_DirAccess_method_get_drive_count>` **(** **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_drive_name<class_DirAccess_method_get_drive_name>` **(** :ref:`int<class_int>` idx **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_files<class_DirAccess_method_get_files>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_files_at<class_DirAccess_method_get_files_at>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_next<class_DirAccess_method_get_next>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_open_error<class_DirAccess_method_get_open_error>` **(** **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_space_left<class_DirAccess_method_get_space_left>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_case_sensitive<class_DirAccess_method_is_case_sensitive>` **(** :ref:`String<class_String>` path **)** |const| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`list_dir_begin<class_DirAccess_method_list_dir_begin>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`list_dir_end<class_DirAccess_method_list_dir_end>` **(** **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`make_dir<class_DirAccess_method_make_dir>` **(** :ref:`String<class_String>` path **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`make_dir_absolute<class_DirAccess_method_make_dir_absolute>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`make_dir_recursive<class_DirAccess_method_make_dir_recursive>` **(** :ref:`String<class_String>` path **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`make_dir_recursive_absolute<class_DirAccess_method_make_dir_recursive_absolute>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`DirAccess<class_DirAccess>` | :ref:`open<class_DirAccess_method_open>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`remove<class_DirAccess_method_remove>` **(** :ref:`String<class_String>` path **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`remove_absolute<class_DirAccess_method_remove_absolute>` **(** :ref:`String<class_String>` path **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`rename<class_DirAccess_method_rename>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`rename_absolute<class_DirAccess_method_rename_absolute>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |static| |
- +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_DirAccess_property_include_hidden:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **include_hidden**
- .. rst-class:: classref-property-setget
- - void **set_include_hidden** **(** :ref:`bool<class_bool>` value **)**
- - :ref:`bool<class_bool>` **get_include_hidden** **(** **)**
- If ``true``, hidden files are included when navigating the directory.
- Affects :ref:`list_dir_begin<class_DirAccess_method_list_dir_begin>`, :ref:`get_directories<class_DirAccess_method_get_directories>` and :ref:`get_files<class_DirAccess_method_get_files>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_property_include_navigational:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **include_navigational**
- .. rst-class:: classref-property-setget
- - void **set_include_navigational** **(** :ref:`bool<class_bool>` value **)**
- - :ref:`bool<class_bool>` **get_include_navigational** **(** **)**
- If ``true``, ``.`` and ``..`` are included when navigating the directory.
- Affects :ref:`list_dir_begin<class_DirAccess_method_list_dir_begin>` and :ref:`get_directories<class_DirAccess_method_get_directories>`.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_DirAccess_method_change_dir:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **change_dir** **(** :ref:`String<class_String>` to_dir **)**
- Changes the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. ``newdir`` or ``../newdir``), or an absolute path (e.g. ``/tmp/newdir`` or ``res://somedir/newdir``).
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- \ **Note:** The new directory must be within the same scope, e.g. when you had opened a directory inside ``res://``, you can't change it to ``user://`` directory. If you need to open a directory in another access scope, use :ref:`open<class_DirAccess_method_open>` to create a new instance instead.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_copy:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **copy** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`int<class_int>` chmod_flags=-1 **)**
- Copies the ``from`` file to the ``to`` destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten.
- If ``chmod_flags`` is different than ``-1``, the Unix permissions for the destination path will be set to the provided value, if available on the current operating system.
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_copy_absolute:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **copy_absolute** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`int<class_int>` chmod_flags=-1 **)** |static|
- Static version of :ref:`copy<class_DirAccess_method_copy>`. Supports only absolute paths.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_current_is_dir:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **current_is_dir** **(** **)** |const|
- Returns whether the current item processed with the last :ref:`get_next<class_DirAccess_method_get_next>` call is a directory (``.`` and ``..`` are considered directories).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_dir_exists:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **dir_exists** **(** :ref:`String<class_String>` path **)**
- Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_dir_exists_absolute:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **dir_exists_absolute** **(** :ref:`String<class_String>` path **)** |static|
- Static version of :ref:`dir_exists<class_DirAccess_method_dir_exists>`. Supports only absolute paths.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_file_exists:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **file_exists** **(** :ref:`String<class_String>` path **)**
- Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path.
- For a static equivalent, use :ref:`FileAccess.file_exists<class_FileAccess_method_file_exists>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_current_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_current_dir** **(** :ref:`bool<class_bool>` include_drive=true **)** |const|
- Returns the absolute path to the currently opened directory (e.g. ``res://folder`` or ``C:\tmp\folder``).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_current_drive:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_current_drive** **(** **)**
- Returns the currently opened directory's drive index. See :ref:`get_drive_name<class_DirAccess_method_get_drive_name>` to convert returned index to the name of the drive.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_directories:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_directories** **(** **)**
- Returns a :ref:`PackedStringArray<class_PackedStringArray>` containing filenames of the directory contents, excluding files. The array is sorted alphabetically.
- Affected by :ref:`include_hidden<class_DirAccess_property_include_hidden>` and :ref:`include_navigational<class_DirAccess_property_include_navigational>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_directories_at:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_directories_at** **(** :ref:`String<class_String>` path **)** |static|
- Returns a :ref:`PackedStringArray<class_PackedStringArray>` containing filenames of the directory contents, excluding files, at the given ``path``. The array is sorted alphabetically.
- Use :ref:`get_directories<class_DirAccess_method_get_directories>` if you want more control of what gets included.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_drive_count:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_drive_count** **(** **)** |static|
- On Windows, returns the number of drives (partitions) mounted on the current filesystem.
- On macOS, returns the number of mounted volumes.
- On Linux, returns the number of mounted volumes and GTK 3 bookmarks.
- On other platforms, the method returns 0.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_drive_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_drive_name** **(** :ref:`int<class_int>` idx **)** |static|
- On Windows, returns the name of the drive (partition) passed as an argument (e.g. ``C:``).
- On macOS, returns the path to the mounted volume passed as an argument.
- On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument.
- On other platforms, or if the requested drive does not exist, the method returns an empty String.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_files:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_files** **(** **)**
- Returns a :ref:`PackedStringArray<class_PackedStringArray>` containing filenames of the directory contents, excluding directories. The array is sorted alphabetically.
- Affected by :ref:`include_hidden<class_DirAccess_property_include_hidden>`.
- \ **Note:** When used on a ``res://`` path in an exported project, only the files actually included in the PCK at the given folder level are returned. In practice, this means that since imported resources are stored in a top-level ``.godot/`` folder, only paths to ``*.gd`` and ``*.import`` files are returned (plus a few files such as ``project.godot`` or ``project.binary`` and the project icon). In an exported project, the list of returned files will also vary depending on whether :ref:`ProjectSettings.editor/export/convert_text_resources_to_binary<class_ProjectSettings_property_editor/export/convert_text_resources_to_binary>` is ``true``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_files_at:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_files_at** **(** :ref:`String<class_String>` path **)** |static|
- Returns a :ref:`PackedStringArray<class_PackedStringArray>` containing filenames of the directory contents, excluding directories, at the given ``path``. The array is sorted alphabetically.
- Use :ref:`get_files<class_DirAccess_method_get_files>` if you want more control of what gets included.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_next:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_next** **(** **)**
- Returns the next element (file or directory) in the current directory.
- The name of the file or directory is returned (and not its full path). Once the stream has been fully processed, the method returns an empty :ref:`String<class_String>` and closes the stream automatically (i.e. :ref:`list_dir_end<class_DirAccess_method_list_dir_end>` would not be mandatory in such a case).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_open_error:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **get_open_error** **(** **)** |static|
- Returns the result of the last :ref:`open<class_DirAccess_method_open>` call in the current thread.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_get_space_left:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_space_left** **(** **)**
- Returns the available space on the current directory's disk, in bytes. Returns ``0`` if the platform-specific method to query the available space fails.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_is_case_sensitive:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_case_sensitive** **(** :ref:`String<class_String>` path **)** |const|
- Returns ``true`` if the file system or directory use case sensitive file names.
- \ **Note:** This method is implemented on macOS, Linux (for EXT4 and F2FS filesystems only) and Windows. On other platforms, it always returns ``true``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_list_dir_begin:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **list_dir_begin** **(** **)**
- Initializes the stream used to list all files and directories using the :ref:`get_next<class_DirAccess_method_get_next>` function, closing the currently opened stream if needed. Once the stream has been processed, it should typically be closed with :ref:`list_dir_end<class_DirAccess_method_list_dir_end>`.
- Affected by :ref:`include_hidden<class_DirAccess_property_include_hidden>` and :ref:`include_navigational<class_DirAccess_property_include_navigational>`.
- \ **Note:** The order of files and directories returned by this method is not deterministic, and can vary between operating systems. If you want a list of all files or folders sorted alphabetically, use :ref:`get_files<class_DirAccess_method_get_files>` or :ref:`get_directories<class_DirAccess_method_get_directories>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_list_dir_end:
- .. rst-class:: classref-method
- void **list_dir_end** **(** **)**
- Closes the current stream opened with :ref:`list_dir_begin<class_DirAccess_method_list_dir_begin>` (whether it has been fully processed with :ref:`get_next<class_DirAccess_method_get_next>` does not matter).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_make_dir:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **make_dir** **(** :ref:`String<class_String>` path **)**
- Creates a directory. The argument can be relative to the current directory, or an absolute path. The target directory should be placed in an already existing directory (to create the full path recursively, see :ref:`make_dir_recursive<class_DirAccess_method_make_dir_recursive>`).
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_make_dir_absolute:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **make_dir_absolute** **(** :ref:`String<class_String>` path **)** |static|
- Static version of :ref:`make_dir<class_DirAccess_method_make_dir>`. Supports only absolute paths.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_make_dir_recursive:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **make_dir_recursive** **(** :ref:`String<class_String>` path **)**
- Creates a target directory and all necessary intermediate directories in its path, by calling :ref:`make_dir<class_DirAccess_method_make_dir>` recursively. The argument can be relative to the current directory, or an absolute path.
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_make_dir_recursive_absolute:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **make_dir_recursive_absolute** **(** :ref:`String<class_String>` path **)** |static|
- Static version of :ref:`make_dir_recursive<class_DirAccess_method_make_dir_recursive>`. Supports only absolute paths.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_open:
- .. rst-class:: classref-method
- :ref:`DirAccess<class_DirAccess>` **open** **(** :ref:`String<class_String>` path **)** |static|
- Creates a new **DirAccess** object and opens an existing directory of the filesystem. The ``path`` argument can be within the project tree (``res://folder``), the user directory (``user://folder``) or an absolute path of the user filesystem (e.g. ``/tmp/folder`` or ``C:\tmp\folder``).
- Returns ``null`` if opening the directory failed. You can use :ref:`get_open_error<class_DirAccess_method_get_open_error>` to check the error that occurred.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_remove:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **remove** **(** :ref:`String<class_String>` path **)**
- Permanently deletes the target file or an empty directory. The argument can be relative to the current directory, or an absolute path. If the target directory is not empty, the operation will fail.
- If you don't want to delete the file/directory permanently, use :ref:`OS.move_to_trash<class_OS_method_move_to_trash>` instead.
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_remove_absolute:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **remove_absolute** **(** :ref:`String<class_String>` path **)** |static|
- Static version of :ref:`remove<class_DirAccess_method_remove>`. Supports only absolute paths.
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_rename:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **rename** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)**
- Renames (move) the ``from`` file or directory to the ``to`` destination. Both arguments should be paths to files or directories, either relative or absolute. If the destination file or directory exists and is not access-protected, it will be overwritten.
- Returns one of the :ref:`Error<enum_@GlobalScope_Error>` code constants (:ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success).
- .. rst-class:: classref-item-separator
- ----
- .. _class_DirAccess_method_rename_absolute:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **rename_absolute** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |static|
- Static version of :ref:`rename<class_DirAccess_method_rename>`. Supports only absolute paths.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
|