class_file.rst 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the File.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_File:
  6. File
  7. ====
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Type to handle file reading and writing operations.
  13. Properties
  14. ----------
  15. +-------------------------+-----------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`endian_swap<class_File_property_endian_swap>` |
  17. +-------------------------+-----------------------------------------------------+
  18. Methods
  19. -------
  20. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`close<class_File_method_close>` **(** **)** |
  22. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`eof_reached<class_File_method_eof_reached>` **(** **)** const |
  24. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`file_exists<class_File_method_file_exists>` **(** :ref:`String<class_String>` path **)** const |
  26. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_16<class_File_method_get_16>` **(** **)** const |
  28. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`get_32<class_File_method_get_32>` **(** **)** const |
  30. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_64<class_File_method_get_64>` **(** **)** const |
  32. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`get_8<class_File_method_get_8>` **(** **)** const |
  34. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_String>` | :ref:`get_as_text<class_File_method_get_as_text>` **(** **)** const |
  36. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`PoolByteArray<class_PoolByteArray>` | :ref:`get_buffer<class_File_method_get_buffer>` **(** :ref:`int<class_int>` len **)** const |
  38. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_csv_line<class_File_method_get_csv_line>` **(** :ref:`String<class_String>` delim="," **)** const |
  40. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`get_double<class_File_method_get_double>` **(** **)** const |
  42. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_error<class_File_method_get_error>` **(** **)** const |
  44. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`get_float<class_File_method_get_float>` **(** **)** const |
  46. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_len<class_File_method_get_len>` **(** **)** const |
  48. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`String<class_String>` | :ref:`get_line<class_File_method_get_line>` **(** **)** const |
  50. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`String<class_String>` | :ref:`get_md5<class_File_method_get_md5>` **(** :ref:`String<class_String>` path **)** const |
  52. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_modified_time<class_File_method_get_modified_time>` **(** :ref:`String<class_String>` file **)** const |
  54. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`String<class_String>` | :ref:`get_pascal_string<class_File_method_get_pascal_string>` **(** **)** |
  56. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`String<class_String>` | :ref:`get_path<class_File_method_get_path>` **(** **)** const |
  58. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`String<class_String>` | :ref:`get_path_absolute<class_File_method_get_path_absolute>` **(** **)** const |
  60. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_position<class_File_method_get_position>` **(** **)** const |
  62. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`get_real<class_File_method_get_real>` **(** **)** const |
  64. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`String<class_String>` | :ref:`get_sha256<class_File_method_get_sha256>` **(** :ref:`String<class_String>` path **)** const |
  66. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Variant<class_Variant>` | :ref:`get_var<class_File_method_get_var>` **(** :ref:`bool<class_bool>` allow_objects=false **)** const |
  68. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`is_open<class_File_method_is_open>` **(** **)** const |
  70. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_File_method_open>` **(** :ref:`String<class_String>` path, :ref:`int<class_int>` flags **)** |
  72. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_compressed<class_File_method_open_compressed>` **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`int<class_int>` compression_mode=0 **)** |
  74. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_encrypted<class_File_method_open_encrypted>` **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`PoolByteArray<class_PoolByteArray>` key **)** |
  76. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_encrypted_with_pass<class_File_method_open_encrypted_with_pass>` **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`String<class_String>` pass **)** |
  78. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`seek<class_File_method_seek>` **(** :ref:`int<class_int>` position **)** |
  80. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`seek_end<class_File_method_seek_end>` **(** :ref:`int<class_int>` position=0 **)** |
  82. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`store_16<class_File_method_store_16>` **(** :ref:`int<class_int>` value **)** |
  84. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`store_32<class_File_method_store_32>` **(** :ref:`int<class_int>` value **)** |
  86. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`store_64<class_File_method_store_64>` **(** :ref:`int<class_int>` value **)** |
  88. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`store_8<class_File_method_store_8>` **(** :ref:`int<class_int>` value **)** |
  90. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`store_buffer<class_File_method_store_buffer>` **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)** |
  92. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`store_csv_line<class_File_method_store_csv_line>` **(** :ref:`PoolStringArray<class_PoolStringArray>` values, :ref:`String<class_String>` delim="," **)** |
  94. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`store_double<class_File_method_store_double>` **(** :ref:`float<class_float>` value **)** |
  96. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`store_float<class_File_method_store_float>` **(** :ref:`float<class_float>` value **)** |
  98. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`store_line<class_File_method_store_line>` **(** :ref:`String<class_String>` line **)** |
  100. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`store_pascal_string<class_File_method_store_pascal_string>` **(** :ref:`String<class_String>` string **)** |
  102. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`store_real<class_File_method_store_real>` **(** :ref:`float<class_float>` value **)** |
  104. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`store_string<class_File_method_store_string>` **(** :ref:`String<class_String>` string **)** |
  106. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`store_var<class_File_method_store_var>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)** |
  108. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. Enumerations
  110. ------------
  111. .. _enum_File_ModeFlags:
  112. .. _class_File_constant_READ:
  113. .. _class_File_constant_WRITE:
  114. .. _class_File_constant_READ_WRITE:
  115. .. _class_File_constant_WRITE_READ:
  116. enum **ModeFlags**:
  117. - **READ** = **1** --- Opens the file for read operations.
  118. - **WRITE** = **2** --- Opens the file for write operations. Create it if the file does not exist and truncate if it exists.
  119. - **READ_WRITE** = **3** --- Opens the file for read and write operations. Does not truncate the file.
  120. - **WRITE_READ** = **7** --- Opens the file for read and write operations. Create it if the file does not exist and truncate if it exists.
  121. ----
  122. .. _enum_File_CompressionMode:
  123. .. _class_File_constant_COMPRESSION_FASTLZ:
  124. .. _class_File_constant_COMPRESSION_DEFLATE:
  125. .. _class_File_constant_COMPRESSION_ZSTD:
  126. .. _class_File_constant_COMPRESSION_GZIP:
  127. enum **CompressionMode**:
  128. - **COMPRESSION_FASTLZ** = **0** --- Uses the FastLZ compression method.
  129. - **COMPRESSION_DEFLATE** = **1** --- Uses the Deflate compression method.
  130. - **COMPRESSION_ZSTD** = **2** --- Uses the Zstd compression method.
  131. - **COMPRESSION_GZIP** = **3** --- Uses the gzip compression method.
  132. Description
  133. -----------
  134. File type. This is used to permanently store data into the user device's file system and to read from it. This can be used to store game save data or player configuration files, for example.
  135. Here's a sample on how to write and read from a file:
  136. ::
  137. func save(content):
  138. var file = File.new()
  139. file.open("user://save_game.dat", File.WRITE)
  140. file.store_string(content)
  141. file.close()
  142. func load():
  143. var file = File.new()
  144. file.open("user://save_game.dat", File.READ)
  145. var content = file.get_as_text()
  146. file.close()
  147. return content
  148. Tutorials
  149. ---------
  150. - :doc:`../getting_started/step_by_step/filesystem`
  151. Property Descriptions
  152. ---------------------
  153. .. _class_File_property_endian_swap:
  154. - :ref:`bool<class_bool>` **endian_swap**
  155. +----------+------------------------+
  156. | *Setter* | set_endian_swap(value) |
  157. +----------+------------------------+
  158. | *Getter* | get_endian_swap() |
  159. +----------+------------------------+
  160. If ``true``, the file's endianness is swapped. Use this if you're dealing with files written in big endian machines.
  161. Note that this is about the file format, not CPU type. This is always reset to ``false`` whenever you open the file.
  162. Method Descriptions
  163. -------------------
  164. .. _class_File_method_close:
  165. - void **close** **(** **)**
  166. Closes the currently opened file.
  167. ----
  168. .. _class_File_method_eof_reached:
  169. - :ref:`bool<class_bool>` **eof_reached** **(** **)** const
  170. Returns ``true`` if the file cursor has read past the end of the file. Note that this function will still return ``false`` while at the end of the file and only activates when reading past it. This can be confusing but it conforms to how low level file access works in all operating systems. There is always :ref:`get_len<class_File_method_get_len>` and :ref:`get_position<class_File_method_get_position>` to implement a custom logic.
  171. ----
  172. .. _class_File_method_file_exists:
  173. - :ref:`bool<class_bool>` **file_exists** **(** :ref:`String<class_String>` path **)** const
  174. Returns ``true`` if the file exists in the given path.
  175. Note that many resources types are imported (e.g. textures or sound files), and that their source asset will not be included in the exported game, as only the imported version is used (in the ``res://.import`` folder). To check for the existence of such resources while taking into account the remapping to their imported location, use :ref:`ResourceLoader.exists<class_ResourceLoader_method_exists>`. Typically, using ``File.file_exists`` on an imported resource would work while you are developing in the editor (the source asset is present in ``res://``, but fail when exported).
  176. ----
  177. .. _class_File_method_get_16:
  178. - :ref:`int<class_int>` **get_16** **(** **)** const
  179. Returns the next 16 bits from the file as an integer.
  180. ----
  181. .. _class_File_method_get_32:
  182. - :ref:`int<class_int>` **get_32** **(** **)** const
  183. Returns the next 32 bits from the file as an integer.
  184. ----
  185. .. _class_File_method_get_64:
  186. - :ref:`int<class_int>` **get_64** **(** **)** const
  187. Returns the next 64 bits from the file as an integer.
  188. ----
  189. .. _class_File_method_get_8:
  190. - :ref:`int<class_int>` **get_8** **(** **)** const
  191. Returns the next 8 bits from the file as an integer.
  192. ----
  193. .. _class_File_method_get_as_text:
  194. - :ref:`String<class_String>` **get_as_text** **(** **)** const
  195. Returns the whole file as a :ref:`String<class_String>`.
  196. Text is interpreted as being UTF-8 encoded.
  197. ----
  198. .. _class_File_method_get_buffer:
  199. - :ref:`PoolByteArray<class_PoolByteArray>` **get_buffer** **(** :ref:`int<class_int>` len **)** const
  200. Returns next ``len`` bytes of the file as a :ref:`PoolByteArray<class_PoolByteArray>`.
  201. ----
  202. .. _class_File_method_get_csv_line:
  203. - :ref:`PoolStringArray<class_PoolStringArray>` **get_csv_line** **(** :ref:`String<class_String>` delim="," **)** const
  204. Returns the next value of the file in CSV (Comma Separated Values) format. You can pass a different delimiter to use other than the default "," (comma), it should be one character long.
  205. Text is interpreted as being UTF-8 encoded.
  206. ----
  207. .. _class_File_method_get_double:
  208. - :ref:`float<class_float>` **get_double** **(** **)** const
  209. Returns the next 64 bits from the file as a floating point number.
  210. ----
  211. .. _class_File_method_get_error:
  212. - :ref:`Error<enum_@GlobalScope_Error>` **get_error** **(** **)** const
  213. Returns the last error that happened when trying to perform operations. Compare with the ``ERR_FILE_*`` constants from :ref:`Error<enum_@GlobalScope_Error>`.
  214. ----
  215. .. _class_File_method_get_float:
  216. - :ref:`float<class_float>` **get_float** **(** **)** const
  217. Returns the next 32 bits from the file as a floating point number.
  218. ----
  219. .. _class_File_method_get_len:
  220. - :ref:`int<class_int>` **get_len** **(** **)** const
  221. Returns the size of the file in bytes.
  222. ----
  223. .. _class_File_method_get_line:
  224. - :ref:`String<class_String>` **get_line** **(** **)** const
  225. Returns the next line of the file as a :ref:`String<class_String>`.
  226. Text is interpreted as being UTF-8 encoded.
  227. ----
  228. .. _class_File_method_get_md5:
  229. - :ref:`String<class_String>` **get_md5** **(** :ref:`String<class_String>` path **)** const
  230. Returns an MD5 String representing the file at the given path or an empty :ref:`String<class_String>` on failure.
  231. ----
  232. .. _class_File_method_get_modified_time:
  233. - :ref:`int<class_int>` **get_modified_time** **(** :ref:`String<class_String>` file **)** const
  234. 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 datetime by using :ref:`OS.get_datetime_from_unix_time<class_OS_method_get_datetime_from_unix_time>`.
  235. ----
  236. .. _class_File_method_get_pascal_string:
  237. - :ref:`String<class_String>` **get_pascal_string** **(** **)**
  238. Returns a :ref:`String<class_String>` saved in Pascal format from the file.
  239. Text is interpreted as being UTF-8 encoded.
  240. ----
  241. .. _class_File_method_get_path:
  242. - :ref:`String<class_String>` **get_path** **(** **)** const
  243. Returns the path as a :ref:`String<class_String>` for the current open file.
  244. ----
  245. .. _class_File_method_get_path_absolute:
  246. - :ref:`String<class_String>` **get_path_absolute** **(** **)** const
  247. Returns the absolute path as a :ref:`String<class_String>` for the current open file.
  248. ----
  249. .. _class_File_method_get_position:
  250. - :ref:`int<class_int>` **get_position** **(** **)** const
  251. Returns the file cursor's position.
  252. ----
  253. .. _class_File_method_get_real:
  254. - :ref:`float<class_float>` **get_real** **(** **)** const
  255. Returns the next bits from the file as a floating point number.
  256. ----
  257. .. _class_File_method_get_sha256:
  258. - :ref:`String<class_String>` **get_sha256** **(** :ref:`String<class_String>` path **)** const
  259. Returns a SHA-256 :ref:`String<class_String>` representing the file at the given path or an empty :ref:`String<class_String>` on failure.
  260. ----
  261. .. _class_File_method_get_var:
  262. - :ref:`Variant<class_Variant>` **get_var** **(** :ref:`bool<class_bool>` allow_objects=false **)** const
  263. Returns the next :ref:`Variant<class_Variant>` value from the file. When ``allow_objects`` is ``true`` decoding objects is allowed.
  264. **WARNING:** Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
  265. ----
  266. .. _class_File_method_is_open:
  267. - :ref:`bool<class_bool>` **is_open** **(** **)** const
  268. Returns ``true`` if the file is currently opened.
  269. ----
  270. .. _class_File_method_open:
  271. - :ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` path, :ref:`int<class_int>` flags **)**
  272. Opens the file for writing or reading, depending on the flags.
  273. ----
  274. .. _class_File_method_open_compressed:
  275. - :ref:`Error<enum_@GlobalScope_Error>` **open_compressed** **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`int<class_int>` compression_mode=0 **)**
  276. Opens a compressed file for reading or writing. Use :ref:`CompressionMode<enum_File_CompressionMode>` constants to set ``compression_mode``.
  277. ----
  278. .. _class_File_method_open_encrypted:
  279. - :ref:`Error<enum_@GlobalScope_Error>` **open_encrypted** **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`PoolByteArray<class_PoolByteArray>` key **)**
  280. Opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it.
  281. ----
  282. .. _class_File_method_open_encrypted_with_pass:
  283. - :ref:`Error<enum_@GlobalScope_Error>` **open_encrypted_with_pass** **(** :ref:`String<class_String>` path, :ref:`int<class_int>` mode_flags, :ref:`String<class_String>` pass **)**
  284. Opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it.
  285. ----
  286. .. _class_File_method_seek:
  287. - void **seek** **(** :ref:`int<class_int>` position **)**
  288. Change the file reading/writing cursor to the specified position (in bytes from the beginning of the file).
  289. ----
  290. .. _class_File_method_seek_end:
  291. - void **seek_end** **(** :ref:`int<class_int>` position=0 **)**
  292. Changes the file reading/writing cursor to the specified position (in bytes from the end of the file). Note that this is an offset, so you should use negative numbers or the cursor will be at the end of the file.
  293. ----
  294. .. _class_File_method_store_16:
  295. - void **store_16** **(** :ref:`int<class_int>` value **)**
  296. Stores an integer as 16 bits in the file.
  297. ----
  298. .. _class_File_method_store_32:
  299. - void **store_32** **(** :ref:`int<class_int>` value **)**
  300. Stores an integer as 32 bits in the file.
  301. ----
  302. .. _class_File_method_store_64:
  303. - void **store_64** **(** :ref:`int<class_int>` value **)**
  304. Stores an integer as 64 bits in the file.
  305. ----
  306. .. _class_File_method_store_8:
  307. - void **store_8** **(** :ref:`int<class_int>` value **)**
  308. Stores an integer as 8 bits in the file.
  309. ----
  310. .. _class_File_method_store_buffer:
  311. - void **store_buffer** **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)**
  312. Stores the given array of bytes in the file.
  313. ----
  314. .. _class_File_method_store_csv_line:
  315. - void **store_csv_line** **(** :ref:`PoolStringArray<class_PoolStringArray>` values, :ref:`String<class_String>` delim="," **)**
  316. Store the given :ref:`PoolStringArray<class_PoolStringArray>` in the file as a line formatted in the CSV (Comma Separated Values) format. You can pass a different delimiter to use other than the default "," (comma), it should be one character long.
  317. Text will be encoded as UTF-8.
  318. ----
  319. .. _class_File_method_store_double:
  320. - void **store_double** **(** :ref:`float<class_float>` value **)**
  321. Stores a floating point number as 64 bits in the file.
  322. ----
  323. .. _class_File_method_store_float:
  324. - void **store_float** **(** :ref:`float<class_float>` value **)**
  325. Stores a floating point number as 32 bits in the file.
  326. ----
  327. .. _class_File_method_store_line:
  328. - void **store_line** **(** :ref:`String<class_String>` line **)**
  329. Stores the given :ref:`String<class_String>` as a line in the file.
  330. Text will be encoded as UTF-8.
  331. ----
  332. .. _class_File_method_store_pascal_string:
  333. - void **store_pascal_string** **(** :ref:`String<class_String>` string **)**
  334. 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).
  335. Text will be encoded as UTF-8.
  336. ----
  337. .. _class_File_method_store_real:
  338. - void **store_real** **(** :ref:`float<class_float>` value **)**
  339. Stores a floating point number in the file.
  340. ----
  341. .. _class_File_method_store_string:
  342. - void **store_string** **(** :ref:`String<class_String>` string **)**
  343. Stores the given :ref:`String<class_String>` in the file.
  344. Text will be encoded as UTF-8.
  345. ----
  346. .. _class_File_method_store_var:
  347. - void **store_var** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)**
  348. Stores any Variant value in the file. When ``full_objects`` is ``true`` encoding objects is allowed (and can potentially include code).