FileAccess

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

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 storing game save data or player configuration files.

Example: How to write and read from a file. The file named "save_game.dat" will be stored in the user data folder, as specified in the Data paths documentation:

package main

import "graphics.gd/classdb/FileAccess"

func SaveToFile(content string) {
	var file = FileAccess.Open("user://save_game.dat", FileAccess.Write)
	file.StoreString(content)
}

func LoadFromFile() string {
	var file = FileAccess.Open("user://save_game.dat", FileAccess.Read)
	var content = file.GetAsText()
	return content
}

A FileAccess instance has its own file cursor, which is the position in bytes in the file where the next read/write operation will occur. Functions such as Get8, Get16, Store8, and Store16 will move the file cursor forward by the number of bytes read/written. The file cursor can be moved to a specific position using SeekTo or SeekEnd, and its position can be retrieved using GetPosition.

A FileAccess instance will close its file when the instance is freed. Since it inherits RefCounted, this happens automatically when it is no longer in use. Close can be called to close it earlier. In C#, the reference must be disposed manually, which can be done with the using statement or by calling the Dispose method directly.

Note: To access project resources once exported, it is recommended to use 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. If using FileAccess, make sure the file is included in the export by changing its import mode to Keep File (exported as is) in the Import dock, or, for files where this option is not available, change the non-resource export filter in the Export dialog to include the file's extension (e.g. *.txt).

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 Flush at regular intervals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path string) bool

Returns true if the file exists in the given path.

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 ResourceLoader.Exists for an alternative approach that takes resource remapping into account.

For a non-static, relative equivalent, use DirAccess.FileExists.

func GetAccessTime

func GetAccessTime(file string) int

Returns the last time the 'file' was accessed in Unix timestamp format, or 0 on error. This Unix timestamp can be converted to another format using the Time singleton.

func GetFileAsBytes

func GetFileAsBytes(path string) []byte

Returns the whole 'path' file contents as a []byte without any decoding.

Returns an empty []byte if an error occurred while opening the file. You can use GetOpenError to check the error that occurred.

func GetFileAsString

func GetFileAsString(path string) string

Returns the whole 'path' file contents as a string. Text is interpreted as being UTF-8 encoded.

Returns an empty string if an error occurred while opening the file. You can use GetOpenError to check the error that occurred.

func GetHiddenAttribute

func GetHiddenAttribute(file string) bool

Returns true, if file hidden attribute is set.

Note: This method is implemented on iOS, BSD, macOS, and Windows.

func GetMd5

func GetMd5(path string) string

Returns an MD5 String representing the file at the given path or an empty string on failure.

func GetModifiedTime

func GetModifiedTime(file string) int

Returns the last time the 'file' was modified in Unix timestamp format, or 0 on error. This Unix timestamp can be converted to another format using the Time singleton.

func GetOpenError

func GetOpenError() error

Returns the result of the last Open call in the current thread.

func GetReadOnlyAttribute

func GetReadOnlyAttribute(file string) bool

Returns true, if file read only attribute is set.

Note: This method is implemented on iOS, BSD, macOS, and Windows.

func GetSha256

func GetSha256(path string) string

Returns an SHA-256 string representing the file at the given path or an empty string on failure.

func GetSize

func GetSize(file string) int

Returns file size in bytes, or -1 on error.

func SetHiddenAttribute

func SetHiddenAttribute(file string, hidden bool) error

Sets file hidden attribute.

Note: This method is implemented on iOS, BSD, macOS, and Windows.

func SetReadOnlyAttribute

func SetReadOnlyAttribute(file string, ro bool) error

Sets file read only attribute.

Note: This method is implemented on iOS, BSD, macOS, and Windows.

func SetUnixPermissions

func SetUnixPermissions(file string, permissions UnixPermissionFlags) error

Sets file UNIX permissions.

Note: This method is implemented on iOS, Linux/BSD, and macOS.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsFileAccess() Instance
}

type CompressionMode

