1 /** 2 Type to handle file reading and writing operations. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.file; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.reference; 25 /** 26 Type to handle file reading and writing operations. 27 28 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. 29 Here's a sample on how to write and read from a file: 30 31 32 func save(content): 33 var file = File.new() 34 file.open("user://save_game.dat", File.WRITE) 35 file.store_string(content) 36 file.close() 37 38 func load(): 39 var file = File.new() 40 file.open("user://save_game.dat", File.READ) 41 var content = file.get_as_text() 42 file.close() 43 return content 44 45 46 In the example above, the file will be saved in the user data folder as specified in the $(D url=https://docs.godotengine.org/en/3.3/tutorials/io/data_paths.html)Data paths$(D /url) documentation. 47 $(B Note:) To access project resources once exported, it is recommended to use $(D ResourceLoader) instead of the $(D File) API, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package. 48 $(B Note:) Files are automatically closed only if the process exits "normally" (such as by clicking the window manager's close button or pressing $(B Alt + F4)). If you stop the project execution by pressing $(B 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 $(D flush) at regular intervals. 49 */ 50 @GodotBaseClass struct File 51 { 52 package(godot) enum string _GODOT_internal_name = "_File"; 53 public: 54 @nogc nothrow: 55 union { /** */ godot_object _godot_object; /** */ Reference _GODOT_base; } 56 alias _GODOT_base this; 57 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 58 package(godot) __gshared bool _classBindingInitialized = false; 59 package(godot) static struct GDNativeClassBinding 60 { 61 __gshared: 62 @GodotName("close") GodotMethod!(void) close; 63 @GodotName("eof_reached") GodotMethod!(bool) eofReached; 64 @GodotName("file_exists") GodotMethod!(bool, String) fileExists; 65 @GodotName("flush") GodotMethod!(void) flush; 66 @GodotName("get_16") GodotMethod!(long) get16; 67 @GodotName("get_32") GodotMethod!(long) get32; 68 @GodotName("get_64") GodotMethod!(long) get64; 69 @GodotName("get_8") GodotMethod!(long) get8; 70 @GodotName("get_as_text") GodotMethod!(String) getAsText; 71 @GodotName("get_buffer") GodotMethod!(PoolByteArray, long) getBuffer; 72 @GodotName("get_csv_line") GodotMethod!(PoolStringArray, String) getCsvLine; 73 @GodotName("get_double") GodotMethod!(double) getDouble; 74 @GodotName("get_endian_swap") GodotMethod!(bool) getEndianSwap; 75 @GodotName("get_error") GodotMethod!(GodotError) getError; 76 @GodotName("get_float") GodotMethod!(double) getFloat; 77 @GodotName("get_len") GodotMethod!(long) getLen; 78 @GodotName("get_line") GodotMethod!(String) getLine; 79 @GodotName("get_md5") GodotMethod!(String, String) getMd5; 80 @GodotName("get_modified_time") GodotMethod!(long, String) getModifiedTime; 81 @GodotName("get_pascal_string") GodotMethod!(String) getPascalString; 82 @GodotName("get_path") GodotMethod!(String) getPath; 83 @GodotName("get_path_absolute") GodotMethod!(String) getPathAbsolute; 84 @GodotName("get_position") GodotMethod!(long) getPosition; 85 @GodotName("get_real") GodotMethod!(double) getReal; 86 @GodotName("get_sha256") GodotMethod!(String, String) getSha256; 87 @GodotName("get_var") GodotMethod!(Variant, bool) getVar; 88 @GodotName("is_open") GodotMethod!(bool) isOpen; 89 @GodotName("open") GodotMethod!(GodotError, String, long) open; 90 @GodotName("open_compressed") GodotMethod!(GodotError, String, long, long) openCompressed; 91 @GodotName("open_encrypted") GodotMethod!(GodotError, String, long, PoolByteArray) openEncrypted; 92 @GodotName("open_encrypted_with_pass") GodotMethod!(GodotError, String, long, String) openEncryptedWithPass; 93 @GodotName("seek") GodotMethod!(void, long) seek; 94 @GodotName("seek_end") GodotMethod!(void, long) seekEnd; 95 @GodotName("set_endian_swap") GodotMethod!(void, bool) setEndianSwap; 96 @GodotName("store_16") GodotMethod!(void, long) store16; 97 @GodotName("store_32") GodotMethod!(void, long) store32; 98 @GodotName("store_64") GodotMethod!(void, long) store64; 99 @GodotName("store_8") GodotMethod!(void, long) store8; 100 @GodotName("store_buffer") GodotMethod!(void, PoolByteArray) storeBuffer; 101 @GodotName("store_csv_line") GodotMethod!(void, PoolStringArray, String) storeCsvLine; 102 @GodotName("store_double") GodotMethod!(void, double) storeDouble; 103 @GodotName("store_float") GodotMethod!(void, double) storeFloat; 104 @GodotName("store_line") GodotMethod!(void, String) storeLine; 105 @GodotName("store_pascal_string") GodotMethod!(void, String) storePascalString; 106 @GodotName("store_real") GodotMethod!(void, double) storeReal; 107 @GodotName("store_string") GodotMethod!(void, String) storeString; 108 @GodotName("store_var") GodotMethod!(void, Variant, bool) storeVar; 109 } 110 /// 111 pragma(inline, true) bool opEquals(in File other) const 112 { return _godot_object.ptr is other._godot_object.ptr; } 113 /// 114 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 115 { _godot_object.ptr = n; return null; } 116 /// 117 pragma(inline, true) bool opEquals(typeof(null) n) const 118 { return _godot_object.ptr is n; } 119 /// 120 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 121 mixin baseCasts; 122 /// Construct a new instance of File. 123 /// Note: use `memnew!File` instead. 124 static File _new() 125 { 126 static godot_class_constructor constructor; 127 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_File"); 128 if(constructor is null) return typeof(this).init; 129 return cast(File)(constructor()); 130 } 131 @disable new(size_t s); 132 /// 133 enum CompressionMode : int 134 { 135 /** 136 Uses the $(D url=http://fastlz.org/)FastLZ$(D /url) compression method. 137 */ 138 compressionFastlz = 0, 139 /** 140 Uses the $(D url=https://en.wikipedia.org/wiki/DEFLATE)DEFLATE$(D /url) compression method. 141 */ 142 compressionDeflate = 1, 143 /** 144 Uses the $(D url=https://facebook.github.io/zstd/)Zstandard$(D /url) compression method. 145 */ 146 compressionZstd = 2, 147 /** 148 Uses the $(D url=https://www.gzip.org/)gzip$(D /url) compression method. 149 */ 150 compressionGzip = 3, 151 } 152 /// 153 enum ModeFlags : int 154 { 155 /** 156 Opens the file for read operations. The cursor is positioned at the beginning of the file. 157 */ 158 read = 1, 159 /** 160 Opens the file for write operations. The file is created if it does not exist, and truncated if it does. 161 */ 162 write = 2, 163 /** 164 Opens the file for read and write operations. Does not truncate the file. The cursor is positioned at the beginning of the file. 165 */ 166 readWrite = 3, 167 /** 168 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. 169 */ 170 writeRead = 7, 171 } 172 /// 173 enum Constants : int 174 { 175 compressionFastlz = 0, 176 read = 1, 177 compressionDeflate = 1, 178 compressionZstd = 2, 179 write = 2, 180 readWrite = 3, 181 compressionGzip = 3, 182 writeRead = 7, 183 } 184 /** 185 Closes the currently opened file and prevents subsequent read/write operations. Use $(D flush) to persist the data to disk without closing the file. 186 */ 187 void close() 188 { 189 checkClassBinding!(typeof(this))(); 190 ptrcall!(void)(GDNativeClassBinding.close, _godot_object); 191 } 192 /** 193 Returns `true` if the file cursor has read past the end of the file. 194 $(B Note:) 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 $(D getLen) and $(D getPosition) to implement a custom logic. 195 */ 196 bool eofReached() const 197 { 198 checkClassBinding!(typeof(this))(); 199 return ptrcall!(bool)(GDNativeClassBinding.eofReached, _godot_object); 200 } 201 /** 202 Returns `true` if the file exists in the given path. 203 $(B 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 $(D ResourceLoader.exists) for an alternative approach that takes resource remapping into account. 204 */ 205 bool fileExists(in String path) const 206 { 207 checkClassBinding!(typeof(this))(); 208 return ptrcall!(bool)(GDNativeClassBinding.fileExists, _godot_object, path); 209 } 210 /** 211 Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call $(D flush) manually before closing a file using $(D close). Still, calling $(D flush) can be used to ensure the data is safe even if the project crashes instead of being closed gracefully. 212 $(B Note:) Only call $(D flush) when you actually need it. Otherwise, it will decrease performance due to constant disk writes. 213 */ 214 void flush() 215 { 216 checkClassBinding!(typeof(this))(); 217 ptrcall!(void)(GDNativeClassBinding.flush, _godot_object); 218 } 219 /** 220 Returns the next 16 bits from the file as an integer. See $(D store16) for details on what values can be stored and retrieved this way. 221 */ 222 long get16() const 223 { 224 checkClassBinding!(typeof(this))(); 225 return ptrcall!(long)(GDNativeClassBinding.get16, _godot_object); 226 } 227 /** 228 Returns the next 32 bits from the file as an integer. See $(D store32) for details on what values can be stored and retrieved this way. 229 */ 230 long get32() const 231 { 232 checkClassBinding!(typeof(this))(); 233 return ptrcall!(long)(GDNativeClassBinding.get32, _godot_object); 234 } 235 /** 236 Returns the next 64 bits from the file as an integer. See $(D store64) for details on what values can be stored and retrieved this way. 237 */ 238 long get64() const 239 { 240 checkClassBinding!(typeof(this))(); 241 return ptrcall!(long)(GDNativeClassBinding.get64, _godot_object); 242 } 243 /** 244 Returns the next 8 bits from the file as an integer. See $(D store8) for details on what values can be stored and retrieved this way. 245 */ 246 long get8() const 247 { 248 checkClassBinding!(typeof(this))(); 249 return ptrcall!(long)(GDNativeClassBinding.get8, _godot_object); 250 } 251 /** 252 Returns the whole file as a $(D String). 253 Text is interpreted as being UTF-8 encoded. 254 */ 255 String getAsText() const 256 { 257 checkClassBinding!(typeof(this))(); 258 return ptrcall!(String)(GDNativeClassBinding.getAsText, _godot_object); 259 } 260 /** 261 Returns next `len` bytes of the file as a $(D PoolByteArray). 262 */ 263 PoolByteArray getBuffer(in long len) const 264 { 265 checkClassBinding!(typeof(this))(); 266 return ptrcall!(PoolByteArray)(GDNativeClassBinding.getBuffer, _godot_object, len); 267 } 268 /** 269 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. 270 Text is interpreted as being UTF-8 encoded. 271 */ 272 PoolStringArray getCsvLine(in String delim = gs!",") const 273 { 274 checkClassBinding!(typeof(this))(); 275 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getCsvLine, _godot_object, delim); 276 } 277 /** 278 Returns the next 64 bits from the file as a floating-point number. 279 */ 280 double getDouble() const 281 { 282 checkClassBinding!(typeof(this))(); 283 return ptrcall!(double)(GDNativeClassBinding.getDouble, _godot_object); 284 } 285 /** 286 287 */ 288 bool getEndianSwap() 289 { 290 checkClassBinding!(typeof(this))(); 291 return ptrcall!(bool)(GDNativeClassBinding.getEndianSwap, _godot_object); 292 } 293 /** 294 Returns the last error that happened when trying to perform operations. Compare with the `ERR_FILE_*` constants from $(D error). 295 */ 296 GodotError getError() const 297 { 298 checkClassBinding!(typeof(this))(); 299 return ptrcall!(GodotError)(GDNativeClassBinding.getError, _godot_object); 300 } 301 /** 302 Returns the next 32 bits from the file as a floating-point number. 303 */ 304 double getFloat() const 305 { 306 checkClassBinding!(typeof(this))(); 307 return ptrcall!(double)(GDNativeClassBinding.getFloat, _godot_object); 308 } 309 /** 310 Returns the size of the file in bytes. 311 */ 312 long getLen() const 313 { 314 checkClassBinding!(typeof(this))(); 315 return ptrcall!(long)(GDNativeClassBinding.getLen, _godot_object); 316 } 317 /** 318 Returns the next line of the file as a $(D String). 319 Text is interpreted as being UTF-8 encoded. 320 */ 321 String getLine() const 322 { 323 checkClassBinding!(typeof(this))(); 324 return ptrcall!(String)(GDNativeClassBinding.getLine, _godot_object); 325 } 326 /** 327 Returns an MD5 String representing the file at the given path or an empty $(D String) on failure. 328 */ 329 String getMd5(in String path) const 330 { 331 checkClassBinding!(typeof(this))(); 332 return ptrcall!(String)(GDNativeClassBinding.getMd5, _godot_object, path); 333 } 334 /** 335 Returns the last time the `file` was modified in unix timestamp format or returns a $(D String) "ERROR IN `file`". This unix timestamp can be converted to datetime by using $(D OS.getDatetimeFromUnixTime). 336 */ 337 long getModifiedTime(in String file) const 338 { 339 checkClassBinding!(typeof(this))(); 340 return ptrcall!(long)(GDNativeClassBinding.getModifiedTime, _godot_object, file); 341 } 342 /** 343 Returns a $(D String) saved in Pascal format from the file. 344 Text is interpreted as being UTF-8 encoded. 345 */ 346 String getPascalString() 347 { 348 checkClassBinding!(typeof(this))(); 349 return ptrcall!(String)(GDNativeClassBinding.getPascalString, _godot_object); 350 } 351 /** 352 Returns the path as a $(D String) for the current open file. 353 */ 354 String getPath() const 355 { 356 checkClassBinding!(typeof(this))(); 357 return ptrcall!(String)(GDNativeClassBinding.getPath, _godot_object); 358 } 359 /** 360 Returns the absolute path as a $(D String) for the current open file. 361 */ 362 String getPathAbsolute() const 363 { 364 checkClassBinding!(typeof(this))(); 365 return ptrcall!(String)(GDNativeClassBinding.getPathAbsolute, _godot_object); 366 } 367 /** 368 Returns the file cursor's position. 369 */ 370 long getPosition() const 371 { 372 checkClassBinding!(typeof(this))(); 373 return ptrcall!(long)(GDNativeClassBinding.getPosition, _godot_object); 374 } 375 /** 376 Returns the next bits from the file as a floating-point number. 377 */ 378 double getReal() const 379 { 380 checkClassBinding!(typeof(this))(); 381 return ptrcall!(double)(GDNativeClassBinding.getReal, _godot_object); 382 } 383 /** 384 Returns a SHA-256 $(D String) representing the file at the given path or an empty $(D String) on failure. 385 */ 386 String getSha256(in String path) const 387 { 388 checkClassBinding!(typeof(this))(); 389 return ptrcall!(String)(GDNativeClassBinding.getSha256, _godot_object, path); 390 } 391 /** 392 Returns the next $(D Variant) value from the file. If `allow_objects` is `true`, decoding objects is allowed. 393 $(B 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. 394 */ 395 Variant getVar(in bool allow_objects = false) const 396 { 397 checkClassBinding!(typeof(this))(); 398 return ptrcall!(Variant)(GDNativeClassBinding.getVar, _godot_object, allow_objects); 399 } 400 /** 401 Returns `true` if the file is currently opened. 402 */ 403 bool isOpen() const 404 { 405 checkClassBinding!(typeof(this))(); 406 return ptrcall!(bool)(GDNativeClassBinding.isOpen, _godot_object); 407 } 408 /** 409 Opens the file for writing or reading, depending on the flags. 410 */ 411 GodotError open(in String path, in long flags) 412 { 413 checkClassBinding!(typeof(this))(); 414 return ptrcall!(GodotError)(GDNativeClassBinding.open, _godot_object, path, flags); 415 } 416 /** 417 Opens a compressed file for reading or writing. 418 $(B Note:) $(D openCompressed) can only read files that were saved by Godot, not third-party compression formats. See $(D url=https://github.com/godotengine/godot/issues/28999)GitHub issue #28999$(D /url) for a workaround. 419 */ 420 GodotError openCompressed(in String path, in long mode_flags, in long compression_mode = 0) 421 { 422 checkClassBinding!(typeof(this))(); 423 return ptrcall!(GodotError)(GDNativeClassBinding.openCompressed, _godot_object, path, mode_flags, compression_mode); 424 } 425 /** 426 Opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it. 427 $(B Note:) The provided key must be 32 bytes long. 428 */ 429 GodotError openEncrypted(in String path, in long mode_flags, in PoolByteArray key) 430 { 431 checkClassBinding!(typeof(this))(); 432 return ptrcall!(GodotError)(GDNativeClassBinding.openEncrypted, _godot_object, path, mode_flags, key); 433 } 434 /** 435 Opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it. 436 */ 437 GodotError openEncryptedWithPass(in String path, in long mode_flags, in String pass) 438 { 439 checkClassBinding!(typeof(this))(); 440 return ptrcall!(GodotError)(GDNativeClassBinding.openEncryptedWithPass, _godot_object, path, mode_flags, pass); 441 } 442 /** 443 Changes the file reading/writing cursor to the specified position (in bytes from the beginning of the file). 444 */ 445 void seek(in long position) 446 { 447 checkClassBinding!(typeof(this))(); 448 ptrcall!(void)(GDNativeClassBinding.seek, _godot_object, position); 449 } 450 /** 451 Changes the file reading/writing cursor to the specified position (in bytes from the end of the file). 452 $(B Note:) This is an offset, so you should use negative numbers or the cursor will be at the end of the file. 453 */ 454 void seekEnd(in long position = 0) 455 { 456 checkClassBinding!(typeof(this))(); 457 ptrcall!(void)(GDNativeClassBinding.seekEnd, _godot_object, position); 458 } 459 /** 460 461 */ 462 void setEndianSwap(in bool enable) 463 { 464 checkClassBinding!(typeof(this))(); 465 ptrcall!(void)(GDNativeClassBinding.setEndianSwap, _godot_object, enable); 466 } 467 /** 468 Stores an integer as 16 bits in the file. 469 $(B Note:) The `value` should lie in the interval `$(D 0, 2^16 - 1)`. Any other value will overflow and wrap around. 470 To store a signed integer, use $(D store64) or store a signed integer from the interval `$(D -2^15, 2^15 - 1)` (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example: 471 472 473 const MAX_15B = 1 << 15 474 const MAX_16B = 1 << 16 475 476 func unsigned16_to_signed(unsigned): 477 return (unsigned + MAX_15B) % MAX_16B - MAX_15B 478 479 func _ready(): 480 var f = File.new() 481 f.open("user://file.dat", File.WRITE_READ) 482 f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42). 483 f.store_16(121) # In bounds, will store 121. 484 f.seek(0) # Go back to start to read the stored value. 485 var read1 = f.get_16() # 65494 486 var read2 = f.get_16() # 121 487 var converted1 = unsigned16_to_signed(read1) # -42 488 var converted2 = unsigned16_to_signed(read2) # 121 489 490 491 */ 492 void store16(in long value) 493 { 494 checkClassBinding!(typeof(this))(); 495 ptrcall!(void)(GDNativeClassBinding.store16, _godot_object, value); 496 } 497 /** 498 Stores an integer as 32 bits in the file. 499 $(B Note:) The `value` should lie in the interval `$(D 0, 2^32 - 1)`. Any other value will overflow and wrap around. 500 To store a signed integer, use $(D store64), or convert it manually (see $(D store16) for an example). 501 */ 502 void store32(in long value) 503 { 504 checkClassBinding!(typeof(this))(); 505 ptrcall!(void)(GDNativeClassBinding.store32, _godot_object, value); 506 } 507 /** 508 Stores an integer as 64 bits in the file. 509 $(B Note:) The `value` must lie in the interval `$(D -2^63, 2^63 - 1)` (i.e. be a valid $(D long) value). 510 */ 511 void store64(in long value) 512 { 513 checkClassBinding!(typeof(this))(); 514 ptrcall!(void)(GDNativeClassBinding.store64, _godot_object, value); 515 } 516 /** 517 Stores an integer as 8 bits in the file. 518 $(B Note:) The `value` should lie in the interval `$(D 0, 255)`. Any other value will overflow and wrap around. 519 To store a signed integer, use $(D store64), or convert it manually (see $(D store16) for an example). 520 */ 521 void store8(in long value) 522 { 523 checkClassBinding!(typeof(this))(); 524 ptrcall!(void)(GDNativeClassBinding.store8, _godot_object, value); 525 } 526 /** 527 Stores the given array of bytes in the file. 528 */ 529 void storeBuffer(in PoolByteArray buffer) 530 { 531 checkClassBinding!(typeof(this))(); 532 ptrcall!(void)(GDNativeClassBinding.storeBuffer, _godot_object, buffer); 533 } 534 /** 535 Store the given $(D PoolStringArray) 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. 536 Text will be encoded as UTF-8. 537 */ 538 void storeCsvLine(in PoolStringArray values, in String delim = gs!",") 539 { 540 checkClassBinding!(typeof(this))(); 541 ptrcall!(void)(GDNativeClassBinding.storeCsvLine, _godot_object, values, delim); 542 } 543 /** 544 Stores a floating-point number as 64 bits in the file. 545 */ 546 void storeDouble(in double value) 547 { 548 checkClassBinding!(typeof(this))(); 549 ptrcall!(void)(GDNativeClassBinding.storeDouble, _godot_object, value); 550 } 551 /** 552 Stores a floating-point number as 32 bits in the file. 553 */ 554 void storeFloat(in double value) 555 { 556 checkClassBinding!(typeof(this))(); 557 ptrcall!(void)(GDNativeClassBinding.storeFloat, _godot_object, value); 558 } 559 /** 560 Appends `line` to the file followed by a line return character (`\n`), encoding the text as UTF-8. 561 */ 562 void storeLine(in String line) 563 { 564 checkClassBinding!(typeof(this))(); 565 ptrcall!(void)(GDNativeClassBinding.storeLine, _godot_object, line); 566 } 567 /** 568 Stores the given $(D String) as a line in the file in Pascal format (i.e. also store the length of the string). 569 Text will be encoded as UTF-8. 570 */ 571 void storePascalString(in String string) 572 { 573 checkClassBinding!(typeof(this))(); 574 ptrcall!(void)(GDNativeClassBinding.storePascalString, _godot_object, string); 575 } 576 /** 577 Stores a floating-point number in the file. 578 */ 579 void storeReal(in double value) 580 { 581 checkClassBinding!(typeof(this))(); 582 ptrcall!(void)(GDNativeClassBinding.storeReal, _godot_object, value); 583 } 584 /** 585 Appends `string` to the file without a line return, encoding the text as UTF-8. 586 */ 587 void storeString(in String string) 588 { 589 checkClassBinding!(typeof(this))(); 590 ptrcall!(void)(GDNativeClassBinding.storeString, _godot_object, string); 591 } 592 /** 593 Stores any Variant value in the file. If `full_objects` is `true`, encoding objects is allowed (and can potentially include code). 594 $(B Note:) Not all properties are included. Only properties that are configured with the $(D constant PROPERTY_USAGE_STORAGE) flag set will be serialized. You can add a new usage flag to a property by overriding the $(D GodotObject._getPropertyList) method in your class. You can also check how property usage is configured by calling $(D GodotObject._getPropertyList). See $(D propertyusageflags) for the possible usage flags. 595 */ 596 void storeVar(VariantArg0)(in VariantArg0 value, in bool full_objects = false) 597 { 598 checkClassBinding!(typeof(this))(); 599 ptrcall!(void)(GDNativeClassBinding.storeVar, _godot_object, value, full_objects); 600 } 601 /** 602 If `true`, the file is read with big-endian $(D url=https://en.wikipedia.org/wiki/Endianness)endianness$(D /url). 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. 603 $(B Note:) $(D endianSwap) is only about the file format, not the CPU type. The CPU endianness doesn't affect the default endianness for files written. 604 $(B Note:) This is always reset to `false` whenever you open the file. Therefore, you must set $(D endianSwap) $(I after) opening the file, not before. 605 */ 606 @property bool endianSwap() 607 { 608 return getEndianSwap(); 609 } 610 /// ditto 611 @property void endianSwap(bool v) 612 { 613 setEndianSwap(v); 614 } 615 }