Drive

interface Drive

GDrive represents a piece of hardware connected to the machine. It’s generally only created for removable hardware or hardware with removable media. For example, an optical disc drive, or a USB flash drive.

GDrive is a container class for iface@Gio.Volume objects that stem from the same piece of media. As such, GDrive abstracts a drive with (or without) removable media and provides operations for querying whether media is available, determining whether media change is automatically detected and ejecting the media.

If the GDrive reports that media isn’t automatically detected, one can poll for media; typically one should not do this periodically as a poll for media operation is potentially expensive and may spin up the drive creating noise.

GDrive supports starting and stopping drives with authentication support for the former. This can be used to support a diverse set of use cases including connecting/disconnecting iSCSI devices, powering down external disk enclosures and starting/stopping multi-disk devices such as RAID devices. Note that the actual semantics and side-effects of starting/stopping a GDrive may vary according to implementation. To choose the correct verbs in e.g. a file manager, use method@Gio.Drive.get_start_stop_type.

For migrating-gnome-vfs.html note that there is no equivalent of GDrive in that API.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val gioDrivePointer: <Error class: unknown class><<Error class: unknown class>>

Functions

Link copied to clipboard
open fun canEject(): Boolean

Checks if a drive can be ejected.

Link copied to clipboard

Checks if a drive can be polled for media changes.

Link copied to clipboard
open fun canStart(): Boolean

Checks if a drive can be started.

Link copied to clipboard

Checks if a drive can be started degraded.

Link copied to clipboard
open fun canStop(): Boolean

Checks if a drive can be stopped.

Link copied to clipboard
open fun connectChanged(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted when the drive's state has changed.

Link copied to clipboard
open fun connectDisconnected(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

This signal is emitted when the #GDrive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.

Link copied to clipboard
open fun connectEjectButton(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted when the physical eject button (if any) of a drive has been pressed.

Link copied to clipboard
open fun connectStopButton(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted when the physical stop button (if any) of a drive has been pressed.

Link copied to clipboard
open fun eject(flags: MountUnmountFlags, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Asynchronously ejects a drive.

Link copied to clipboard
open fun ejectFinish(result: AsyncResult): <Error class: unknown class><Boolean>

Finishes ejecting a drive.

Link copied to clipboard
open fun ejectWithOperation(flags: MountUnmountFlags, mountOperation: MountOperation? = null, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Ejects a drive. This is an asynchronous operation, and is finished by calling g_drive_eject_with_operation_finish() with the @drive and #GAsyncResult data returned in the @callback.

Link copied to clipboard
open fun ejectWithOperationFinish(result: AsyncResult): <Error class: unknown class><Boolean>

Finishes ejecting a drive. If any errors occurred during the operation,

Link copied to clipboard

Gets the kinds of identifiers that @drive has. Use g_drive_get_identifier() to obtain the identifiers themselves.

Link copied to clipboard
open fun getIcon(): Icon

Gets the icon for @drive.

Link copied to clipboard
open fun getIdentifier(kind: String): String?

Gets the identifier of the given kind for @drive. The only identifier currently available is %G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.

Link copied to clipboard
open fun getName(): String

Gets the name of @drive.

Link copied to clipboard
open fun getSortKey(): String?

Gets the sort key for @drive, if any.

Link copied to clipboard

Gets a hint about how a drive can be started/stopped.

Link copied to clipboard
open fun getSymbolicIcon(): Icon

Gets the icon for @drive.

Link copied to clipboard
open fun getVolumes(): <Error class: unknown class>

Get a list of mountable volumes for @drive.

Link copied to clipboard
open fun hasMedia(): Boolean

Checks if the @drive has media. Note that the OS may not be polling the drive for media changes; see g_drive_is_media_check_automatic() for more details.

Link copied to clipboard
open fun hasVolumes(): Boolean

Check if @drive has any mountable volumes.

Link copied to clipboard

Checks if @drive is capable of automatically detecting media changes.

Link copied to clipboard

Checks if the @drive supports removable media.

Link copied to clipboard
open fun isRemovable(): Boolean

Checks if the #GDrive and/or its media is considered removable by the user. See g_drive_is_media_removable().

Link copied to clipboard
open fun pollForMedia(cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Asynchronously polls @drive to see if media has been inserted or removed.

Link copied to clipboard
open fun pollForMediaFinish(result: AsyncResult): <Error class: unknown class><Boolean>

Finishes an operation started with g_drive_poll_for_media() on a drive.

Link copied to clipboard
open fun start(flags: DriveStartFlags, mountOperation: MountOperation? = null, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Asynchronously starts a drive.

Link copied to clipboard
open fun startFinish(result: AsyncResult): <Error class: unknown class><Boolean>

Finishes starting a drive.

Link copied to clipboard
open fun stop(flags: MountUnmountFlags, mountOperation: MountOperation? = null, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Asynchronously stops a drive.

Link copied to clipboard
open fun stopFinish(result: AsyncResult): <Error class: unknown class><Boolean>

Finishes stopping a drive.