type CompressionMode int //gd:FileAccess.CompressionMode
const (
	// Uses the [FastLZ] compression method.
	//
	// [FastLZ]: https://fastlz.org/
	CompressionFastlz CompressionMode = 0
	// Uses the [DEFLATE] compression method.
	//
	// [DEFLATE]: https://en.wikipedia.org/wiki/DEFLATE
	CompressionDeflate CompressionMode = 1
	// Uses the [Zstandard] compression method.
	//
	// [Zstandard]: https://facebook.github.io/zstd/
	CompressionZstd CompressionMode = 2
	// Uses the [gzip] compression method.
	//
	// [gzip]: https://www.gzip.org/
	CompressionGzip CompressionMode = 3
	// Uses the [brotli] compression method (only decompression is supported).
	//
	// [brotli]: https://github.com/google/brotli
	CompressionBrotli CompressionMode = 4
)

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsFileAccess

func (self *Extension[T]) AsFileAccess() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.FileAccess

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func CreateTemp

func CreateTemp(mode_flags int, prefix string, extension string, keep bool) Instance

Creates a temporary file. This file will be freed when the returned FileAccess is freed.

If 'prefix' is not empty, it will be prefixed to the file name, separated by a -.

If 'extension' is not empty, it will be appended to the temporary file name.

If 'keep' is true, the file is not deleted when the returned FileAccess is freed.

Returns null if opening the file failed. You can use GetOpenError to check the error that occurred.

func New

func New() Instance

func Open

func Open(path string, flags ModeFlags) Instance

Creates a new FileAccess object and opens the file for writing or reading, depending on the flags.

Returns null if opening the file failed. You can use GetOpenError to check the error that occurred.

func OpenCompressed

func OpenCompressed(path string, mode_flags ModeFlags, compression_mode CompressionMode) Instance

Creates a new FileAccess object and opens a compressed file for reading or writing.

Note: OpenCompressed can only read files that were saved by Godot, not third-party compression formats. See GitHub issue #28999 for a workaround.

Returns null if opening the file failed. You can use GetOpenError to check the error that occurred.

func OpenEncrypted

func OpenEncrypted(path string, mode_flags ModeFlags, key []byte, iv []byte) Instance

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.

Note: The provided key must be 32 bytes long.

Returns null if opening the file failed. You can use GetOpenError to check the error that occurred.

func OpenEncryptedWithPass

func OpenEncryptedWithPass(path string, mode_flags ModeFlags, pass string) Instance

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.

Returns null if opening the file failed. You can use GetOpenError to check the error that occurred.

func (Instance) AsFileAccess

func (self Instance) AsFileAccess() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) BigEndian

func (self Instance) BigEndian() bool

func (Instance) Close

func (self Instance) Close()

Closes the currently opened file and prevents subsequent read/write operations. Use Flush to persist the data to disk without closing the file.

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.

func (Instance) EofReached

func (self Instance) EofReached() bool

Returns true if the file cursor has already read past the end of the file.

Note: eof_reached() == false cannot be used to check whether there is more data available. To loop while there is more data available, use:

func (Instance) Flush

func (self Instance) Flush()

Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call Flush manually before closing a file. Still, calling Flush can be used to ensure the data is safe even if the project crashes instead of being closed gracefully.

Note: Only call Flush when you actually need it. Otherwise, it will decrease performance due to constant disk writes.

func (Instance) Get16

func (self Instance) Get16() int

Returns the next 16 bits from the file as an integer. This advances the file cursor by 2 bytes. See Store16 for details on what values can be stored and retrieved this way.

func (Instance) Get32

func (self Instance) Get32() int

Returns the next 32 bits from the file as an integer. This advances the file cursor by 4 bytes. See Store32 for details on what values can be stored and retrieved this way.

func (Instance) Get64

func (self Instance) Get64() int

Returns the next 64 bits from the file as an integer. This advances the file cursor by 8 bytes. See Store64 for details on what values can be stored and retrieved this way.

func (Instance) Get8

func (self Instance) Get8() int

