# gio.Drive

Virtual File System drive management.

## Synopsis

gio.Drive
gobject.GInterface
can_eject
can_poll_for_media
eject
callback
flags
gio.MOUNT_UNMOUNT_NONE
cancellable
None
user_data
None
eject_finish
result
enumerate_identifiers
get_icon
get_identifier
get_name
get_volumes
has_media
has_volumes
is_media_check_automatic
is_media_removable
poll_for_media
callback
cancellable
None
user_data
None
poll_for_media_finish
result

## Ancestry

    +-- gobject.GInterface
      +-- gio.Drive

## Prerequisites

`gio.Drive` requires `gobject.GObject`

## Description

`gio.Drive` - this represent a piece of hardware connected to the machine. Its generally only created for removable hardware or hardware with removable media.

`gio.Drive` is a container class for GVolume objects that stem from the same piece of media. As such, `gio.Drive` abstracts a drive with (or without) removable media and provides operations for querying whether media is available, determing whether media change is automatically detected and ejecting the media.

If the `gio.Drive` 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 potententially expensive and may spin up the drive creating noise.

For porting from GnomeVFS note that there is no equivalent of `gio.Drive` in that API.

## Methods

### gio.Drive.can_eject

                    can_eject

Returns :

  `True` if the drive can be ejected, `False` otherwise.

The `can_eject`() method checks if a drive can be ejected.

### gio.Drive.can_poll_for_media

                    can_poll_for_media

Returns :

  `True` if the drive can be polled for media changes, `False` otherwise.

The `can_poll_for_media`() method checks if a drive can be polled for media changes.

### gio.Drive.eject

                    eject

                        callback

                        flagsgio.MOUNT_UNMOUNT_NONE

                        cancellableNone

                        user_dataNone

`callback` :

  A GAsyncReadyCallback to call when the request is satisfied.

`flags` :

  flags affecting the unmount if required for eject.

`cancellable` :

  Optional `gio.Cancellable` object, `None` to ignore.

`user_data` :

  The data to pass to callback function.

The `eject`() method asynchronously ejects a drive.

When the operation is finished, callback will be called. You can then call `gio.Drive.eject_finish`() to obtain the result of the operation.

### gio.Drive.eject_finish

                    eject_finish
                    result

`result` :

  a `gio.AsyncResult`.

Returns :

  `True` if the drive has been ejected successfully, `False` otherwise.

The `eject_finish`() method finishes ejecting a drive.

### gio.Drive.enumerate_identifiers

                    enumerate_identifiers

Returns :

  a list of strings containing kinds of identifiers.

The `enumerate_identifiers`() method gets the kinds of identifiers that drive has. Use `gio.Drive.get_identifier`() to obtain the identifiers themselves.

### gio.Drive.get_icon

                    get_icon

Returns :

  `gio.Icon` for the drive.

The `get_icon`() method gets the icon for drive.

### gio.Drive.get_identifier

                    get_identifier

Returns :

  A string containing the requested identfier, or `None` if the `gio.Drive` doesn't have this kind of identifier.

The `get_identifier`() method gets the identifier of the given kind for drive.

### gio.Drive.get_name

                    get_name

Returns :

  A string containing drive's name.

The `get_name`() method gets the name of drive.

### gio.Drive.get_volumes

                    get_volumes

Returns :

  A list containing any `gio.Volume` objects on the given drive.

The `get_volumes`() method get a list of mountable volumes for drive.

### gio.Drive.has_media

                    has_media

Returns :

  `True` if drive has media, `False` otherwise.

The `has_media`() method checks if the drive has media. Note that the OS may not be polling the drive for media changes; see `gio.Drive.is_media_check_automatic`() for more details.

### gio.Drive.has_volumes

                    has_volumes

Returns :

  `True` if drive contains volumes, `False` otherwise.

The `has_volumes`() method check if drive has any mountable volumes.

### gio.Drive.is_media_check_automatic

                    is_media_check_automatic

Returns :

  `True` if drive is capabable of automatically detecting media changes, `False` otherwise.

The `is_media_check_automatic`() method checks if drive is capabable of automatically detecting media changes.

### gio.Drive.is_media_removable

                    is_media_removable

Returns :

  `True` if drive supports removable media, `False` otherwise.

The `is_media_removable`() method checks if the drive supports removable media.

### gio.Drive.poll_for_media

                    poll_for_media

                        callback

                        cancellableNone

                        user_dataNone

`callback` :

  A GAsyncReadyCallback to call when the request is satisfied.

`cancellable` :

  Optional `gio.Cancellable` object, `None` to ignore.

`user_data` :

  The data to pass to callback function.

The `poll_for_media`() method asynchronously polls drive to see if media has been inserted or removed.

When the operation is finished, callback will be called. You can then call `gio.Drive.poll_for_media_finish`() to obtain the result of the operation.

### gio.Drive.poll_for_media_finish

                    poll_for_media_finish
                    result

`result` :

  a `gio.AsyncResult`.

Returns :

  `True` if the drive has been poll_for_mediaed successfully, `False` otherwise.

The `poll_for_media_finish`() method finishes an operation started with `gio.Drive.poll_for_media`() on a drive.