resource
FreeBodyEngine.core.files.resource
#
FileResource(id, data, file_path)
#
A handle to one loaded file, returned by FileSystem.get_file() - the
common, backend-agnostic interface loaders/callers use regardless of
whether data is a DevFileStream, an AssetPackStream, or any other
FileStream implementation.
Wraps data (a FileStream) as file file_path, tagged with id - stores the backend stream directly rather than copying its contents, so reads/writes below always reflect the stream's current state.
data = data
instance-attribute
#
file_path = file_path
instance-attribute
#
id = id
instance-attribute
#
clear()
#
Clears the underlying file's contents (a no-op if the backing FileStream doesn't allow writes).
read(size=-1, offset=0, bytes=False)
#
Reads size bytes starting at offset (the whole file by
default). Decodes the result to str unless bytes=True is
passed - an empty read decodes to "" rather than raising, since
an empty byte string is valid UTF-8 but callers generally want a
plain empty string back, not to special-case it themselves.
write(data, offset=-1)
#
Writes data at offset (appending at the current end of file
when offset is -1, the default). A no-op if the backing
FileStream doesn't allow writes.