class_fileaccess.rst 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/FileAccess.xml.
  6. .. _class_FileAccess:
  7. FileAccess
  8. ==========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Provides methods for file reading and writing operations.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This class can be used to permanently store data in the user device's file system and to read from it. This is useful for store game save data or player configuration files.
  15. Here's a sample on how to write and read from a file:
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. func save(content):
  19. var file = FileAccess.open("user://save_game.dat", FileAccess.WRITE)
  20. file.store_string(content)
  21. func load():
  22. var file = FileAccess.open("user://save_game.dat", FileAccess.READ)
  23. var content = file.get_as_text()
  24. return content
  25. .. code-tab:: csharp
  26. public void Save(string content)
  27. {
  28. using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write);
  29. file.StoreString(content);
  30. }
  31. public string Load()
  32. {
  33. using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read);
  34. string content = file.GetAsText();
  35. return content;
  36. }
  37. In the example above, the file will be saved in the user data folder as specified in the :doc:`Data paths <../tutorials/io/data_paths>` documentation.
  38. \ **FileAccess** will close when it's freed, which happens when it goes out of scope or when it gets assigned with ``null``. :ref:`close<class_FileAccess_method_close>` can be used to close it before then explicitly. In C# the reference must be disposed manually, which can be done with the ``using`` statement or by calling the ``Dispose`` method directly.
  39. \ **Note:** To access project resources once exported, it is recommended to use :ref:`ResourceLoader<class_ResourceLoader>` instead of **FileAccess**, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package.
  40. \ **Note:** Files are automatically closed only if the process exits "normally" (such as by clicking the window manager's close button or pressing **Alt + F4**). If you stop the project execution by pressing **F8** while the project is running, the file won't be closed as the game process will be killed. You can work around this by calling :ref:`flush<class_FileAccess_method_flush>` at regular intervals.
  41. .. rst-class:: classref-introduction-group
  42. Tutorials
  43. ---------
  44. - :doc:`File system <../tutorials/scripting/filesystem>`
  45. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  46. .. rst-class:: classref-reftable-group
  47. Properties
  48. ----------
  49. .. table::
  50. :widths: auto
  51. +-------------------------+---------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`big_endian<class_FileAccess_property_big_endian>` |
  53. +-------------------------+---------------------------------------------------------+
  54. .. rst-class:: classref-reftable-group
  55. Methods
  56. -------
  57. .. table::
  58. :widths: auto
  59. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`close<class_FileAccess_method_close>` **(** **)** |
  61. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`bool<class_bool>` | :ref:`eof_reached<class_FileAccess_method_eof_reached>` **(** **)** |const| |
  63. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`file_exists<class_FileAccess_method_file_exists>` **(** :ref:`String<class_String>` path **)** |static| |
  65. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`flush<class_FileAccess_method_flush>` **(** **)** |
  67. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`get_8<class_FileAccess_method_get_8>` **(** **)** |const| |
  69. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`int<class_int>` | :ref:`get_16<class_FileAccess_method_get_16>` **(** **)** |const| |
  71. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`get_32<class_FileAccess_method_get_32>` **(** **)** |const| |
  73. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`int<class_int>` | :ref:`get_64<class_FileAccess_method_get_64>` **(** **)** |const| |
  75. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`String<class_String>` | :ref:`get_as_text<class_FileAccess_method_get_as_text>` **(** :ref:`bool<class_bool>` skip_cr=false **)** |const| |
  77. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_buffer<class_FileAccess_method_get_buffer>` **(** :ref:`int<class_int>` length **)** |const| |
  79. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_csv_line<class_FileAccess_method_get_csv_line>` **(** :ref:`String<class_String>` delim="," **)** |const| |
  81. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`float<class_float>` | :ref:`get_double<class_FileAccess_method_get_double>` **(** **)** |const| |
  83. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_error<class_FileAccess_method_get_error>` **(** **)** |const| |
  85. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_file_as_bytes<class_FileAccess_method_get_file_as_bytes>` **(** :ref:`String<class_String>` path **)** |static| |
  87. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`String<class_String>` | :ref:`get_file_as_string<class_FileAccess_method_get_file_as_string>` **(** :ref:`String<class_String>` path **)** |static| |
  89. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`get_float<class_FileAccess_method_get_float>` **(** **)** |const| |
  91. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`int<class_int>` | :ref:`get_length<class_FileAccess_method_get_length>` **(** **)** |const| |
  93. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`String<class_String>` | :ref:`get_line<class_FileAccess_method_get_line>` **(** **)** |const| |
  95. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`String<class_String>` | :ref:`get_md5<class_FileAccess_method_get_md5>` **(** :ref:`String<class_String>` path **)** |static| |
  97. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`int<class_int>` | :ref:`get_modified_time<class_FileAccess_method_get_modified_time>` **(** :ref:`String<class_String>` file **)** |static| |
  99. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_open_error<class_FileAccess_method_get_open_error>` **(** **)** |static| |
  101. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`String<class_String>` | :ref:`get_pascal_string<class_FileAccess_method_get_pascal_string>` **(** **)** |
  103. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`String<class_String>` | :ref:`get_path<class_FileAccess_method_get_path>` **(** **)** |const| |
  105. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`String<class_String>` | :ref:`get_path_absolute<class_FileAccess_method_get_path_absolute>` **(** **)** |const| |
  107. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`get_position<class_FileAccess_method_get_position>` **(** **)** |const| |
  109. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`float<class_float>` | :ref:`get_real<class_FileAccess_method_get_real>` **(** **)** |const| |
  111. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`String<class_String>` | :ref:`get_sha256<class_FileAccess_method_get_sha256>` **(** :ref:`String<class_String>` path **)** |static| |
  113. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Variant<class_Variant>` | :ref:`get_var<class_FileAccess_method_get_var>` **(** :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  115. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`bool<class_bool>` | :ref:`is_open<class_FileAccess_method_is_open>` **(** **)** |const| |
  117. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`FileAccess<class_FileAccess>` | :ref:`open<class_FileAccess_method_open>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` flags **)** |static| |
  119. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`FileAccess<class_FileAccess>` | :ref:`open_compressed<class_FileAccess_method_open_compressed>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_FileAccess_CompressionMode>` compression_mode=0 **)** |static| |
  121. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`FileAccess<class_FileAccess>` | :ref:`open_encrypted<class_FileAccess_method_open_encrypted>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)** |static| |
  123. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`FileAccess<class_FileAccess>` | :ref:`open_encrypted_with_pass<class_FileAccess_method_open_encrypted_with_pass>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)** |static| |
  125. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`seek<class_FileAccess_method_seek>` **(** :ref:`int<class_int>` position **)** |
  127. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`seek_end<class_FileAccess_method_seek_end>` **(** :ref:`int<class_int>` position=0 **)** |
  129. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`store_8<class_FileAccess_method_store_8>` **(** :ref:`int<class_int>` value **)** |
  131. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`store_16<class_FileAccess_method_store_16>` **(** :ref:`int<class_int>` value **)** |
  133. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`store_32<class_FileAccess_method_store_32>` **(** :ref:`int<class_int>` value **)** |
  135. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | void | :ref:`store_64<class_FileAccess_method_store_64>` **(** :ref:`int<class_int>` value **)** |
  137. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | void | :ref:`store_buffer<class_FileAccess_method_store_buffer>` **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)** |
  139. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | void | :ref:`store_csv_line<class_FileAccess_method_store_csv_line>` **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)** |
  141. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | void | :ref:`store_double<class_FileAccess_method_store_double>` **(** :ref:`float<class_float>` value **)** |
  143. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | void | :ref:`store_float<class_FileAccess_method_store_float>` **(** :ref:`float<class_float>` value **)** |
  145. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | void | :ref:`store_line<class_FileAccess_method_store_line>` **(** :ref:`String<class_String>` line **)** |
  147. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | void | :ref:`store_pascal_string<class_FileAccess_method_store_pascal_string>` **(** :ref:`String<class_String>` string **)** |
  149. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | void | :ref:`store_real<class_FileAccess_method_store_real>` **(** :ref:`float<class_float>` value **)** |
  151. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | void | :ref:`store_string<class_FileAccess_method_store_string>` **(** :ref:`String<class_String>` string **)** |
  153. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | void | :ref:`store_var<class_FileAccess_method_store_var>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)** |
  155. +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. .. rst-class:: classref-section-separator
  157. ----
  158. .. rst-class:: classref-descriptions-group
  159. Enumerations
  160. ------------
  161. .. _enum_FileAccess_ModeFlags:
  162. .. rst-class:: classref-enumeration
  163. enum **ModeFlags**:
  164. .. _class_FileAccess_constant_READ:
  165. .. rst-class:: classref-enumeration-constant
  166. :ref:`ModeFlags<enum_FileAccess_ModeFlags>` **READ** = ``1``
  167. Opens the file for read operations. The cursor is positioned at the beginning of the file.
  168. .. _class_FileAccess_constant_WRITE:
  169. .. rst-class:: classref-enumeration-constant
  170. :ref:`ModeFlags<enum_FileAccess_ModeFlags>` **WRITE** = ``2``
  171. Opens the file for write operations. The file is created if it does not exist, and truncated if it does.
  172. .. _class_FileAccess_constant_READ_WRITE:
  173. .. rst-class:: classref-enumeration-constant
  174. :ref:`ModeFlags<enum_FileAccess_ModeFlags>` **READ_WRITE** = ``3``
  175. Opens the file for read and write operations. Does not truncate the file. The cursor is positioned at the beginning of the file.
  176. .. _class_FileAccess_constant_WRITE_READ:
  177. .. rst-class:: classref-enumeration-constant
  178. :ref:`ModeFlags<enum_FileAccess_ModeFlags>` **WRITE_READ** = ``7``
  179. Opens the file for read and write operations. The file is created if it does not exist, and truncated if it does. The cursor is positioned at the beginning of the file.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _enum_FileAccess_CompressionMode:
  183. .. rst-class:: classref-enumeration
  184. enum **CompressionMode**:
  185. .. _class_FileAccess_constant_COMPRESSION_FASTLZ:
  186. .. rst-class:: classref-enumeration-constant
  187. :ref:`CompressionMode<enum_FileAccess_CompressionMode>` **COMPRESSION_FASTLZ** = ``0``
  188. Uses the `FastLZ <https://fastlz.org/>`__ compression method.
  189. .. _class_FileAccess_constant_COMPRESSION_DEFLATE:
  190. .. rst-class:: classref-enumeration-constant
  191. :ref:`CompressionMode<enum_FileAccess_CompressionMode>` **COMPRESSION_DEFLATE** = ``1``
  192. Uses the `DEFLATE <https://en.wikipedia.org/wiki/DEFLATE>`__ compression method.
  193. .. _class_FileAccess_constant_COMPRESSION_ZSTD:
  194. .. rst-class:: classref-enumeration-constant
  195. :ref:`CompressionMode<enum_FileAccess_CompressionMode>` **COMPRESSION_ZSTD** = ``2``
  196. Uses the `Zstandard <https://facebook.github.io/zstd/>`__ compression method.
  197. .. _class_FileAccess_constant_COMPRESSION_GZIP:
  198. .. rst-class:: classref-enumeration-constant
  199. :ref:`CompressionMode<enum_FileAccess_CompressionMode>` **COMPRESSION_GZIP** = ``3``
  200. Uses the `gzip <https://www.gzip.org/>`__ compression method.
  201. .. _class_FileAccess_constant_COMPRESSION_BROTLI:
  202. .. rst-class:: classref-enumeration-constant
  203. :ref:`CompressionMode<enum_FileAccess_CompressionMode>` **COMPRESSION_BROTLI** = ``4``
  204. Uses the `brotli <https://github.com/google/brotli>`__ compression method (only decompression is supported).
  205. .. rst-class:: classref-section-separator
  206. ----
  207. .. rst-class:: classref-descriptions-group
  208. Property Descriptions
  209. ---------------------
  210. .. _class_FileAccess_property_big_endian:
  211. .. rst-class:: classref-property
  212. :ref:`bool<class_bool>` **big_endian**
  213. .. rst-class:: classref-property-setget
  214. - void **set_big_endian** **(** :ref:`bool<class_bool>` value **)**
  215. - :ref:`bool<class_bool>` **is_big_endian** **(** **)**
  216. If ``true``, the file is read with big-endian `endianness <https://en.wikipedia.org/wiki/Endianness>`__. If ``false``, the file is read with little-endian endianness. If in doubt, leave this to ``false`` as most files are written with little-endian endianness.
  217. \ **Note:** :ref:`big_endian<class_FileAccess_property_big_endian>` is only about the file format, not the CPU type. The CPU endianness doesn't affect the default endianness for files written.
  218. \ **Note:** This is always reset to ``false`` whenever you open the file. Therefore, you must set :ref:`big_endian<class_FileAccess_property_big_endian>` *after* opening the file, not before.
  219. .. rst-class:: classref-section-separator
  220. ----
  221. .. rst-class:: classref-descriptions-group
  222. Method Descriptions
  223. -------------------
  224. .. _class_FileAccess_method_close:
  225. .. rst-class:: classref-method
  226. void **close** **(** **)**
  227. Closes the currently opened file and prevents subsequent read/write operations. Use :ref:`flush<class_FileAccess_method_flush>` to persist the data to disk without closing the file.
  228. \ **Note:** **FileAccess** will automatically close when it's freed, which happens when it goes out of scope or when it gets assigned with ``null``. In C# the reference must be disposed after we are done using it, this can be done with the ``using`` statement or calling the ``Dispose`` method directly.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_FileAccess_method_eof_reached:
  232. .. rst-class:: classref-method
  233. :ref:`bool<class_bool>` **eof_reached** **(** **)** |const|
  234. Returns ``true`` if the file cursor has already read past the end of the file.
  235. \ **Note:** ``eof_reached() == false`` cannot be used to check whether there is more data available. To loop while there is more data available, use:
  236. .. tabs::
  237. .. code-tab:: gdscript
  238. while file.get_position() < file.get_length():
  239. # Read data
  240. .. code-tab:: csharp
  241. while (file.GetPosition() < file.GetLength())
  242. {
  243. // Read data
  244. }
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_FileAccess_method_file_exists:
  248. .. rst-class:: classref-method
  249. :ref:`bool<class_bool>` **file_exists** **(** :ref:`String<class_String>` path **)** |static|
  250. Returns ``true`` if the file exists in the given path.
  251. \ **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<class_ResourceLoader_method_exists>` for an alternative approach that takes resource remapping into account.
  252. For a non-static, relative equivalent, use :ref:`DirAccess.file_exists<class_DirAccess_method_file_exists>`.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_FileAccess_method_flush:
  256. .. rst-class:: classref-method
  257. void **flush** **(** **)**
  258. Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call :ref:`flush<class_FileAccess_method_flush>` manually before closing a file. Still, calling :ref:`flush<class_FileAccess_method_flush>` can be used to ensure the data is safe even if the project crashes instead of being closed gracefully.
  259. \ **Note:** Only call :ref:`flush<class_FileAccess_method_flush>` when you actually need it. Otherwise, it will decrease performance due to constant disk writes.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_FileAccess_method_get_8:
  263. .. rst-class:: classref-method
  264. :ref:`int<class_int>` **get_8** **(** **)** |const|
  265. Returns the next 8 bits from the file as an integer. See :ref:`store_8<class_FileAccess_method_store_8>` for details on what values can be stored and retrieved this way.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_FileAccess_method_get_16:
  269. .. rst-class:: classref-method
  270. :ref:`int<class_int>` **get_16** **(** **)** |const|
  271. Returns the next 16 bits from the file as an integer. See :ref:`store_16<class_FileAccess_method_store_16>` for details on what values can be stored and retrieved this way.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. _class_FileAccess_method_get_32:
  275. .. rst-class:: classref-method
  276. :ref:`int<class_int>` **get_32** **(** **)** |const|
  277. Returns the next 32 bits from the file as an integer. See :ref:`store_32<class_FileAccess_method_store_32>` for details on what values can be stored and retrieved this way.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_FileAccess_method_get_64:
  281. .. rst-class:: classref-method
  282. :ref:`int<class_int>` **get_64** **(** **)** |const|
  283. Returns the next 64 bits from the file as an integer. See :ref:`store_64<class_FileAccess_method_store_64>` for details on what values can be stored and retrieved this way.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_FileAccess_method_get_as_text:
  287. .. rst-class:: classref-method
  288. :ref:`String<class_String>` **get_as_text** **(** :ref:`bool<class_bool>` skip_cr=false **)** |const|
  289. Returns the whole file as a :ref:`String<class_String>`. Text is interpreted as being UTF-8 encoded.
  290. If ``skip_cr`` is ``true``, carriage return characters (``\r``, CR) will be ignored when parsing the UTF-8, so that only line feed characters (``\n``, LF) represent a new line (Unix convention).
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_FileAccess_method_get_buffer:
  294. .. rst-class:: classref-method
  295. :ref:`PackedByteArray<class_PackedByteArray>` **get_buffer** **(** :ref:`int<class_int>` length **)** |const|
  296. Returns next ``length`` bytes of the file as a :ref:`PackedByteArray<class_PackedByteArray>`.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_FileAccess_method_get_csv_line:
  300. .. rst-class:: classref-method
  301. :ref:`PackedStringArray<class_PackedStringArray>` **get_csv_line** **(** :ref:`String<class_String>` delim="," **)** |const|
  302. Returns the next value of the file in CSV (Comma-Separated Values) format. You can pass a different delimiter ``delim`` to use other than the default ``","`` (comma). This delimiter must be one-character long, and cannot be a double quotation mark.
  303. Text is interpreted as being UTF-8 encoded. Text values must be enclosed in double quotes if they include the delimiter character. Double quotes within a text value can be escaped by doubling their occurrence.
  304. For example, the following CSV lines are valid and will be properly parsed as two strings each:
  305. ::
  306. Alice,"Hello, Bob!"
  307. Bob,Alice! What a surprise!
  308. Alice,"I thought you'd reply with ""Hello, world""."
  309. Note how the second line can omit the enclosing quotes as it does not include the delimiter. However it *could* very well use quotes, it was only written without for demonstration purposes. The third line must use ``""`` for each quotation mark that needs to be interpreted as such instead of the end of a text value.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_FileAccess_method_get_double:
  313. .. rst-class:: classref-method
  314. :ref:`float<class_float>` **get_double** **(** **)** |const|
  315. Returns the next 64 bits from the file as a floating-point number.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_FileAccess_method_get_error:
  319. .. rst-class:: classref-method
  320. :ref:`Error<enum_@GlobalScope_Error>` **get_error** **(** **)** |const|
  321. Returns the last error that happened when trying to perform operations. Compare with the ``ERR_FILE_*`` constants from :ref:`Error<enum_@GlobalScope_Error>`.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_FileAccess_method_get_file_as_bytes:
  325. .. rst-class:: classref-method
  326. :ref:`PackedByteArray<class_PackedByteArray>` **get_file_as_bytes** **(** :ref:`String<class_String>` path **)** |static|
  327. Returns the whole ``path`` file contents as a :ref:`PackedByteArray<class_PackedByteArray>` without any decoding.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_FileAccess_method_get_file_as_string:
  331. .. rst-class:: classref-method
  332. :ref:`String<class_String>` **get_file_as_string** **(** :ref:`String<class_String>` path **)** |static|
  333. Returns the whole ``path`` file contents as a :ref:`String<class_String>`. Text is interpreted as being UTF-8 encoded.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_FileAccess_method_get_float:
  337. .. rst-class:: classref-method
  338. :ref:`float<class_float>` **get_float** **(** **)** |const|
  339. Returns the next 32 bits from the file as a floating-point number.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_FileAccess_method_get_length:
  343. .. rst-class:: classref-method
  344. :ref:`int<class_int>` **get_length** **(** **)** |const|
  345. Returns the size of the file in bytes.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_FileAccess_method_get_line:
  349. .. rst-class:: classref-method
  350. :ref:`String<class_String>` **get_line** **(** **)** |const|
  351. Returns the next line of the file as a :ref:`String<class_String>`.
  352. Text is interpreted as being UTF-8 encoded.
  353. .. rst-class:: classref-item-separator
  354. ----
  355. .. _class_FileAccess_method_get_md5:
  356. .. rst-class:: classref-method
  357. :ref:`String<class_String>` **get_md5** **(** :ref:`String<class_String>` path **)** |static|
  358. Returns an MD5 String representing the file at the given path or an empty :ref:`String<class_String>` on failure.
  359. .. rst-class:: classref-item-separator
  360. ----
  361. .. _class_FileAccess_method_get_modified_time:
  362. .. rst-class:: classref-method
  363. :ref:`int<class_int>` **get_modified_time** **(** :ref:`String<class_String>` file **)** |static|
  364. Returns the last time the ``file`` was modified in Unix timestamp format or returns a :ref:`String<class_String>` "ERROR IN ``file``". This Unix timestamp can be converted to another format using the :ref:`Time<class_Time>` singleton.
  365. .. rst-class:: classref-item-separator
  366. ----
  367. .. _class_FileAccess_method_get_open_error:
  368. .. rst-class:: classref-method
  369. :ref:`Error<enum_@GlobalScope_Error>` **get_open_error** **(** **)** |static|
  370. Returns the result of the last :ref:`open<class_FileAccess_method_open>` call in the current thread.
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_FileAccess_method_get_pascal_string:
  374. .. rst-class:: classref-method
  375. :ref:`String<class_String>` **get_pascal_string** **(** **)**
  376. Returns a :ref:`String<class_String>` saved in Pascal format from the file.
  377. Text is interpreted as being UTF-8 encoded.
  378. .. rst-class:: classref-item-separator
  379. ----
  380. .. _class_FileAccess_method_get_path:
  381. .. rst-class:: classref-method
  382. :ref:`String<class_String>` **get_path** **(** **)** |const|
  383. Returns the path as a :ref:`String<class_String>` for the current open file.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_FileAccess_method_get_path_absolute:
  387. .. rst-class:: classref-method
  388. :ref:`String<class_String>` **get_path_absolute** **(** **)** |const|
  389. Returns the absolute path as a :ref:`String<class_String>` for the current open file.
  390. .. rst-class:: classref-item-separator
  391. ----
  392. .. _class_FileAccess_method_get_position:
  393. .. rst-class:: classref-method
  394. :ref:`int<class_int>` **get_position** **(** **)** |const|
  395. Returns the file cursor's position.
  396. .. rst-class:: classref-item-separator
  397. ----
  398. .. _class_FileAccess_method_get_real:
  399. .. rst-class:: classref-method
  400. :ref:`float<class_float>` **get_real** **(** **)** |const|
  401. Returns the next bits from the file as a floating-point number.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_FileAccess_method_get_sha256:
  405. .. rst-class:: classref-method
  406. :ref:`String<class_String>` **get_sha256** **(** :ref:`String<class_String>` path **)** |static|
  407. Returns a SHA-256 :ref:`String<class_String>` representing the file at the given path or an empty :ref:`String<class_String>` on failure.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_FileAccess_method_get_var:
  411. .. rst-class:: classref-method
  412. :ref:`Variant<class_Variant>` **get_var** **(** :ref:`bool<class_bool>` allow_objects=false **)** |const|
  413. Returns the next :ref:`Variant<class_Variant>` value from the file. If ``allow_objects`` is ``true``, decoding objects is allowed.
  414. Internally, this uses the same decoding mechanism as the :ref:`@GlobalScope.bytes_to_var<class_@GlobalScope_method_bytes_to_var>` method.
  415. \ **Warning:** Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
  416. .. rst-class:: classref-item-separator
  417. ----
  418. .. _class_FileAccess_method_is_open:
  419. .. rst-class:: classref-method
  420. :ref:`bool<class_bool>` **is_open** **(** **)** |const|
  421. Returns ``true`` if the file is currently opened.
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_FileAccess_method_open:
  425. .. rst-class:: classref-method
  426. :ref:`FileAccess<class_FileAccess>` **open** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` flags **)** |static|
  427. Creates a new **FileAccess** object and opens the file for writing or reading, depending on the flags.
  428. Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
  429. .. rst-class:: classref-item-separator
  430. ----
  431. .. _class_FileAccess_method_open_compressed:
  432. .. rst-class:: classref-method
  433. :ref:`FileAccess<class_FileAccess>` **open_compressed** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_FileAccess_CompressionMode>` compression_mode=0 **)** |static|
  434. Creates a new **FileAccess** object and opens a compressed file for reading or writing.
  435. \ **Note:** :ref:`open_compressed<class_FileAccess_method_open_compressed>` can only read files that were saved by Godot, not third-party compression formats. See `GitHub issue #28999 <https://github.com/godotengine/godot/issues/28999>`__ for a workaround.
  436. Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _class_FileAccess_method_open_encrypted:
  440. .. rst-class:: classref-method
  441. :ref:`FileAccess<class_FileAccess>` **open_encrypted** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)** |static|
  442. Creates a new **FileAccess** object and opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it.
  443. \ **Note:** The provided key must be 32 bytes long.
  444. Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_FileAccess_method_open_encrypted_with_pass:
  448. .. rst-class:: classref-method
  449. :ref:`FileAccess<class_FileAccess>` **open_encrypted_with_pass** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)** |static|
  450. Creates a new **FileAccess** object and opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it.
  451. Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_FileAccess_method_seek:
  455. .. rst-class:: classref-method
  456. void **seek** **(** :ref:`int<class_int>` position **)**
  457. Changes the file reading/writing cursor to the specified position (in bytes from the beginning of the file).
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_FileAccess_method_seek_end:
  461. .. rst-class:: classref-method
  462. void **seek_end** **(** :ref:`int<class_int>` position=0 **)**
  463. Changes the file reading/writing cursor to the specified position (in bytes from the end of the file).
  464. \ **Note:** This is an offset, so you should use negative numbers or the cursor will be at the end of the file.
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_FileAccess_method_store_8:
  468. .. rst-class:: classref-method
  469. void **store_8** **(** :ref:`int<class_int>` value **)**
  470. Stores an integer as 8 bits in the file.
  471. \ **Note:** The ``value`` should lie in the interval ``[0, 255]``. Any other value will overflow and wrap around.
  472. To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>`, or convert it manually (see :ref:`store_16<class_FileAccess_method_store_16>` for an example).
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_FileAccess_method_store_16:
  476. .. rst-class:: classref-method
  477. void **store_16** **(** :ref:`int<class_int>` value **)**
  478. Stores an integer as 16 bits in the file.
  479. \ **Note:** The ``value`` should lie in the interval ``[0, 2^16 - 1]``. Any other value will overflow and wrap around.
  480. To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>` or store a signed integer from the interval ``[-2^15, 2^15 - 1]`` (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
  481. .. tabs::
  482. .. code-tab:: gdscript
  483. const MAX_15B = 1 << 15
  484. const MAX_16B = 1 << 16
  485. func unsigned16_to_signed(unsigned):
  486. return (unsigned + MAX_15B) % MAX_16B - MAX_15B
  487. func _ready():
  488. var f = FileAccess.open("user://file.dat", FileAccess.WRITE_READ)
  489. f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
  490. f.store_16(121) # In bounds, will store 121.
  491. f.seek(0) # Go back to start to read the stored value.
  492. var read1 = f.get_16() # 65494
  493. var read2 = f.get_16() # 121
  494. var converted1 = unsigned16_to_signed(read1) # -42
  495. var converted2 = unsigned16_to_signed(read2) # 121
  496. .. code-tab:: csharp
  497. public override void _Ready()
  498. {
  499. using var f = FileAccess.Open("user://file.dat", FileAccess.ModeFlags.WriteRead);
  500. f.Store16(unchecked((ushort)-42)); // This wraps around and stores 65494 (2^16 - 42).
  501. f.Store16(121); // In bounds, will store 121.
  502. f.Seek(0); // Go back to start to read the stored value.
  503. ushort read1 = f.Get16(); // 65494
  504. ushort read2 = f.Get16(); // 121
  505. short converted1 = (short)read1; // -42
  506. short converted2 = (short)read2; // 121
  507. }
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_FileAccess_method_store_32:
  511. .. rst-class:: classref-method
  512. void **store_32** **(** :ref:`int<class_int>` value **)**
  513. Stores an integer as 32 bits in the file.
  514. \ **Note:** The ``value`` should lie in the interval ``[0, 2^32 - 1]``. Any other value will overflow and wrap around.
  515. To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>`, or convert it manually (see :ref:`store_16<class_FileAccess_method_store_16>` for an example).
  516. .. rst-class:: classref-item-separator
  517. ----
  518. .. _class_FileAccess_method_store_64:
  519. .. rst-class:: classref-method
  520. void **store_64** **(** :ref:`int<class_int>` value **)**
  521. Stores an integer as 64 bits in the file.
  522. \ **Note:** The ``value`` must lie in the interval ``[-2^63, 2^63 - 1]`` (i.e. be a valid :ref:`int<class_int>` value).
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _class_FileAccess_method_store_buffer:
  526. .. rst-class:: classref-method
  527. void **store_buffer** **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)**
  528. Stores the given array of bytes in the file.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_FileAccess_method_store_csv_line:
  532. .. rst-class:: classref-method
  533. void **store_csv_line** **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)**
  534. Store the given :ref:`PackedStringArray<class_PackedStringArray>` in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter ``delim`` to use other than the default ``","`` (comma). This delimiter must be one-character long.
  535. Text will be encoded as UTF-8.
  536. .. rst-class:: classref-item-separator
  537. ----
  538. .. _class_FileAccess_method_store_double:
  539. .. rst-class:: classref-method
  540. void **store_double** **(** :ref:`float<class_float>` value **)**
  541. Stores a floating-point number as 64 bits in the file.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_FileAccess_method_store_float:
  545. .. rst-class:: classref-method
  546. void **store_float** **(** :ref:`float<class_float>` value **)**
  547. Stores a floating-point number as 32 bits in the file.
  548. .. rst-class:: classref-item-separator
  549. ----
  550. .. _class_FileAccess_method_store_line:
  551. .. rst-class:: classref-method
  552. void **store_line** **(** :ref:`String<class_String>` line **)**
  553. Appends ``line`` to the file followed by a line return character (``\n``), encoding the text as UTF-8.
  554. .. rst-class:: classref-item-separator
  555. ----
  556. .. _class_FileAccess_method_store_pascal_string:
  557. .. rst-class:: classref-method
  558. void **store_pascal_string** **(** :ref:`String<class_String>` string **)**
  559. Stores the given :ref:`String<class_String>` as a line in the file in Pascal format (i.e. also store the length of the string).
  560. Text will be encoded as UTF-8.
  561. .. rst-class:: classref-item-separator
  562. ----
  563. .. _class_FileAccess_method_store_real:
  564. .. rst-class:: classref-method
  565. void **store_real** **(** :ref:`float<class_float>` value **)**
  566. Stores a floating-point number in the file.
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_FileAccess_method_store_string:
  570. .. rst-class:: classref-method
  571. void **store_string** **(** :ref:`String<class_String>` string **)**
  572. Appends ``string`` to the file without a line return, encoding the text as UTF-8.
  573. \ **Note:** This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using :ref:`store_pascal_string<class_FileAccess_method_store_pascal_string>` instead. For retrieving strings from a text file, you can use ``get_buffer(length).get_string_from_utf8()`` (if you know the length) or :ref:`get_as_text<class_FileAccess_method_get_as_text>`.
  574. .. rst-class:: classref-item-separator
  575. ----
  576. .. _class_FileAccess_method_store_var:
  577. .. rst-class:: classref-method
  578. void **store_var** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)**
  579. Stores any Variant value in the file. If ``full_objects`` is ``true``, encoding objects is allowed (and can potentially include code).
  580. Internally, this uses the same encoding mechanism as the :ref:`@GlobalScope.var_to_bytes<class_@GlobalScope_method_var_to_bytes>` method.
  581. \ **Note:** Not all properties are included. Only properties that are configured with the :ref:`@GlobalScope.PROPERTY_USAGE_STORAGE<class_@GlobalScope_constant_PROPERTY_USAGE_STORAGE>` flag set will be serialized. You can add a new usage flag to a property by overriding the :ref:`Object._get_property_list<class_Object_method__get_property_list>` method in your class. You can also check how property usage is configured by calling :ref:`Object._get_property_list<class_Object_method__get_property_list>`. See :ref:`PropertyUsageFlags<enum_@GlobalScope_PropertyUsageFlags>` for the possible usage flags.
  582. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  583. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  584. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  585. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  586. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  587. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`