diff options
Diffstat (limited to 'doc/classes/FileAccess.xml')
-rw-r--r-- | doc/classes/FileAccess.xml | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index fad6cbcc93..99574da808 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -8,23 +8,23 @@ Here's a sample on how to write and read from a file: [codeblocks] [gdscript] - func save(content): + func save_to_file(content): var file = FileAccess.open("user://save_game.dat", FileAccess.WRITE) file.store_string(content) - func load(): + func load_from_file(): var file = FileAccess.open("user://save_game.dat", FileAccess.READ) var content = file.get_as_text() return content [/gdscript] [csharp] - public void Save(string content) + public void SaveToFile(string content) { using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write); file.StoreString(content); } - public string Load() + public string LoadFromFile() { using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read); string content = file.GetAsText(); @@ -40,7 +40,7 @@ <tutorials> <link title="File system">$DOCS_URL/tutorials/scripting/filesystem.html</link> <link title="Runtime file loading and saving">$DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html</link> - <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link> + <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/2755</link> </tutorials> <methods> <method name="close"> @@ -131,7 +131,7 @@ Returns the next value of the file in CSV (Comma-Separated Values) format. You can pass a different delimiter [param delim] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long, and cannot be a double quotation mark. 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. For example, the following CSV lines are valid and will be properly parsed as two strings each: - [codeblock] + [codeblock lang=text] Alice,"Hello, Bob!" Bob,Alice! What a surprise! Alice,"I thought you'd reply with ""Hello, world""." @@ -190,7 +190,7 @@ <method name="get_line" qualifiers="const"> <return type="String" /> <description> - Returns the next line of the file as a [String]. + Returns the next line of the file as a [String]. The returned string doesn't include newline ([code]\n[/code]) or carriage return ([code]\r[/code]) characters, but does include any other leading or trailing whitespace. Text is interpreted as being UTF-8 encoded. </description> </method> @@ -324,6 +324,13 @@ Returns [code]null[/code] if opening the file failed. You can use [method get_open_error] to check the error that occurred. </description> </method> + <method name="resize"> + <return type="int" enum="Error" /> + <param index="0" name="length" type="int" /> + <description> + Resizes the file to a specified length. The file must be open in a mode that permits writing. If the file is extended, NUL characters are appended. If the file is truncated, all data from the end file to the original length of the file is lost. + </description> + </method> <method name="seek"> <return type="void" /> <param index="0" name="position" type="int" /> |