Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

GLib::Mount

module GLib::Mount

The GLib::Mount interface represents user-visible mounts. Note, when porting from GnomeVFS, GLib::Mount is the moral equivalent of GnomeVFS::Volume.

GLib::Mount is a “mounted” filesystem that you can access. Mounted is in quotes because it’s not the same as a unix mount, it might be a gvfs mount, but you can still access the files on it if you use GIO. Might or might not be related to a volume object.

Unmounting a GLib::Mount instance is an asynchronous operation. For more information about asynchronous operations, see GLib::AsyncReady? and GLib::SimpleAsyncReady?. To unmount a GLib::Mount instance, first call GLib::Mount#unmount_with_operation with a block. The callback will be fired when the operation has resolved (either with success or failure), and a GLib::AsyncReady? structure will be passed to the callback. That callback should then call GLib::Mount#unmount_with_operation_finish to see if the operation was completed successfully. If an error is present when g_mount_unmount_with_operation_finish() is called, then it will be raised.

Instance Methods

can_eject?
Checks if the mount can be eject.
  • Returns: true if the mount can be ejected
can_unmount?
Checks if the mount can be unmounted.
  • Returns: true if the mount can be unmounted
default_location
Gets the default location of the mount. The default location of the given mount is a path that reflects the main entry point for the user (for example, the home directory, or the root of the volume).
drive

Gets the GLib::Drive for the mount.

This is a convenience method for getting the GLib::Volume and then using that object to get the GLib::Drive.

  • Returns: A GLib::Drive, or nil if the mount is not associated with a volume or a drive
eject_with_operation(flags = GLib::Mount::UNMOUNT_NONE, mount_operation = nil, cancellable = nil){ |result| }

Ejects a mount. This is an asynchronous operation, and is finished by calling GLib::Mount#eject_with_operation_finish in the block.

Since 2.22

eject_with_operation_finish(result)

Finishes ejecting a mount.

A GLib::IO::Error is raised if this mount couldn’t be ejected.

Since 2.22

guess_content_type(force_rescan = false, cancellable = nil){ |result| }

Tries to guess the type of content stored on the mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), for example, x-content/image-dcf for camera memory cards. See the specification for more on x-content types.

This is an asynchronous operation (see GLib::Mount#guess_content_type_sync for the synchronous version), and is finished by calling GLib::Mount#guess_content_type_finish inside the block.

Since 2.18

  • force_rescan: true to force a rescan of the content, otherwise a cached
  • result will be used if available
  • cancellable: Optional GLib::Cancellable object, nil to ignore
  • result: A GLib::AsyncResult
  • Returns: self
guess_content_type_finish(result)

Finishes guessing content types of the mount.

A GLib::IO::Error is raised if this mount’s content type couldn’t be guessed. In particular, you may get an GLib::IO::NotSupportedError if the mount does not support content guessing.

Since 2.18

guess_content_type_sync(force_rescan, cancellable = nil)

Tries to guess the type of content stored on the mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), for example, x-content/image-dcf for camera memory cards. See the specification for more on x-content types.

This is an synchronous operation and as such may block doing I/O; see GLib::Mount#guess_content_type for the asynchronous version.

Since 2.18

  • force_rescan: true to force a rescan of the content, otherwise a cached result will be used if available
  • cancellable: Optional GLib::Cancellable object, nil to ignore
  • Returns: An Array of String content types
icon
Gets the icon for the mount.
name
Gets the name of the mount.
  • Returns: The name of the mount.
remount(flags = GLib::Mount::MOUNT_NONE, mount_operation = nil, cancellable = nil){ |result| }

Remounts a mount. This is an asynchronous operation, and is finished by calling GLib::Mount#remount_finish inside the block.

Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

remount_finish(result)
Finishes remounting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
  • result: A GLib::AsyncResult
  • Returns: true if the mount was successfully remounted. false otherwise
root
Gets the root directory of the mount.
shadow

Increments the shadow count on the mount. Usually used by GLib::VolumeMonitor implementations when creating a shadow mount for the mount, see GLib::Mount#shadowed? for more information. The caller will need to emit the “changed” signal on the mount manually.

Since 2.20

shadowed?

Checks if the mount is shadowed. Applications or libraries should avoid displaying the mount in the user interface if it is shadowed.

A mount is said to be shadowed if there exists one or more user visible objects (currently GLib::Mount objects) with a root that is inside the root of the mount.

One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a GLib::VolumeMonitor implementation would create two GLib::Volume objects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIs gphoto2://[usb:001,002]/store1/ and gphoto2://[usb:001,002]/store2/. When the underlying mount (with root) is mounted, said GLib::VolumeMonitor implementation would create two GLib::Mount objects (each with their root matching the corresponding volume activation root) that would shadow the original mount.

The proxy monitor in GVfs 2.26 and later automatically creates and manage shadow mounts (and shadows the underlying mount) if the activation root on a GLib::Volume is set.

Since 2.20

  • Returns: true if the mount is shadowed
unmount_with_operation(flags = GLib::Mount::UNMONUT_NONE, mount_operation = nil, cancellable = nil){ |result| }

Unmounts a mount. This is an asynchronous operation, and is finished by calling GLib::Mount#unmount_with_operation_finish inside the block.

Since 2.22

unmount_with_operation_finish(result)

Finishes unmounting a mount.

A GLib::IO::Error is raised if this mount couldn’t be unmounted.

Since 2.22

unshadow

Decrements the shadow count on the mount. Usually used by GLib::VolumeMonitor implementations when destroying a shadow mount for the mount, see GLib::Mount#shadowed? for more information. The caller will need to emit the “changed” signal on the mount manually.

Since 2.20

  • Returns: self
uuid
Gets the UUID for the the mount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque String. Returns nil if there is no UUID available.
  • Returns: The UUID for the mount or nil if no UUID can be computed
volume
Gets the volume for the the mount.
  • Returns: A GLib::Volume, or nil if the mount is not associated with a volume

Constants

MOUNT_NONE
No flags set
UNMOUNT_FORCE
Unmount even if there are outstanding file operations on the mount
UNMOUNT_NONE
No flags set