Returns the next 8 bits from the file as an integer. This advances the file cursor by 1 byte. See Store8 for details on what values can be stored and retrieved this way.

func (Instance) GetAsText

func (self Instance) GetAsText() string

Returns the whole file as a string. Text is interpreted as being UTF-8 encoded. This ignores the file cursor and does not affect it.

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).

func (Instance) GetBuffer

func (self Instance) GetBuffer(length int) []byte

Returns next 'length' bytes of the file as a []byte. This advances the file cursor by 'length' bytes.

func (Instance) GetCsvLine

func (self Instance) GetCsvLine() []string

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.

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. This advances the file cursor to after the newline character at the end of the line.

For example, the following CSV lines are valid and will be properly parsed as two strings each:

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.

func (Instance) GetDouble

func (self Instance) GetDouble() Float.X

Returns the next 64 bits from the file as a floating-point number. This advances the file cursor by 8 bytes.

func (Instance) GetError

func (self Instance) GetError() error

Returns the last error that happened when trying to perform operations. Compare with the ERR_FILE_* constants from [Error].

func (Instance) GetFloat

func (self Instance) GetFloat() Float.X

Returns the next 32 bits from the file as a floating-point number. This advances the file cursor by 4 bytes.

func (Instance) GetHalf

func (self Instance) GetHalf() Float.X

Returns the next 16 bits from the file as a half-precision floating-point number. This advances the file cursor by 2 bytes.

func (Instance) GetLength

func (self Instance) GetLength() int

Returns the size of the file in bytes. For a pipe, returns the number of bytes available for reading from the pipe.

func (Instance) GetLine

func (self Instance) GetLine() string

Returns the next line of the file as a string. The returned string doesn't include newline (\n) or carriage return (\r) characters, but does include any other leading or trailing whitespace. This advances the file cursor to after the newline character at the end of the line.

Text is interpreted as being UTF-8 encoded.

func (Instance) GetPascalString

func (self Instance) GetPascalString() string

Returns a string saved in Pascal format from the file, meaning that the length of the string is explicitly stored at the start. See StorePascalString. This may include newline characters. The file cursor is advanced after the bytes read.

Text is interpreted as being UTF-8 encoded.

func (Instance) GetPath

func (self Instance) GetPath() string

Returns the path as a string for the current open file.

func (Instance) GetPathAbsolute

func (self Instance) GetPathAbsolute() string

Returns the absolute path as a string for the current open file.

func (Instance) GetPosition

func (self Instance) GetPosition() int

Returns the file cursor's position in bytes from the beginning of the file. This is the file reading/writing cursor set by SeekTo or SeekEnd and advanced by read/write operations.

func (Instance) GetReal

func (self Instance) GetReal() Float.X

Returns the next bits from the file as a floating-point number. This advances the file cursor by either 4 or 8 bytes, depending on the precision used by the Godot build that saved the file.

If the file was saved by a Godot build compiled with the precision=single option (the default), the number of read bits for that file is 32. Otherwise, if compiled with the precision=double option, the number of read bits is 64.

func (Instance) GetVar

func (self Instance) GetVar() any

Returns the next any value from the file. If 'allow_objects' is true, decoding objects is allowed. This advances the file cursor by the number of bytes read.

Internally, this uses the same decoding mechanism as the @GlobalScope.BytesToVar method, as described in the Binary serialization API documentation.

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.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsOpen

func (self Instance) IsOpen() bool

Returns true if the file is currently opened.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) Resize

func (self Instance) Resize(length int) error

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.

func (Instance) SeekEnd

func (self Instance) SeekEnd()

Changes the file reading/writing cursor to the specified position (in bytes from the end of the file). This changes the value returned by GetPosition.

Note: This is an offset, so you should use negative numbers or the file cursor will be at the end of the file.

func (Instance) SeekTo

func (self Instance) SeekTo(position int)

Changes the file reading/writing cursor to the specified position (in bytes from the beginning of the file). This changes the value returned by GetPosition.

