File.loadBytes

glib.bytes.Bytes loadBytes(gio.cancellable.Cancellable cancellable, out string etagOut)

Loads the contents of file and returns it as #GBytes.

If file is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling [gio.file.File.loadContents] and [glib.bytes.Bytes.newTake].

For resources, etag_out will be set to null.

The data contained in the resulting #GBytes is always zero-terminated, but this is not included in the #GBytes length. The resulting #GBytes should be freed with [glib.bytes.Bytes.unref] when no longer in use.

Parameters

cancellablea #GCancellable or null
etagOuta location to place the current entity tag for the file, or null if the entity tag is not needed

Returns

a #GBytes or null and error is set

Throws

[ErrorWrap]