FileAccess
File access with explicit modes, byte formats and error checks.
FileAccess reads and writes OS paths, asset:// and user://. Use user:// for progress; load imported project assets through ResourceLoader instead of assuming original files remain accessible after export.
Check Open() for null and immediately read GetOpenError() on the same thread. Release owned handles with using. Write/WriteRead truncate existing files; ReadWrite retains contents and starts at position 0. Create parent directories separately.
Positions and lengths are bytes. Check actual GetBuffer() length and write results; a numeric value or empty string alone proves no success. GetAsText() reads the whole file and restores the cursor; EofReached() indicates reading past end. BigEndian concerns numeric fields, not arbitrary bytes/UTF-8.
Behavior depends on the handle: ordinary Windows Flush() flushes output buffering, while compressed/encrypted containers retain writes in memory until close. None is a general power-loss guarantee. Encrypted Write has a reproduced limitation: an invalid key can be detected after destination truncation.
UTF-8 reading and diagnosis, binary slot, saving with a backup. Tests ran on Windows in isolated projects; temporary files were source-reviewed, while encryption security and other platforms were not certified.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
BigEndianProperty
public bool BigEndian { get; set; }Byte-order setting for numeric Get/Store operations on this handle: false is little-endian, true big-endian. A new Open() has a fresh false-default handle; the setting is not stored as file metadata. Does not reorder GetBuffer/StoreBuffer bytes or UTF-8 text. StoreVar/GetVar applies it to the 32-bit length prefix, not the inner Variant payload; tested. Reader and writer must agree on the format.
Methods76
Closevoid
public void Close();Closes this handle file; using/Dispose of an owned wrapper also ends its use. Do not read, seek or call EofReached() after closing. Repeated Close() was tested on Windows, but does not reopen; Open() creates another handle. Returns no Error, so closing does not certify reliable persistence.
CreateTemp2 overloads
public static FileAccess CreateTemp(FileAccess.ModeFlags modeFlags, string prefix = "", string extension = "", bool keep = false);Creates a file in OS temp and returns an owned RefCounted handle in the requested mode. Native code first creates it with Write then reopens with that mode, so Read can open a new empty temp file. prefix/extension are filename parts, not paths. On null immediately check GetOpenError(). keep=false enables best-effort deletion of the original temp file on last native-reference release; Close() alone only closes the stream. keep=true preserves the file after release. C# using releases your reference, but other owners can extend lifetime. Cleanup after process failure is not guaranteed; lifecycle was source-reviewed only here.
| Name | Type | Default |
|---|---|---|
modeFlags | FileAccess.ModeFlags | — |
prefix | string | "" |
extension | string | "" |
keep | bool | false |
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
prefixValid filename prefix without path separators; empty is allowed.
extensionValid filename extension, not a directory. Native code removes one leading dot.
keepTrue preserves the temp file after release; false enables best-effort deletion on last native-reference release.
FileAccessOwned temp handle or null; automatic cleanup depends on keep and native references.
public static FileAccess CreateTemp(int modeFlags, string prefix, string extension, bool keep);Creates a file in OS temp and returns an owned RefCounted handle in the requested mode. Native code first creates it with Write then reopens with that mode, so Read can open a new empty temp file. prefix/extension are filename parts, not paths. On null immediately check GetOpenError(). keep=false enables best-effort deletion of the original temp file on last native-reference release; Close() alone only closes the stream. keep=true preserves the file after release. C# using releases your reference, but other owners can extend lifetime. Cleanup after process failure is not guaranteed; lifecycle was source-reviewed only here. The int overload forwards a numeric value as ModeFlags; use only values of that enum.
| Name | Type | Default |
|---|---|---|
modeFlags | int | — |
prefix | string | — |
extension | string | — |
keep | bool | — |
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
prefixValid filename prefix without path separators; empty is allowed.
extensionValid filename extension, not a directory. Native code removes one leading dot.
keepTrue preserves the temp file after release; false enables best-effort deletion on last native-reference release.
FileAccessOwned temp handle or null; automatic cleanup depends on keep and native references.
EofReachedbool
public bool EofReached();Read-past-end indicator, not GetPosition() compared with GetLength(). An exact read of all available bytes leaves false on Windows; the next read attempt sets EOF. An empty line can be a valid blank file line. Use only on an open handle and check actual GetBuffer() length/read results.
boolRead-past-EOF indicator; a cursor exactly at end is insufficient.
FileExistsbool
public static bool FileExists(string path);Tests a file through the backend/packed data; a directory is not a file. False does not distinguish absence from inaccessibility; true guarantees no later Open() and does not replace ResourceLoader for imported resources. Check Open() itself rather than relying on this test alone.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathFile path to test; opening still requires checking its result.
boolTrue if the backend sees a file; false is also possible when inaccessible.
Flushvoid
public void Flush();Flushes an open handle output buffer to its backend without closing it. Windows calls fflush and supplies no separate Error. Call before Resize() after buffered writes, otherwise a later flush can restore the old length; reproduced in testing. Not equivalent to System.IO.FileStream.Flush(true) and not a power-loss guarantee.
Get16ushort
public ushort Get16();Reads an unsigned 16-bit number from 2 bytes at the current cursor. Byte order follows this handle BigEndian; defaults to little-endian. A short read supplies no separate bool and can return a partial value; zero is also valid data. Check record size and GetError(), not the numeric value alone.
ushortUnsigned 16-bit value; a short record may yield a partial value.
Get32uint
public uint Get32();Reads an unsigned 32-bit number from 4 bytes at the current cursor. Byte order follows this handle BigEndian; defaults to little-endian. A short read supplies no separate bool and can return a partial value; zero is also valid data. Check record size and GetError(), not the numeric value alone.
uintUnsigned 32-bit value; a short record may yield a partial value.
Get64ulong
public ulong Get64();Reads an unsigned 64-bit number from 8 bytes at the current cursor. Byte order follows this handle BigEndian; defaults to little-endian. A short read supplies no separate bool and can return a partial value; zero is also valid data. Check record size and GetError(), not the numeric value alone.
ulongUnsigned 64-bit value; a short record may yield a partial value.
Get8byte
public byte Get8();Reads an unsigned 8-bit number from 1 bytes at the current cursor. BigEndian has no effect on one byte. A short read supplies no separate bool and can return a partial value; zero is also valid data. Check record size and GetError(), not the numeric value alone.
byteUnsigned 8-bit value; a short record may yield a partial value.
GetAccessTimeulong
public static ulong GetAccessTime(string file);Access time in whole Unix-epoch seconds. Not a read counter or reliable last-gameplay-action signal: updates depend on OS/filesystem policy. Windows can fall back to creation time when access time is absent; errors can give 0 with a diagnostic. Do not infer accessibility/read permission from this timestamp alone.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
ulongUnix seconds; not guaranteed to update on every read.
GetAsText2 overloads
public string GetAsText();Reads the entire file as UTF-8 from the beginning, then restores the original cursor. Does not read only the remainder. The main overload retains CR; it allocates for the whole content, so bound file size first. Not strict UTF-8/schema validation; for strict decoding read a bounded GetBuffer() and validate separately. Cursor restoration does not guarantee unchanged GetError().
stringEntire-file UTF-8 text; empty alone does not prove success.
public string GetAsText(bool skipCr);Reads the entire file as UTF-8 from the beginning, then restores the original cursor. Does not read only the remainder. The main overload retains CR; it allocates for the whole content, so bound file size first. Not strict UTF-8/schema validation; for strict decoding read a bounded GetBuffer() and validate separately. Cursor restoration does not guarantee unchanged GetError().
| Name | Type | Default |
|---|---|---|
skipCr | bool | — |
skipCrTrue removes all CR, including lone ones, not only CRLF. False retains CR.
stringEntire-file UTF-8 text; empty alone does not prove success.
GetBufferbyte[]
public byte[] GetBuffer(long length);Reads up to length bytes from the current position into a new C# byte[]. At EOF the array can be shorter than requested; check Length for fixed-format data. 0 returns empty without reading; negative length is invalid. Bound allocations beforehand; empty alone does not distinguish a zero request, end or error.
| Name | Type | Default |
|---|---|---|
length | long | — |
lengthRequested byte count >= 0; bound allocation size beforehand.
byte[]New byte[] of actual bytes read, possibly shorter than length.
GetCsvLinestring[]
public string[] GetCsvLine(string delim = ",");Reads a CSV record into string[]; quoted fields can span physical lines. Delimiter must be one non-double-quote character; double embedded quotes inside quoted fields. Line breaks are normalized through GetLine(). A blank line yields one empty field, not an unambiguous EOF signal. Does not validate schema/column count; damaged quotes can produce a diagnostic and a result, so validate records separately.
| Name | Type | Default |
|---|---|---|
delim | string | "," |
delimOne non-double-quote delimiter character for matched reading/writing; not a multicharacter string.
string[]Fields of one CSV record; a blank record normally has one empty field. Validate schema separately.
GetDoubledouble
public double GetDouble();Reads Double from 8 bytes and returns C# double. BigEndian applies through the numeric layout. Does not enforce finite values or gameplay-domain bounds. Check format, remaining record size and I/O status separately; this does not parse a text number.
doubleC# double; the numeric value alone proves no complete successful read.
GetErrorError
public Error GetError();Last backend status of this handle, not the last Open() error. Inspect immediately after an operation. On Windows a successful Seek() can clear the EOF indicator while GetError() retains FileEof; a later successful read refreshes it. Do not treat stale status as a new failure or ignore the current operation bool/returned length.
ErrorLast updated backend Error; may remain from an earlier operation.
GetExtendedAttributebyte[]
public static byte[] GetExtendedAttribute(string file, string attributeName);Reads named extended attribute/stream bytes through the backend; Windows uses an alternate data stream. Empty byte[] does not distinguish an empty value, absent name, failure or unsupported backend. The name list adds information but is not an atomic check. Raw data written by SetExtendedAttributeString() can include a trailing NUL.
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
byte[]New value byte[]; empty is not an unambiguous diagnostic.
GetExtendedAttributeStringstring
public static string GetExtendedAttributeString(string file, string attributeName);Gets named bytes and decodes UTF-8. Not strict text validation; empty cannot distinguish absence, empty data and failure. For exact formats use GetExtendedAttribute() with an explicit UTF-8/terminator policy. Do not treat the attribute as part of the main content returned by GetFileAsBytes().
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
stringDecoded string; empty is not an unambiguous diagnostic.
GetExtendedAttributesListstring[]
public static string[] GetExtendedAttributesList(string file);Names of backend-visible extended attributes/streams. Windows lists named data streams, excluding the main unnamed stream. Order is unspecified. Empty can also result from unavailability/failure with no separate Error; the list can change before reading a value.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
string[]Name string[] without sorting/atomicity guarantees.
GetFileAsBytesbyte[]
public static byte[] GetFileAsBytes(string path);Opens a file, allocates for its full length and returns undecoded bytes. The bound helper updates GetOpenError(): empty can mean a valid empty file or an opening error, so check immediately. A convenience helper rather than a size-bounded reader: native code exposes no separate actual read count. For strict limits/short-read handling use Open(), GetLength() and bounded GetBuffer().
| Name | Type | Default |
|---|---|---|
path | string | — |
pathFile path to read; size/accessibility can change after a separate check.
byte[]New byte[]; check GetOpenError() to distinguish an opening error for empty results.
GetFileAsStringstring
public static string GetFileAsString(string path);Reads the whole file and decodes UTF-8, retaining CR. Empty can be valid data or an opening error; immediately check GetOpenError(), which this helper updates. That status describes opening, not full UTF-8/schema validation or concurrent file changes. Use bounded byte reads and a validating decoder for strict decoding.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathFile path to read; size/accessibility can change after a separate check.
stringUTF-8 string; check GetOpenError() separately from decoding/schema validation.
GetFloatfloat
public float GetFloat();Reads Float from 4 bytes and returns C# float. BigEndian applies through the numeric layout. Does not enforce finite values or gameplay-domain bounds. Check format, remaining record size and I/O status separately; this does not parse a text number.
floatC# float; the numeric value alone proves no complete successful read.
GetHalffloat
public float GetHalf();Reads Half from 2 bytes and returns C# float. BigEndian applies through the numeric layout. Half loses source float precision: storage is 16-bit, not 32-bit. Check format, remaining record size and I/O status separately; this does not parse a text number.
floatC# float; the numeric value alone proves no complete successful read.
public static bool GetHiddenAttribute(string file);Queries a path hidden attribute through the backend; Windows reads FILE_ATTRIBUTE_HIDDEN. Not a universal dot-prefixed-name rule or access control. False can result from an error with a diagnostic rather than proving a normal file. Packed entries may provide no attribute.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
boolBackend hidden flag; false does not certify successful attribute querying.
GetLengthulong
public ulong GetLength();Open file length in bytes, not remaining bytes or character count. Check a size limit before allocating buffers, while allowing for later changes. Windows temporarily seeks to end and back; EOF state can change, so this is not a substitute for checking read results.
ulongOpen file byte length.
GetLinestring
public string GetLine();Reads the next UTF-8 line from the current cursor without its terminator. Handles LF, CRLF and lone CR; NUL also ends a line, so this is unsuitable for arbitrary binary data. Empty does not necessarily mean EOF; an unterminated final line is also returned. Bound file size for input constraints.
stringLine without its terminator; empty is also possible before EOF.
GetMd5string
public static string GetMd5(string path);Reads the main file stream and returns MD5 as 32 lowercase hex characters. A valid empty file has a nonempty digest; opening failure gives empty string. A hash, not a digital signature or source-trust check. Native helper supplies no separate complete-read status; post-partial-read I/O errors and concurrent changes were not tested here.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathFile path to read; size/accessibility can change after a separate check.
string32 lowercase hex characters or empty on opening failure.
GetModifiedTimeulong
public static ulong GetModifiedTime(string file);Modification time in whole Unix-epoch seconds, not milliseconds or local time. Windows can fall back to creation time when write time is absent; failure/unavailability can return 0. Precision and updates depend on the backend. A timestamp alone does not verify content; packed/export metadata was not exercised here.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
ulongUnix seconds; 0 is also possible for unavailable results.
GetOpenErrorError
public static Error GetOpenError();Last public file-opening error on this thread. A later Open-family call can replace it even on success. Read immediately after null; for an already opened handle, inspect operation results and GetError() instead of this static getter.
ErrorLast opening status on this thread; not current handle-operation status.
GetPascalStringstring
public string GetPascalString();Reads a 32-bit length then UTF-8 payload, not an LF/NUL-terminated line. Length is bytes and uses BigEndian. Native code allocates from the prefix: validate a length bound and payload availability before using this on external data. Returned text is not strict corrupted-record validation; invalid/huge lengths were not executed in this pass.
stringDecoded string; the result alone does not validate framing/length.
GetPathstring
public string GetPath();Path associated with the open handle; Windows returns the original Open() string, such as asset://. Not necessarily a normalized OS path or persistent ID. Use GetPathAbsolute() for a physical path, subject to backend/export limits.
stringOriginal/backend path associated with the handle.
GetPathAbsolutestring
public string GetPathAbsolute();Absolute path representation when supplied by the backend. Windows removes its internal prefix and uses forward separators. Does not prove existence, write permission, availability outside the application or a loose file in an exported package.
stringBackend absolute representation; not a universal physical path for every export.
GetPositionulong
public ulong GetPosition();Current byte position in an open file. A UTF-8 character can span several bytes, so this is not a character count. Interpret alongside the data format and read result. Position at file end alone does not imply EofReached().
ulongCurrent byte offset, not a character index.
GetReadOnlyAttributebool
public static bool GetReadOnlyAttribute(string file);Reads the backend read-only attribute, FILE_ATTRIBUTE_READONLY on Windows. Not a full ACL test or guarantee about Open(Write)/another process access. Query errors can also return false with a diagnostic; check actual write operations separately.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
boolBackend read-only flag; not the full access-permission model.
GetRealfloat
public float GetReal();Reads native real according to the internal read mode; the current SDK returns C# float and the installed build read 4 bytes. Not universal precision negotiation between builds. For a stable external format explicitly choose GetFloat() or GetDouble() and fix width, byte order and record version.
floatCurrent SDK C# float; native format width must be agreed separately.
GetSha256string
public static string GetSha256(string path);Reads the main file stream and returns SHA-256 as 64 lowercase hex characters. A valid empty file has a nonempty digest; opening failure gives empty string. A hash, not a digital signature or source-trust check. Native helper supplies no separate complete-read status; post-partial-read I/O errors and concurrent changes were not tested here.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathFile path to read; size/accessibility can change after a separate check.
string64 lowercase hex characters or empty on opening failure.
GetSizelong
public static long GetSize(string file);File byte size by path without a public handle. Ordinary backend failures can return -1, but this is not a universal indicator: Windows returns 0 for some invalid paths. Zero therefore proves no existing empty file. Check Open() for subsequent I/O; size can change after querying.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
longByte size or a backend sentinel; -1/0 semantics vary by path/backend.
GetUnixPermissionsFileAccess.UnixPermissionFlags
public static FileAccess.UnixPermissionFlags GetUnixPermissions(string file);Returns Unix permission bits where supplied by the backend, not a full ACL. Windows returns 0 even for accessible files; this does not mean all access is denied. Packed entries can also give 0. Determine support and actual opening access separately.
| Name | Type | Default |
|---|---|---|
file | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
FileAccess.UnixPermissionFlagsPermission bitmask; 0 also represents unavailable support on Windows.
GetVarVariant
public Variant GetVar(bool allowObjects = false);Reads a StoreVar record: a 32-bit length using current BigEndian and a native Variant payload. Scope the C# result with using Variant. Nil may be valid stored data and can also result from an error; it is insufficient as a success test. Bound framing beforehand and validate schema/types. Keep allowObjects=false for external data; true permits native object construction from data, not merely extra fields. Full objects and corrupted lengths were not executed here.
| Name | Type | Default |
|---|---|---|
allowObjects | bool | false |
allowObjectsDefaults to false. Enable true only for trusted object formats, accounting for possible class construction from payload.
VariantRecord Variant; Nil can also be valid data. Release the owned result with using.
IsBigEndianbool
public bool IsBigEndian();Byte-order setting for numeric Get/Store operations on this handle: false is little-endian, true big-endian. A new Open() has a fresh false-default handle; the setting is not stored as file metadata. Does not reorder GetBuffer/StoreBuffer bytes or UTF-8 text. StoreVar/GetVar applies it to the 32-bit length prefix, not the inner Variant payload; tested. Reader and writer must agree on the format.
boolCurrent BigEndian setting of this handle.
IsOpenbool
public bool IsOpen();Tests whether a live handle has an open file. Returns false after Close() on the tested Windows backend. Proves no write mode, free space, current contents or previous-operation success. Do not use a wrapper after Dispose even for this test.
boolTrue when the live handle has an open file.
OpenFileAccess
public static FileAccess Open(string path, FileAccess.ModeFlags flags);Opens a file and returns an owned RefCounted handle; use using in C#. On null read GetOpenError() immediately on the same thread. Read/ReadWrite require an existing file; Write/WriteRead create or truncate it. ReadWrite preserves contents and starts at position 0, not append mode. Creates no parents. Use user:// for progress; original files under asset:// are not guaranteed after export.
| Name | Type | Default |
|---|---|---|
path | string | — |
flags | FileAccess.ModeFlags | — |
pathFile path: user://, asset:// or a supported OS path; the parent must exist.
flagsRead/ReadWrite for an existing file; Write/WriteRead create or truncate. Do not confuse ReadWrite and WriteRead.
FileAccessOwned FileAccess or null; read GetOpenError() immediately.
OpenCompressedFileAccess
public static FileAccess OpenCompressed(string path, FileAccess.ModeFlags modeFlags, FileAccess.CompressionMode compressionMode = FileAccess.CompressionMode.Fastlz);Opens a FileAccess compression container, not an arbitrary .zip/.gz file. Even CompressionMode.GZip selects an algorithm inside the engine GCPF container. Use Write for writing and Read for reading; ReadWrite is rejected and WriteRead is not supported editing of an existing container. Reads select the algorithm from the header. Writes stay buffered until Close()/release; Flush() does not finalize them. The returned handle is owned; on null immediately check GetOpenError(). Corrupt/foreign containers are not validated inputs here.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
compressionMode | FileAccess.CompressionMode | FileAccess.CompressionMode.Fastlz |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
compressionModeWrite algorithm inside GCPF; reads select it from the header. The selected algorithm must support encoding; Brotli is read-only.
FileAccessOwned FileAccess or null; immediately GetOpenError() on null.
OpenEncrypted4 overloads
public static FileAccess OpenEncrypted(string path, FileAccess.ModeFlags modeFlags, byte[] key);Opens an engine encrypted FileAccess container with a 32-byte key; use only Read or Write. Critical 1.0.0 limitation: the base Write opens/truncates the destination before key validation. An invalid key length can return null/Error.InvalidParameter after previous contents are lost; reproduced on a disposable file. Validate parameters before calling and avoid overwriting the only valuable copy. Data stays in memory until Close()/release; Flush() writes no finished container. A write IV must be empty for generation or 16 bytes; reads use the file IV. The format uses AES-CFB and a data MD5, not a separately validated authenticated-encryption protocol. Security assessment and wrong-key reads were not executed; roundtrip does not prove security. On null check GetOpenError() immediately. The overload without iV selects automatic IV generation on writes.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
key | byte[] | — |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
keyExactly 32 key bytes. Validate length before Write opening: native validation occurs after base-file opening. Array/span is not a text password.
FileAccessOwned FileAccess or null; a Write failure does not imply preservation of an existing file.
public static FileAccess OpenEncrypted(string path, FileAccess.ModeFlags modeFlags, byte[] key, byte[] iV = null);Opens an engine encrypted FileAccess container with a 32-byte key; use only Read or Write. Critical 1.0.0 limitation: the base Write opens/truncates the destination before key validation. An invalid key length can return null/Error.InvalidParameter after previous contents are lost; reproduced on a disposable file. Validate parameters before calling and avoid overwriting the only valuable copy. Data stays in memory until Close()/release; Flush() writes no finished container. A write IV must be empty for generation or 16 bytes; reads use the file IV. The format uses AES-CFB and a data MD5, not a separately validated authenticated-encryption protocol. Security assessment and wrong-key reads were not executed; roundtrip does not prove security. On null check GetOpenError() immediately.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
key | byte[] | — |
iV | byte[] | null |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
keyExactly 32 key bytes. Validate length before Write opening: native validation occurs after base-file opening. Array/span is not a text password.
iVEmpty on writing enables IV generation; nonempty must contain 16 bytes. Reads use the header IV. Do not carry a fixed QA IV into a production scheme.
FileAccessOwned FileAccess or null; a Write failure does not imply preservation of an existing file.
public static FileAccess OpenEncrypted(string path, FileAccess.ModeFlags modeFlags, ReadOnlySpan<byte> key);Opens an engine encrypted FileAccess container with a 32-byte key; use only Read or Write. Critical 1.0.0 limitation: the base Write opens/truncates the destination before key validation. An invalid key length can return null/Error.InvalidParameter after previous contents are lost; reproduced on a disposable file. Validate parameters before calling and avoid overwriting the only valuable copy. Data stays in memory until Close()/release; Flush() writes no finished container. A write IV must be empty for generation or 16 bytes; reads use the file IV. The format uses AES-CFB and a data MD5, not a separately validated authenticated-encryption protocol. Security assessment and wrong-key reads were not executed; roundtrip does not prove security. On null check GetOpenError() immediately. The overload without iV selects automatic IV generation on writes.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
key | ReadOnlySpan<byte> | — |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
keyExactly 32 key bytes. Validate length before Write opening: native validation occurs after base-file opening. Array/span is not a text password.
FileAccessOwned FileAccess or null; a Write failure does not imply preservation of an existing file.
public static FileAccess OpenEncrypted(string path, FileAccess.ModeFlags modeFlags, ReadOnlySpan<byte> key, ReadOnlySpan<byte> iV);Opens an engine encrypted FileAccess container with a 32-byte key; use only Read or Write. Critical 1.0.0 limitation: the base Write opens/truncates the destination before key validation. An invalid key length can return null/Error.InvalidParameter after previous contents are lost; reproduced on a disposable file. Validate parameters before calling and avoid overwriting the only valuable copy. Data stays in memory until Close()/release; Flush() writes no finished container. A write IV must be empty for generation or 16 bytes; reads use the file IV. The format uses AES-CFB and a data MD5, not a separately validated authenticated-encryption protocol. Security assessment and wrong-key reads were not executed; roundtrip does not prove security. On null check GetOpenError() immediately.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
key | ReadOnlySpan<byte> | — |
iV | ReadOnlySpan<byte> | — |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
keyExactly 32 key bytes. Validate length before Write opening: native validation occurs after base-file opening. Array/span is not a text password.
iVEmpty on writing enables IV generation; nonempty must contain 16 bytes. Reads use the header IV. Do not carry a fixed QA IV into a production scheme.
FileAccessOwned FileAccess or null; a Write failure does not imply preservation of an existing file.
OpenEncryptedWithPassFileAccess
public static FileAccess OpenEncryptedWithPass(string path, FileAccess.ModeFlags modeFlags, string pass);Opens the same encrypted FileAccess container using a password. Current native code derives the key from 32 characters of password MD5 text; this promises no modern password KDF, salt or separate authentication. Use Read/Write; check null and immediately GetOpenError(). Writes finalize only on close; Flush() leaves data in memory. The base Write already changes an existing file before setup completes, so container-opening failure does not guarantee destination preservation. A successful password roundtrip was tested; no security assessment was performed.
| Name | Type | Default |
|---|---|---|
path | string | — |
modeFlags | FileAccess.ModeFlags | — |
pass | string | — |
pathContainer file path; Write can lose existing contents before setup finishes.
modeFlagsUse only Read or Write for a container; for CreateTemp this is the returned handle mode.
passPassword for the current native format, not raw 32 key bytes. Keep real secrets out of published examples.
FileAccessOwned FileAccess or null; check GetOpenError() while accounting for early Write-destination changes.
RemoveExtendedAttributeError
public static Error RemoveExtendedAttribute(string file, string attributeName);Removes one named value/stream, not the file or all attributes. A missing name returns an error on Windows; do not assume automatic idempotence. Check Error/backend support; remove empty values by name like nonempty ones.
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
ResizeError
public Error Resize(long length);Changes a writable open file byte length. Flush() first after writes: on Windows pending output can restore the old length even after Resize() returns Ok; reproduced. Check Error and final length; explicitly set the next operation cursor. Zero-filled growth was tested only on the current Windows filesystem, not guaranteed for every backend.
| Name | Type | Default |
|---|---|---|
length | long | — |
lengthNew nonnegative byte length; flush pending output first.
ErrorLength-change Error; with pending writes Ok alone does not prove final length.
Seekvoid
public void Seek(ulong position);Sets an absolute byte offset from the beginning of an open file. Not a character index or truncation; a short overwrite can leave the old tail. Returns no Error; validate the offset and inspect subsequent I/O results. Windows successful seek clears the EOF indicator but may leave the previous GetError().
| Name | Type | Default |
|---|---|---|
position | ulong | — |
positionNonnegative absolute byte offset from the open file beginning.
SeekEndvoid
public void SeekEnd(long position = 0);Moves relative to file end in bytes. 0 selects end for appending; negative values move before end; do not seek before the beginning. Creates no file and changes no mode. Call SeekEnd() to append after ReadWrite rather than assuming its initial cursor is at the end.
| Name | Type | Default |
|---|---|---|
position | long | 0 |
positionByte offset from end; 0 for end, negative for an earlier position.
SetBigEndianvoid
public void SetBigEndian(bool bigEndian);Byte-order setting for numeric Get/Store operations on this handle: false is little-endian, true big-endian. A new Open() has a fresh false-default handle; the setting is not stored as file metadata. Does not reorder GetBuffer/StoreBuffer bytes or UTF-8 text. StoreVar/GetVar applies it to the 32-bit length prefix, not the inner Variant payload; tested. Reader and writer must agree on the format.
| Name | Type | Default |
|---|---|---|
bigEndian | bool | — |
bigEndianTrue for big-endian numeric fields; false for little-endian. Does not detect the format automatically.
SetExtendedAttribute2 overloads
public static Error SetExtendedAttribute(string file, string attributeName, byte[] data);Writes named bytes through the backend; array/span overloads supply the same content. Windows creates/overwrites a separate data stream, not the file main bytes. Check Error and filesystem support. An empty array can create an existing name with an empty value; it is not removal—use RemoveExtendedAttribute().
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
data | byte[] | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
dataNamed-value bytes; an empty buffer does not mean removal.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
public static Error SetExtendedAttribute(string file, string attributeName, ReadOnlySpan<byte> data);Writes named bytes through the backend; array/span overloads supply the same content. Windows creates/overwrites a separate data stream, not the file main bytes. Check Error and filesystem support. An empty array can create an existing name with an empty value; it is not removal—use RemoveExtendedAttribute().
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
data | ReadOnlySpan<byte> | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
dataNamed-value bytes; an empty buffer does not mean removal.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
SetExtendedAttributeStringError
public static Error SetExtendedAttributeString(string file, string attributeName, string data);Encodes UTF-8 text for the attribute backend. The current implementation includes a trailing NUL, confirmed by reading raw bytes on Windows. For exact external byte formats use SetExtendedAttribute() with explicit encoding/terminator rules. Check Error; this does not write the main file content.
| Name | Type | Default |
|---|---|---|
file | string | — |
attributeName | string | — |
data | string | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
attributeNameNonempty backend-format name; Windows uses a separate data-stream name. Not the main file path.
dataString to encode as UTF-8; current implementation appends NUL to raw bytes.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
public static Error SetHiddenAttribute(string file, bool hidden);Changes the backend hidden attribute; check returned Error. Windows changes the corresponding bit while retaining other attributes. Creates no file and protects no content from reading. OS/filesystem/packed-resource support varies; unavailable/failure is not successful application.
| Name | Type | Default |
|---|---|---|
file | string | — |
hidden | bool | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
hiddenTrue sets hidden, false clears it; not access control.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
SetReadOnlyAttributeError
public static Error SetReadOnlyAttribute(string file, bool ro);Sets/clears the backend read-only attribute; Windows changes one bit while retaining others. Not equivalent to configuring all permissions/ACLs and does not guarantee reversal if environment permissions change. Check Error; packed entries may not support this operation.
| Name | Type | Default |
|---|---|---|
file | string | — |
ro | bool | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
roTrue sets the read-only attribute, false clears it; not ACL configuration.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
SetUnixPermissionsError
public static Error SetUnixPermissions(string file, FileAccess.UnixPermissionFlags permissions);Requests Unix permission-bit changes. The tested Windows backend returns Error.Unavailable without changing ACLs. Packed entries are also unavailable for setting. Check Error; success of another attribute API proves no chmod support. Unix platforms were not executed here.
| Name | Type | Default |
|---|---|---|
file | string | — |
permissions | FileAccess.UnixPermissionFlags | — |
fileSpecific file/object path; asset://, user:// or a supported OS path subject to backend support.
permissionsUnix permission bits; the Windows backend returns Unavailable here.
ErrorBackend operation Error; distinguish Ok, Unavailable and other failures.
Store16bool
public bool Store16(ushort value);Writes an unsigned 16-bit number in exactly 2 bytes at the current cursor, without a type/length tag. Byte order follows this handle BigEndian; defaults to little-endian. The reader must know the format and use Get16(). Check bool; writing is not atomic and guarantees no media flush.
| Name | Type | Default |
|---|---|---|
value | ushort | — |
valueUnsigned 16-bit value. Validate range before explicitly converting a wider/signed type.
boolBool result for writing all numeric bytes; not durable-storage assurance.
Store32bool
public bool Store32(uint value);Writes an unsigned 32-bit number in exactly 4 bytes at the current cursor, without a type/length tag. Byte order follows this handle BigEndian; defaults to little-endian. The reader must know the format and use Get32(). Check bool; writing is not atomic and guarantees no media flush.
| Name | Type | Default |
|---|---|---|
value | uint | — |
valueUnsigned 32-bit value. Validate range before explicitly converting a wider/signed type.
boolBool result for writing all numeric bytes; not durable-storage assurance.
Store64bool
public bool Store64(ulong value);Writes an unsigned 64-bit number in exactly 8 bytes at the current cursor, without a type/length tag. Byte order follows this handle BigEndian; defaults to little-endian. The reader must know the format and use Get64(). Check bool; writing is not atomic and guarantees no media flush.
| Name | Type | Default |
|---|---|---|
value | ulong | — |
valueUnsigned 64-bit value. Validate range before explicitly converting a wider/signed type.
boolBool result for writing all numeric bytes; not durable-storage assurance.
Store8bool
public bool Store8(byte value);Writes an unsigned 8-bit number in exactly 1 bytes at the current cursor, without a type/length tag. BigEndian has no effect on one byte. The reader must know the format and use Get8(). Check bool; writing is not atomic and guarantees no media flush.
| Name | Type | Default |
|---|---|---|
value | byte | — |
valueUnsigned 8-bit value. Validate range before explicitly converting a wider/signed type.
boolBool result for writing all numeric bytes; not durable-storage assurance.
StoreBuffer2 overloads
public bool StoreBuffer(byte[] buffer);Writes supplied bytes at the current cursor without text, size or byte-order conversion. Array/span overloads perform the same write. Creates no parents, truncates no remaining old tail and promises no atomicity. Check bool/status and use a suitable ReadWrite/WriteRead mode when writing after reading.
| Name | Type | Default |
|---|---|---|
buffer | byte[] | — |
bufferBytes to write from the current cursor; the buffer is not automatically an object serialization.
boolBackend bool result for writing all supplied bytes.
public bool StoreBuffer(ReadOnlySpan<byte> buffer);Writes supplied bytes at the current cursor without text, size or byte-order conversion. Array/span overloads perform the same write. Creates no parents, truncates no remaining old tail and promises no atomicity. Check bool/status and use a suitable ReadWrite/WriteRead mode when writing after reading.
| Name | Type | Default |
|---|---|---|
buffer | ReadOnlySpan<byte> | — |
bufferBytes to write from the current cursor; the buffer is not automatically an object serialization.
boolBackend bool result for writing all supplied bytes.
StoreCsvLine2 overloads
public bool StoreCsvLine(ReadOnlySpan<string> values, string delim);Writes a CSV record and one LF. Fields containing a delimiter, quote or LF are quoted; embedded quotes are doubled. A lone CR does not trigger quoting in the current implementation: such a field can split into two records when read, as reproduced. Normalize CRLF/CR to LF first when line breaks are needed inside fields; this changes original line endings. Use one non-double-quote delimiter for matching GetCsvLine(). Array/span overloads use the same format; check bool.
| Name | Type | Default |
|---|---|---|
values | ReadOnlySpan<string> | — |
delim | string | — |
valuesRecord fields; normalize CRLF/CR according to your text policy first, otherwise lone CR can break roundtrip.
delimOne non-double-quote delimiter character for matched reading/writing; not a multicharacter string.
boolBool result of writing the formatted line and LF; does not certify exact lone-CR roundtrip.
public bool StoreCsvLine(string[] values, string delim = ",");Writes a CSV record and one LF. Fields containing a delimiter, quote or LF are quoted; embedded quotes are doubled. A lone CR does not trigger quoting in the current implementation: such a field can split into two records when read, as reproduced. Normalize CRLF/CR to LF first when line breaks are needed inside fields; this changes original line endings. Use one non-double-quote delimiter for matching GetCsvLine(). Array/span overloads use the same format; check bool.
| Name | Type | Default |
|---|---|---|
values | string[] | — |
delim | string | "," |
valuesRecord fields; normalize CRLF/CR according to your text policy first, otherwise lone CR can break roundtrip.
delimOne non-double-quote delimiter character for matched reading/writing; not a multicharacter string.
boolBool result of writing the formatted line and LF; does not certify exact lone-CR roundtrip.
StoreDoublebool
public bool StoreDouble(double value);Encodes a number as Double in 8 bytes with selected BigEndian; no text representation or type tag. Does not enforce finite values or gameplay-domain bounds. Read with matching GetDouble() and format; check the write bool.
| Name | Type | Default |
|---|---|---|
value | double | — |
valueNumber for the selected binary precision; the caller validates application-domain constraints.
boolBackend encoding/write result bool.
StoreFloatbool
public bool StoreFloat(float value);Encodes a number as Float in 4 bytes with selected BigEndian; no text representation or type tag. Does not enforce finite values or gameplay-domain bounds. Read with matching GetFloat() and format; check the write bool.
| Name | Type | Default |
|---|---|---|
value | float | — |
valueNumber for the selected binary precision; the caller validates application-domain constraints.
boolBackend encoding/write result bool.
StoreHalfbool
public bool StoreHalf(float value);Encodes a number as Half in 2 bytes with selected BigEndian; no text representation or type tag. Half loses source float precision: storage is 16-bit, not 32-bit. Read with matching GetHalf() and format; check the write bool.
| Name | Type | Default |
|---|---|---|
value | float | — |
valueNumber for the selected binary precision; the caller validates application-domain constraints.
boolBackend encoding/write result bool.
StoreLinebool
public bool StoreLine(string line);Writes UTF-8 text followed by one LF byte (0x0A), not platform CRLF. Does not remove a terminator already present in the argument. Returns the combined bool result; position grows by UTF-8 byte count plus LF. Overwrite and persistence limits are the same as StoreString().
| Name | Type | Default |
|---|---|---|
line | string | — |
lineLine text; the method additionally writes one LF.
boolTrue when both string and appended LF writes succeed at backend level.
StorePascalStringbool
public bool StorePascalString(string @string);Writes a 32-bit UTF-8 byte length followed by the string bytes. Not a one-byte Pascal length or C# character count. The prefix uses BigEndian; payload remains UTF-8. Read with GetPascalString(), matching byte order and an agreed record-size bound; check bool.
| Name | Type | Default |
|---|---|---|
string | string | — |
stringText to encode as UTF-8; the prefix contains encoded byte length, not string.Length.
boolCombined bool result of writing length and UTF-8 bytes.
StoreRealbool
public bool StoreReal(float value);Native real write width depends on build precision: source selects StoreFloat or StoreDouble by sizeof(real_t). The installed build used 4 bytes; other precision builds were not tested. Explicitly choose StoreFloat()/StoreDouble() for a fixed-width external format. BigEndian applies; bool does not certify media persistence.
| Name | Type | Default |
|---|---|---|
value | float | — |
valueNumber in the current SDK real type; not an automatically portable-precision field.
boolBool result of this build native real write.
StoreStringbool
public bool StoreString(string @string);Writes UTF-8 bytes at the current cursor without an automatic LF or length prefix. Position is measured in bytes. A short overwrite does not truncate an old tail; choose Write/WriteRead or controlled Resize(). Check bool and GetError(); true guarantees neither media persistence nor atomic saving.
| Name | Type | Default |
|---|---|---|
string | string | — |
stringText to encode as UTF-8 without an automatic line terminator.
boolWrite result bool; not durable-storage assurance.
StoreVarbool
public bool StoreVar(Variant value, bool fullObjects = false);Serializes a Variant into native binary payload with a 32-bit length prefix. Format belongs to StoreVar/GetVar, not JSON, a prefab or a whole-level snapshot. BigEndian changes the length prefix, not inner payload bytes. fullObjects defaults to false; full-object serialization was not executed. Takes no ownership of the input Variant. Add your own save version/schema; check write bool and loaded types.
| Name | Type | Default |
|---|---|---|
value | Variant | — |
fullObjects | bool | false |
valueVariant to write; ownership remains with the caller. Game-object references do not automatically become persistent IDs.
fullObjectsDefaults to false. True enables full object representation, not automatic level saving; this mode was not tested here.
boolBool result for length and Variant payload writes; not atomic-save or schema-compatibility assurance.
FileAccess.CompressionMode
| Value | Description |
|---|---|
Brotli = 4 | Uses the brotli compression method (only decompression is supported). |
Deflate = 1 | Uses the DEFLATE(https://en.wikipedia.org/wiki/DEFLATE) compression method. |
Fastlz = 0 | Uses the FastLZ(https://fastlz.org/) compression method. |
GZip = 3 | Uses the gzip compression method. |
Zstd = 2 | Uses the Zstandard(https://facebook.github.io/zstd/) compression method. |
FileAccess.ModeFlags
| Value | Description |
|---|---|
Read = 1 | Opens the file for read operations. The file cursor is positioned at the beginning of the file. |
ReadWrite = 3 | Opens the file for read and write operations. Does not truncate the file. The file cursor is positioned at the beginning of the file. |
Write = 2 | Opens the file for write operations. If the file exists, it is truncated to zero length and its contents are cleared. Otherwise, it is created.
Note: When creating a file it must be in an already existing directory. To recursively create directories for a file path, see |
WriteRead = 7 | Opens the file for read and write operations. If the file exists, it is truncated to zero length and its contents are cleared. Otherwise, it is created. 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 |
FileAccess.UnixPermissionFlags
| Value | Description |
|---|---|
ExecuteGroup = 8 | Execute for group bit. |
ExecuteOther = 1 | Execute for other bit. |
ExecuteOwner = 64 | Execute for owner bit. |
ReadGroup = 32 | Read for group bit. |
ReadOther = 4 | Read for other bit. |
ReadOwner = 256 | Read for owner bit. |
RestrictedDelete = 512 | Restricted deletion (sticky) bit. |
SetGroupId = 1024 | Set group id on execution bit. |
SetUserId = 2048 | Set user id on execution bit. |
WriteGroup = 16 | Write for group bit. |
WriteOther = 2 | Write for other bit. |
WriteOwner = 128 | Write for owner bit. |