:github_url: hide .. meta:: :keywords: directory, path, folder .. _class_DirAccess: DirAccess ========= **Hereda:** :ref:`RefCounted` **<** :ref:`Object` Proporciona métodos para gestionar directorios y su contenido. .. rst-class:: classref-introduction-group Descripción ---------------------- 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:** Accessing project ("res://") directories once exported may behave unexpectedly as some files are converted to engine-specific formats and their original source files may not be present in the expected PCK package. Because of this, to access resources in an exported project, it is recommended to use :ref:`ResourceLoader` instead of :ref:`FileAccess`. 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."); } } Keep in mind that file names may change or be remapped after export. If you want to see the actual resource file list as it appears in the editor, use :ref:`ResourceLoader.list_directory()` instead. .. rst-class:: classref-introduction-group Tutoriales -------------------- - :doc:`Sistema de archivos <../tutorials/scripting/filesystem>` .. rst-class:: classref-reftable-group Propiedades ---------------------- .. table:: :widths: auto +-------------------------+----------------------------------------------------------------------------+ | :ref:`bool` | :ref:`include_hidden` | +-------------------------+----------------------------------------------------------------------------+ | :ref:`bool` | :ref:`include_navigational` | +-------------------------+----------------------------------------------------------------------------+ .. rst-class:: classref-reftable-group Métodos -------------- .. table:: :widths: auto +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`change_dir`\ (\ to_dir\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`copy`\ (\ from\: :ref:`String`, to\: :ref:`String`, chmod_flags\: :ref:`int` = -1\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`copy_absolute`\ (\ from\: :ref:`String`, to\: :ref:`String`, chmod_flags\: :ref:`int` = -1\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`create_link`\ (\ source\: :ref:`String`, target\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`DirAccess` | :ref:`create_temp`\ (\ prefix\: :ref:`String` = "", keep\: :ref:`bool` = false\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`current_is_dir`\ (\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`dir_exists`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`dir_exists_absolute`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`file_exists`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_current_dir`\ (\ include_drive\: :ref:`bool` = true\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_current_drive`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_directories`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_directories_at`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_drive_count`\ (\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_drive_name`\ (\ idx\: :ref:`int`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_files`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_files_at`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_filesystem_type`\ (\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_next`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`get_open_error`\ (\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_space_left`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_bundle`\ (\ path\: :ref:`String`\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_case_sensitive`\ (\ path\: :ref:`String`\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_equivalent`\ (\ path_a\: :ref:`String`, path_b\: :ref:`String`\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_link`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`list_dir_begin`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`list_dir_end`\ (\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`make_dir`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`make_dir_absolute`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`make_dir_recursive`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`make_dir_recursive_absolute`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`DirAccess` | :ref:`open`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`read_link`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`remove`\ (\ path\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`remove_absolute`\ (\ path\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`rename`\ (\ from\: :ref:`String`, to\: :ref:`String`\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`rename_absolute`\ (\ from\: :ref:`String`, to\: :ref:`String`\ ) |static| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Propiedades -------------------------------------------------------- .. _class_DirAccess_property_include_hidden: .. rst-class:: classref-property :ref:`bool` **include_hidden** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_include_hidden**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **get_include_hidden**\ (\ ) If ``true``, hidden files are included when navigating the directory. Affects :ref:`list_dir_begin()`, :ref:`get_directories()` and :ref:`get_files()`. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_property_include_navigational: .. rst-class:: classref-property :ref:`bool` **include_navigational** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_include_navigational**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **get_include_navigational**\ (\ ) If ``true``, ``.`` and ``..`` are included when navigating the directory. Affects :ref:`list_dir_begin()` and :ref:`get_directories()`. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Métodos ------------------------------------------------ .. _class_DirAccess_method_change_dir: .. rst-class:: classref-method :ref:`Error` **change_dir**\ (\ to_dir\: :ref:`String`\ ) :ref:`🔗` 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` code constants (:ref:`@GlobalScope.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()` to create a new instance instead. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_copy: .. rst-class:: classref-method :ref:`Error` **copy**\ (\ from\: :ref:`String`, to\: :ref:`String`, chmod_flags\: :ref:`int` = -1\ ) :ref:`🔗` 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` code constants (:ref:`@GlobalScope.OK` on success). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_copy_absolute: .. rst-class:: classref-method :ref:`Error` **copy_absolute**\ (\ from\: :ref:`String`, to\: :ref:`String`, chmod_flags\: :ref:`int` = -1\ ) |static| :ref:`🔗` Versión estática de :ref:`copy()`. Solo admite rutas absolutas. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_create_link: .. rst-class:: classref-method :ref:`Error` **create_link**\ (\ source\: :ref:`String`, target\: :ref:`String`\ ) :ref:`🔗` Crea un enlace simbólico entre archivos o carpetas. \ **Nota:** En Windows, este método solo funciona si la aplicación se está ejecutando con privilegios elevados o el Modo Desarrollador está habilitado. \ **Nota:** Este método está implementado en macOS, Linux y Windows. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_create_temp: .. rst-class:: classref-method :ref:`DirAccess` **create_temp**\ (\ prefix\: :ref:`String` = "", keep\: :ref:`bool` = false\ ) |static| :ref:`🔗` Creates a temporary directory. This directory will be freed when the returned **DirAccess** is freed. If ``prefix`` is not empty, it will be prefixed to the directory name, separated by a ``-``. If ``keep`` is ``true``, the directory is not deleted when the returned **DirAccess** is freed. Returns ``null`` if opening the directory failed. You can use :ref:`get_open_error()` to check the error that occurred. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_current_is_dir: .. rst-class:: classref-method :ref:`bool` **current_is_dir**\ (\ ) |const| :ref:`🔗` Devuelve si el objeto actual procesado con la última llamada a :ref:`get_next()` es un directorio. ``.`` y ``..`` son considerados directorios. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_dir_exists: .. rst-class:: classref-method :ref:`bool` **dir_exists**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Devuelve si el directorio de destino existe. El argumento puede ser relativo al directorio actual, o una ruta absoluta. \ **Nota:** El :ref:`bool` devuelto en el editor y después de la exportación cuando se usa en una ruta en el directorio ``res://`` puede ser diferente. Algunos archivos se convierten a formatos específicos del motor cuando se exportan, lo que puede cambiar la estructura del directorio. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_dir_exists_absolute: .. rst-class:: classref-method :ref:`bool` **dir_exists_absolute**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Versión estática de :ref:`dir_exists()`. Solo admite rutas absolutas. \ **Nota:** El :ref:`bool` devuelto en el editor y después de la exportación cuando se usa en una ruta en el directorio ``res://`` puede ser diferente. Algunos archivos se convierten a formatos específicos del motor cuando se exportan, lo que puede cambiar la estructura del directorio. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_file_exists: .. rst-class:: classref-method :ref:`bool` **file_exists**\ (\ path\: :ref:`String`\ ) :ref:`🔗` 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()`. \ **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. See :ref:`ResourceLoader.exists()` for an alternative approach that takes resource remapping into account. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_current_dir: .. rst-class:: classref-method :ref:`String` **get_current_dir**\ (\ include_drive\: :ref:`bool` = true\ ) |const| :ref:`🔗` Devuelve la ruta absoluta del directorio abierto actualmente (por ejemplo, ``res://folder`` o ``C:\tmp\folder``). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_current_drive: .. rst-class:: classref-method :ref:`int` **get_current_drive**\ (\ ) :ref:`🔗` Devuelve el índice de la unidad del directorio abierto actualmente. Véase :ref:`get_drive_name()` para convertir el índice devuelto al nombre de la unidad. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_directories: .. rst-class:: classref-method :ref:`PackedStringArray` **get_directories**\ (\ ) :ref:`🔗` Devuelve un :ref:`PackedStringArray` que contiene los nombres de archivo del contenido del directorio, excluyendo los archivos. El array está ordenado alfabéticamente. Afectado por :ref:`include_hidden` y :ref:`include_navigational`. \ **Nota:** Los directorios devueltos en el editor y después de la exportación en el directorio ``res://`` pueden diferir, ya que algunos archivos se convierten a formatos específicos del motor cuando se exportan. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_directories_at: .. rst-class:: classref-method :ref:`PackedStringArray` **get_directories_at**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Devuelve un :ref:`PackedStringArray` que contiene nombres de archivos del contenido del directorio, excluyendo archivos, en la ``path`` dada. El array se ordena alfabéticamente. Usa :ref:`get_directories()` si quieres más control sobre lo que se incluye. \ **Nota:** Los directorios devueltos en el editor y después de la exportación en el directorio ``res://`` pueden diferir, ya que algunos archivos se convierten a formatos específicos del motor cuando se exportan. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_drive_count: .. rst-class:: classref-method :ref:`int` **get_drive_count**\ (\ ) |static| :ref:`🔗` En Windows, devuelve el número de unidades (particiones) montadas en el sistema de archivos actual. En macOS y Android, devuelve el número de volúmenes montados. En Linux, devuelve el número de volúmenes montados y los marcadores de GTK 3. En otras plataformas, el método devuelve 0. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_drive_name: .. rst-class:: classref-method :ref:`String` **get_drive_name**\ (\ idx\: :ref:`int`\ ) |static| :ref:`🔗` En Windows, devuelve el nombre de la unidad (partición) pasada como argumento (p. ej. ``C:``). En macOS, devuelve la ruta al volumen montado pasado como argumento. En Linux, devuelve la ruta al volumen montado o al marcador de GTK 3 pasado como argumento. En Android (API nivel 30+), devuelve la ruta al volumen montado como argumento. En otras plataformas, o si la unidad solicitada no existe, el método devuelve una String vacía. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_files: .. rst-class:: classref-method :ref:`PackedStringArray` **get_files**\ (\ ) :ref:`🔗` Returns a :ref:`PackedStringArray` containing filenames of the directory contents, excluding directories. The array is sorted alphabetically. Affected by :ref:`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` is ``true``. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_files_at: .. rst-class:: classref-method :ref:`PackedStringArray` **get_files_at**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Returns a :ref:`PackedStringArray` containing filenames of the directory contents, excluding directories, at the given ``path``. The array is sorted alphabetically. Use :ref:`get_files()` if you want more control of what gets included. \ **Note:** When used on a ``res://`` path in an exported project, only the files 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 other 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 :ref:`ProjectSettings.editor/export/convert_text_resources_to_binary`. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_filesystem_type: .. rst-class:: classref-method :ref:`String` **get_filesystem_type**\ (\ ) |const| :ref:`🔗` Returns file system type name of the current directory's disk. Returned values are uppercase strings like ``NTFS``, ``FAT32``, ``EXFAT``, ``APFS``, ``EXT4``, ``BTRFS``, and so on. \ **Note:** This method is implemented on macOS, Linux, Windows and for PCK virtual file system. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_next: .. rst-class:: classref-method :ref:`String` **get_next**\ (\ ) :ref:`🔗` 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` and closes the stream automatically (i.e. :ref:`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` **get_open_error**\ (\ ) |static| :ref:`🔗` Returns the result of the last :ref:`open()` call in the current thread. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_get_space_left: .. rst-class:: classref-method :ref:`int` **get_space_left**\ (\ ) :ref:`🔗` 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_bundle: .. rst-class:: classref-method :ref:`bool` **is_bundle**\ (\ path\: :ref:`String`\ ) |const| :ref:`🔗` Returns ``true`` if the directory is a macOS bundle. \ **Note:** This method is implemented on macOS. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_is_case_sensitive: .. rst-class:: classref-method :ref:`bool` **is_case_sensitive**\ (\ path\: :ref:`String`\ ) |const| :ref:`🔗` 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_is_equivalent: .. rst-class:: classref-method :ref:`bool` **is_equivalent**\ (\ path_a\: :ref:`String`, path_b\: :ref:`String`\ ) |const| :ref:`🔗` Returns ``true`` if paths ``path_a`` and ``path_b`` resolve to the same file system object. Returns ``false`` otherwise, even if the files are bit-for-bit identical (e.g., identical copies of the file that are not symbolic links). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_is_link: .. rst-class:: classref-method :ref:`bool` **is_link**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Returns ``true`` if the file or directory is a symbolic link, directory junction, or other reparse point. \ **Note:** This method is implemented on macOS, Linux, and Windows. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_list_dir_begin: .. rst-class:: classref-method :ref:`Error` **list_dir_begin**\ (\ ) :ref:`🔗` Initializes the stream used to list all files and directories using the :ref:`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()`. Affected by :ref:`include_hidden` and :ref:`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()` or :ref:`get_directories()`. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_list_dir_end: .. rst-class:: classref-method |void| **list_dir_end**\ (\ ) :ref:`🔗` Closes the current stream opened with :ref:`list_dir_begin()` (whether it has been fully processed with :ref:`get_next()` does not matter). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_make_dir: .. rst-class:: classref-method :ref:`Error` **make_dir**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Crea un directorio. El argumento puede ser relativo al directorio actual o una ruta absoluta. El directorio de destino debe ubicarse en un directorio ya existente (para crear la ruta completa recursivamente, Véase :ref:`make_dir_recursive()`). Devuelve una de las constantes de código :ref:`Error` (:ref:`@GlobalScope.OK` en caso de éxito). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_make_dir_absolute: .. rst-class:: classref-method :ref:`Error` **make_dir_absolute**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Static version of :ref:`make_dir()`. Supports only absolute paths. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_make_dir_recursive: .. rst-class:: classref-method :ref:`Error` **make_dir_recursive**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Creates a target directory and all necessary intermediate directories in its path, by calling :ref:`make_dir()` recursively. The argument can be relative to the current directory, or an absolute path. Returns one of the :ref:`Error` code constants (:ref:`@GlobalScope.OK` on success). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_make_dir_recursive_absolute: .. rst-class:: classref-method :ref:`Error` **make_dir_recursive_absolute**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Static version of :ref:`make_dir_recursive()`. Supports only absolute paths. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_open: .. rst-class:: classref-method :ref:`DirAccess` **open**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` 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()` to check the error that occurred. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_read_link: .. rst-class:: classref-method :ref:`String` **read_link**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Returns target of the symbolic link. \ **Note:** This method is implemented on macOS, Linux, and Windows. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_remove: .. rst-class:: classref-method :ref:`Error` **remove**\ (\ path\: :ref:`String`\ ) :ref:`🔗` Elimina permanentemente el archivo de destino o un directorio vacío. El argumento puede ser relativo al directorio actual o una ruta absoluta. Si el directorio de destino no está vacío, la operación fallará. Si no desea eliminar el archivo o directorio permanentemente, utiliza :ref:`OS.move_to_trash()`. Devuelve una de las constantes de código :ref:`Error`, (:ref:`@GlobalScope.OK` en caso de éxito). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_remove_absolute: .. rst-class:: classref-method :ref:`Error` **remove_absolute**\ (\ path\: :ref:`String`\ ) |static| :ref:`🔗` Static version of :ref:`remove()`. Supports only absolute paths. .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_rename: .. rst-class:: classref-method :ref:`Error` **rename**\ (\ from\: :ref:`String`, to\: :ref:`String`\ ) :ref:`🔗` 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` code constants (:ref:`@GlobalScope.OK` on success). .. rst-class:: classref-item-separator ---- .. _class_DirAccess_method_rename_absolute: .. rst-class:: classref-method :ref:`Error` **rename_absolute**\ (\ from\: :ref:`String`, to\: :ref:`String`\ ) |static| :ref:`🔗` Static version of :ref:`rename()`. Supports only absolute paths. .. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)` .. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)` .. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)` .. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)` .. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)` .. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)` .. |void| replace:: :abbr:`void (Sin valor de retorno.)`