Module: Gio::Mount

Defined in:
(unknown)

Overview

The #GMount interface represents user-visible mounts. Note, when porting from GnomeVFS, #GMount is the moral equivalent of Gnome::VFSVolume.

#GMount 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 #GMount instance is an asynchronous operation. For more information about asynchronous operations, see GAsync::Result and #GTask. To unmount a #GMount instance, first call g_mount_unmount_with_operation() with (at least) the #GMount instance and a GAsync::ReadyCallback. The callback will be fired when the operation has resolved (either with success or failure), and a GAsync::Result structure will be passed to the callback. That callback should then call g_mount_unmount_with_operation_finish() with the #GMount and the GAsync::Result data 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 filled with any error information.

Instance Method Summary collapse

Instance Method Details

#can_eject(mount) ⇒ TrueClass

Returns true if the mount can be ejected.

Parameters:

Returns:

  • (TrueClass)

    true if the mount can be ejected.

#can_unmount(mount) ⇒ TrueClass

Returns true if the mount can be unmounted.

Parameters:

Returns:

  • (TrueClass)

    true if the mount can be unmounted.

#changed(mount) ⇒ nil

Parameters:

Returns:

  • (nil)

#default_locationGio::File

Gets the default location of mount. The default location of the given mount is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).

Returns:

  • (Gio::File)

    a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

#driveGio::Drive

Gets the drive for the mount.

This is a convenience method for getting the #GVolume and then using that object to get the #GDrive.

Returns:

  • (Gio::Drive)

    a #GDrive or nil if mount is not associated with a volume or a drive. The returned object should be unreffed with g_object_unref() when no longer needed.

#eject(mount, flags, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount.

  • flags (Gio::MountUnmountFlags)

    flags affecting the unmount if required for eject

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#eject_finish(mount, result) ⇒ TrueClass

Returns true if the mount was successfully ejected. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the mount was successfully ejected. false otherwise.

#eject_with_operation(mount, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount.

  • flags (Gio::MountUnmountFlags)

    flags affecting the unmount if required for eject

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#eject_with_operation_finish(mount, result) ⇒ TrueClass

Returns true if the mount was successfully ejected. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the mount was successfully ejected. false otherwise.

#get_default_location(mount) ⇒ Gio::File

Returns a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::File)

    a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

#get_drive(mount) ⇒ Gio::Drive

Returns a #GDrive or nil if mount is not associated with a volume or a drive. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::Drive)

    a #GDrive or nil if mount is not associated with a volume or a drive. The returned object should be unreffed with g_object_unref() when no longer needed.

#get_icon(mount) ⇒ Gio::Icon

Returns a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::Icon)

    a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

#get_name(mount) ⇒ String

Returns the name for the given mount. The returned string should be freed with g_free() when no longer needed.

Parameters:

Returns:

  • (String)

    the name for the given mount. The returned string should be freed with g_free() when no longer needed.

#get_root(mount) ⇒ Gio::File

Returns a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::File)

    a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

#get_sort_key(mount) ⇒ String

Returns Sorting key for mount or nil if no such key is available.

Parameters:

Returns:

  • (String)

    Sorting key for mount or nil if no such key is available.

#get_symbolic_icon(mount) ⇒ Gio::Icon

Returns a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::Icon)

    a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

#get_uuid(mount) ⇒ String

Returns the UUID for mount or nil if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.

Parameters:

Returns:

  • (String)

    the UUID for mount or nil if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.

#get_volume(mount) ⇒ Gio::Volume

Returns a #GVolume or nil if mount is not associated with a volume. The returned object should be unreffed with g_object_unref() when no longer needed.

Parameters:

Returns:

  • (Gio::Volume)

    a #GVolume or nil if mount is not associated with a volume. The returned object should be unreffed with g_object_unref() when no longer needed.

#guess_content_type(mount, force_rescan, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount

  • force_rescan (TrueClass)

    Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback

  • user_data (GObject)

    user data passed to callback

Returns:

  • (nil)

#guess_content_type_finish(mount, result) ⇒ Array<String>

Returns an array of content types or nil on error. Caller should free this array with g_strfreev() when done with it.

Parameters:

Returns:

  • (Array<String>)

    an array of content types or nil on error. Caller should free this array with g_strfreev() when done with it.

#guess_content_type_sync(mount, force_rescan, cancellable) ⇒ Array<String>

Returns an array of content types or nil on error. Caller should free this array with g_strfreev() when done with it.

Parameters:

  • mount (Gio::Mount)

    a #GMount

  • force_rescan (TrueClass)

    Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

Returns:

  • (Array<String>)

    an array of content types or nil on error. Caller should free this array with g_strfreev() when done with it.

#iconGio::Icon

Gets the icon for mount.

Returns:

  • (Gio::Icon)

    a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

#is_shadowedTrueClass

Determines if mount is shadowed. Applications or libraries should avoid displaying 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 #GMount objects) with a root that is inside the root of 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 GVolume::Monitor implementation would create two #GVolume 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:///store1/` and `gphoto2:///store2/`. When the underlying mount (with root `gphoto2:///`) is mounted, said GVolume::Monitor implementation would create two #GMount 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 #GVolume is set.

Returns:

  • (TrueClass)

    true if mount is shadowed.

#nameString

Gets the name of mount.

Returns:

  • (String)

    the name for the given mount. The returned string should be freed with g_free() when no longer needed.

#pre_unmount(mount) ⇒ nil

Parameters:

Returns:

  • (nil)

#remount(mount, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount.

  • flags (Gio::MountMountFlags)

    flags affecting the operation

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#remount_finish(mount, result) ⇒ TrueClass

Returns true if the mount was successfully remounted. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the mount was successfully remounted. false otherwise.

#rootGio::File

Gets the root directory on mount.

Returns:

  • (Gio::File)

    a #GFile. The returned object should be unreffed with g_object_unref() when no longer needed.

#shadownil

Increments the shadow count on mount. Usually used by GVolume::Monitor implementations when creating a shadow mount for mount, see g_mount_is_shadowed() for more information. The caller will need to emit the #GMount::changed signal on mount manually.

Returns:

  • (nil)

#sort_keyString

Gets the sort key for mount, if any.

Returns:

  • (String)

    Sorting key for mount or nil if no such key is available.

#symbolic_iconGio::Icon

Gets the symbolic icon for mount.

Returns:

  • (Gio::Icon)

    a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.

#unmount(mount, flags, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount.

  • flags (Gio::MountUnmountFlags)

    flags affecting the operation

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#unmount_finish(mount, result) ⇒ TrueClass

Returns true if the mount was successfully unmounted. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the mount was successfully unmounted. false otherwise.

#unmount_with_operation(mount, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • mount (Gio::Mount)

    a #GMount.

  • flags (Gio::MountUnmountFlags)

    flags affecting the operation

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#unmount_with_operation_finish(mount, result) ⇒ TrueClass

Returns true if the mount was successfully unmounted. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the mount was successfully unmounted. false otherwise.

#unmounted(mount) ⇒ nil

Parameters:

Returns:

  • (nil)

#unshadownil

Decrements the shadow count on mount. Usually used by GVolume::Monitor implementations when destroying a shadow mount for mount, see g_mount_is_shadowed() for more information. The caller will need to emit the #GMount::changed signal on mount manually.

Returns:

  • (nil)

#uuidString

Gets the UUID for 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:

  • (String)

    the UUID for mount or nil if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.

#volumeGio::Volume

Gets the volume for the mount.

Returns:

  • (Gio::Volume)

    a #GVolume or nil if mount is not associated with a volume. The returned object should be unreffed with g_object_unref() when no longer needed.