Skip to content

Commit 673f396

Browse files
committed
Merge pull request #99132 from BrianBHuynh/master
Add notes on `DirAccess` documentation
2 parents 7f6b272 + 06bed7a commit 673f396

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/classes/DirAccess.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Static
1515
DirAccess.make_dir_absolute("user://levels/world1")
1616
[/codeblock]
17-
[b]Note:[/b] 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 [ResourceLoader] to access imported resources.
17+
[b]Note:[/b] 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 [ResourceLoader] instead of [FileAccess].
1818
Here is an example on how to iterate through the files of a directory:
1919
[codeblocks]
2020
[gdscript]
@@ -116,13 +116,15 @@
116116
<param index="0" name="path" type="String" />
117117
<description>
118118
Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path.
119+
[b]Note:[/b] The returned [bool] in the editor and after exporting when used on a path in the [code]res://[/code] directory may be different. Some files are converted to engine-specific formats when exported, potentially changing the directory structure.
119120
</description>
120121
</method>
121122
<method name="dir_exists_absolute" qualifiers="static">
122123
<return type="bool" />
123124
<param index="0" name="path" type="String" />
124125
<description>
125126
Static version of [method dir_exists]. Supports only absolute paths.
127+
[b]Note:[/b] The returned [bool] in the editor and after exporting when used on a path in the [code]res://[/code] directory may be different. Some files are converted to engine-specific formats when exported, potentially changing the directory structure.
126128
</description>
127129
</method>
128130
<method name="file_exists">
@@ -131,6 +133,7 @@
131133
<description>
132134
Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path.
133135
For a static equivalent, use [method FileAccess.file_exists].
136+
[b]Note:[/b] 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 [method ResourceLoader.exists] for an alternative approach that takes resource remapping into account.
134137
</description>
135138
</method>
136139
<method name="get_current_dir" qualifiers="const">
@@ -151,6 +154,7 @@
151154
<description>
152155
Returns a [PackedStringArray] containing filenames of the directory contents, excluding files. The array is sorted alphabetically.
153156
Affected by [member include_hidden] and [member include_navigational].
157+
[b]Note:[/b] The returned directories in the editor and after exporting in the [code]res://[/code] directory may differ as some files are converted to engine-specific formats when exported.
154158
</description>
155159
</method>
156160
<method name="get_directories_at" qualifiers="static">
@@ -159,6 +163,7 @@
159163
<description>
160164
Returns a [PackedStringArray] containing filenames of the directory contents, excluding files, at the given [param path]. The array is sorted alphabetically.
161165
Use [method get_directories] if you want more control of what gets included.
166+
[b]Note:[/b] The returned directories in the editor and after exporting in the [code]res://[/code] directory may differ as some files are converted to engine-specific formats when exported.
162167
</description>
163168
</method>
164169
<method name="get_drive_count" qualifiers="static">
@@ -194,6 +199,7 @@
194199
<description>
195200
Returns a [PackedStringArray] containing filenames of the directory contents, excluding directories, at the given [param path]. The array is sorted alphabetically.
196201
Use [method get_files] if you want more control of what gets included.
202+
[b]Note:[/b] When used on a [code]res://[/code] 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 [code].godot/[/code] folder, only paths to [code].gd[/code] and [code].import[/code] files are returned (plus a few other files, such as [code]project.godot[/code] or [code]project.binary[/code] and the project icon). In an exported project, the list of returned files will also vary depending on [member ProjectSettings.editor/export/convert_text_resources_to_binary].
197203
</description>
198204
</method>
199205
<method name="get_next">

0 commit comments

Comments
 (0)