Contents

loadResource(resource:options:replyHandler:)

Requests that the file system load a resource and present it as a volume.

Declaration

func loadResource(resource: FSResource, options: FSTaskOptions, replyHandler reply: @escaping  @Sendable (FSVolume?, (any Error)?) -> Void)
func loadResource(resource: FSResource, options: FSTaskOptions) async throws -> FSVolume

Parameters

  • resource:

    An Fsresource to load.

  • options:

    An Fstaskoptions object specifying options to apply when loading the resource. An Fsunaryfilesystem supports two options: -f for “force” and --rdonly for read-only. The file system must remember if the read-only option is present.

  • reply:

    A block or closure that your implementation invokes when it finishes setting up or encounters an error. Pass a subclass of FSVolume as the first parameter if loading succeeds. If loading fails, pass an error as the second parameter.

Discussion

Implement this method by inspecting the provided resource and verifying it uses a supported format. If the resource does use a supported format, create a subclass of FSVolume, clear the container error state, and invoke the reply callback, passing your volume as a parameter. If loading can’t proceed, invoke reply and send an appropriate error as the second parameter.

See Also

Loading and unloading resources