func (Instance) SetBigEndian

func (self Instance) SetBigEndian(value bool)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Store16

func (self Instance) Store16(value int) bool

Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. Returns true if the operation is successful.

Note: The 'value' should lie in the interval [0, 2^16 - 1]. Any other value will overflow and wrap around.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

To store a signed integer, use Store64 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:

func (Instance) Store32

func (self Instance) Store32(value int) bool

Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. Returns true if the operation is successful.

Note: The 'value' should lie in the interval [0, 2^32 - 1]. Any other value will overflow and wrap around.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

To store a signed integer, use Store64, or convert it manually (see Store16 for an example).

func (Instance) Store64

func (self Instance) Store64(value int) bool

Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. Returns true if the operation is successful.

Note: The 'value' must lie in the interval [-2^63, 2^63 - 1] (i.e. be a valid int value).

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) Store8

func (self Instance) Store8(value int) bool

Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. Returns true if the operation is successful.

Note: The 'value' should lie in the interval [0, 255]. Any other value will overflow and wrap around.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

To store a signed integer, use Store64, or convert it manually (see Store16 for an example).

func (Instance) StoreBuffer

func (self Instance) StoreBuffer(buffer []byte) bool

Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreCsvLine

func (self Instance) StoreCsvLine(values []string) bool

Store the given []string 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.

Text will be encoded as UTF-8. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreDouble

func (self Instance) StoreDouble(value Float.X) bool

Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreFloat

func (self Instance) StoreFloat(value Float.X) bool

Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreHalf

func (self Instance) StoreHalf(value Float.X) bool

Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreLine

func (self Instance) StoreLine(line string) bool

Stores 'line' in the file followed by a newline character (\n), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from String.Length which counts the number of UTF-32 codepoints. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StorePascalString

func (self Instance) StorePascalString(s string) bool

Stores the given string as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from String.Length which counts the number of UTF-32 codepoints. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreReal

func (self Instance) StoreReal(value Float.X) bool

Stores a floating-point number in the file. This advances the file cursor by either 4 or 8 bytes, depending on the precision used by the current Godot build.

If using a Godot build compiled with the precision=single option (the default), this method will save a 32-bit float. Otherwise, if compiled with the precision=double option, this will save a 64-bit float. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreString

func (self Instance) StoreString(s string) bool

Stores 'string' in the file without a newline character (\n), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from String.Length which counts the number of UTF-32 codepoints. Returns true if the operation is successful.

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 StorePascalString instead. For retrieving strings from a text file, you can use get_buffer(length).get_string_from_utf8() (if you know the length) or GetAsText.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) StoreVar

func (self Instance) StoreVar(value any) bool

Stores any Variant value in the file. If 'full_objects' is true, encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. Returns true if the operation is successful.

Internally, this uses the same encoding mechanism as the @GlobalScope.VarToBytes method, as described in the Binary serialization API documentation.

Note: Not all properties are included. Only properties that are configured with the [PropertyUsageStorage] flag set will be serialized. You can add a new usage flag to a property by overriding the Object.GetPropertyList method in your class. You can also check how property usage is configured by calling Object.GetPropertyList. See [PropertyUsageFlags] for the possible usage flags.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type ModeFlags

type ModeFlags int //gd:FileAccess.ModeFlags
const (
	// Opens the file for read operations. The file cursor is positioned at the beginning of the file.
	Read ModeFlags = 1
	// Opens the file for write operations. The file is created if it does not exist, and truncated if it does.
	//
	// Note: When creating a file it must be in an already existing directory. To recursively create directories for a file path, see [DirAccess.MakeDirRecursive].
	//
	// [DirAccess.MakeDirRecursive]: https://pkg.go.dev/graphics.gd/classdb/DirAccess#Instance.MakeDirRecursive
	Write ModeFlags = 2
	// Opens the file for read and write operations. Does not truncate the file. The file cursor is positioned at the beginning of the file.
	ReadWrite ModeFlags = 3
	// Opens the file for read and write operations. The file is created if it does not exist, and truncated if it does. The file cursor is positioned at the beginning of the file.
	//
	// Note: When creating a file it must be in an already existing directory. To recursively create directories for a file path, see [DirAccess.MakeDirRecursive].
	//
	// [DirAccess.MakeDirRecursive]: https://pkg.go.dev/graphics.gd/classdb/DirAccess#Instance.MakeDirRecursive
	WriteRead ModeFlags = 7
)

