API reference
GDFileStream
Reader, Writer, and Closer for ordered incremental access to a regular file. Separate streams proceed concurrently.
Methods
read(max: int = 32768) -> PackedByteArray, Errread_async(max: int = 32768) -> await PackedByteArray, Errwrite(data: PackedByteArray) -> int, Errwrite_async(data: PackedByteArray) -> await int, Errseek(offset: int) -> Variant, Errseek_async(offset: int) -> await Variant, Errclose() -> Variant, Errclose_async() -> await Variant, Erris_open() -> bool
read
read(max: int = 32768) -> PackedByteArray, ErrRead up to the requested bytes; an empty success result denotes EOF when the requested count is positive.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max | int | 32768 | Maximum bytes requested by one read. |
Return value
PackedByteArray, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
read_async
read_async(max: int = 32768) -> await PackedByteArray, ErrRead up to the requested bytes; an empty success result denotes EOF when the requested count is positive.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max | int | 32768 | Maximum bytes requested by one read. |
Return value
await PackedByteArray, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
write
write(data: PackedByteArray) -> int, ErrWrite all supplied bytes and return the written count.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
Return value
int, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
write_async
write_async(data: PackedByteArray) -> await int, ErrWrite all supplied bytes and return the written count.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
Return value
await int, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
seek
seek(offset: int) -> Variant, ErrMove the next I/O position to a byte offset from the start.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
offset | int | Required | Zero-based starting position, in bytes unless the method explicitly operates on text characters. |
Return value
Variant, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
seek_async
seek_async(offset: int) -> await Variant, ErrMove the next I/O position to a byte offset from the start.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
offset | int | Required | Zero-based starting position, in bytes unless the method explicitly operates on text characters. |
Return value
await Variant, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
close
close() -> Variant, ErrClose the file after preceding operations.
Parameters
No parameters.
Return value
Variant, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
close_async
close_async() -> await Variant, ErrClose the file after preceding operations.
Parameters
No parameters.
Return value
await Variant, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
is_open
is_open() -> boolReturn whether the file has been opened and closing has not started.
Parameters
No parameters.
Return value
bool
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.