type MoreArgs

type MoreArgs [1]gdclass.FileAccess

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) GetAsText

func (self MoreArgs) GetAsText(skip_cr bool) string

Returns the whole file as a string. Text is interpreted as being UTF-8 encoded. This ignores the file cursor and does not affect it.

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).

func (MoreArgs) GetCsvLine

func (self MoreArgs) GetCsvLine(delim string) []string

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.

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. This advances the file cursor to after the newline character at the end of the line.

For example, the following CSV lines are valid and will be properly parsed as two strings each:

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.

func (MoreArgs) GetVar

func (self MoreArgs) GetVar(allow_objects bool) any

Returns the next any value from the file. If 'allow_objects' is true, decoding objects is allowed. This advances the file cursor by the number of bytes read.

Internally, this uses the same decoding mechanism as the @GlobalScope.BytesToVar method, as described in the Binary serialization API documentation.

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.

func (MoreArgs) SeekEnd

func (self MoreArgs) SeekEnd(position int)

Changes the file reading/writing cursor to the specified position (in bytes from the end of the file). This changes the value returned by GetPosition.

Note: This is an offset, so you should use negative numbers or the file cursor will be at the end of the file.

func (MoreArgs) StoreCsvLine

func (self MoreArgs) StoreCsvLine(values []string, delim string) bool

Store the given []string 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.

Text will be encoded as UTF-8. Returns true if the operation is successful.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

func (MoreArgs) StoreVar

func (self MoreArgs) StoreVar(value any, full_objects bool) bool

Stores any Variant value in the file. If 'full_objects' is true, encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. Returns true if the operation is successful.

Internally, this uses the same encoding mechanism as the @GlobalScope.VarToBytes method, as described in the Binary serialization API documentation.

Note: Not all properties are included. Only properties that are configured with the [PropertyUsageStorage] flag set will be serialized. You can add a new usage flag to a property by overriding the Object.GetPropertyList method in your class. You can also check how property usage is configured by calling Object.GetPropertyList. See [PropertyUsageFlags] for the possible usage flags.

Note: If an error occurs, the resulting value of the file position indicator is indeterminate.

type UnixPermissionFlags

type UnixPermissionFlags int //gd:FileAccess.UnixPermissionFlags
const (
	// Read for owner bit.
	UnixReadOwner UnixPermissionFlags = 256
	// Write for owner bit.
	UnixWriteOwner UnixPermissionFlags = 128
	// Execute for owner bit.
	UnixExecuteOwner UnixPermissionFlags = 64
	// Read for group bit.
	UnixReadGroup UnixPermissionFlags = 32
	// Write for group bit.
	UnixWriteGroup UnixPermissionFlags = 16
	// Execute for group bit.
	UnixExecuteGroup UnixPermissionFlags = 8
	// Read for other bit.
	UnixReadOther UnixPermissionFlags = 4
	// Write for other bit.
	UnixWriteOther UnixPermissionFlags = 2
	// Execute for other bit.
	UnixExecuteOther UnixPermissionFlags = 1
	// Set user id on execution bit.
	UnixSetUserId UnixPermissionFlags = 2048
	// Set group id on execution bit.
	UnixSetGroupId UnixPermissionFlags = 1024
	// Restricted deletion (sticky) bit.
	UnixRestrictedDelete UnixPermissionFlags = 512
)

func GetUnixPermissions

func GetUnixPermissions(file string) UnixPermissionFlags

Returns file UNIX permissions.

Note: This method is implemented on iOS, Linux/BSD, and macOS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL