# Gio::Drive Class Reference

Virtual File System drive management. More...

`#include <giomm/drive.h>`

Inheritance diagram for Gio::Drive:
[legend]

List of all members.

## Public Member Functions
virtual | ~Drive ()
GDrive* | gobj ()
| Provides access to the underlying C GObject.
const GDrive* | gobj () const
| Provides access to the underlying C GObject.
Glib::ustring | get_name () const
| Gets the name of drive.
Glib::RefPtr< Icon > | get_icon ()
| Gets the icon for drive.
Glib::RefPtr< const Icon > | get_icon () const
| Gets the icon for drive.
bool | has_volumes () const
| Check if drive has any mountable volumes.
Glib::ListHandle< Glib::RefPtr < Volume > > | get_volumes ()
| Get a list of mountable volumes for drive.
bool | is_media_removable () const
| Checks if the drive supports removable media.
bool | has_media () const
| Checks if the drive has media.
bool | is_media_check_automatic () const
| Checks if drive is capabable of automatically detecting media changes.
bool | can_poll_for_media () const
| Checks if a drive can be polled for media changes.
bool | can_eject () const
| Checks if a drive can be ejected.
void | eject (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Ejects the drive.
void | eject (const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Ejects the drive.
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
void | eject (MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Ejects the drive.
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
bool | eject_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes ejecting a drive.
void | poll_for_media (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Polls drive to see if media has been inserted or removed.
void | poll_for_media (const SlotAsyncReady& slot)
| Polls drive to see if media has been inserted or removed.
void | poll_for_media ()
| Polls drive to see if media has been inserted or removed.
bool | poll_for_media_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an operation started with g_drive_poll_for_media() on a drive.
std::string | get_identifier (const std::string& kind) const
| Gets the identifier of the given kind for drive.
Glib::StringArrayHandle | enumerate_identifiers () const
| Gets the kinds of identifiers that drive has.
void | start (const Glib::RefPtr< MountOperation >& mount_operation, const Glib::RefPtr< Cancellable >& cancellable, const SlotAsyncReady& slot, DriveStartFlags flags=DRIVE_START_NONE)
void | start (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, DriveStartFlags flags=DRIVE_START_NONE)
bool | start_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes starting a drive.
bool | can_start () const
bool | can_start_degraded () const
void | stop (const Glib::RefPtr< MountOperation >& mount_operation, const Glib::RefPtr< Cancellable >& cancellable, const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
void | stop (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
bool | stop_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes stopping a drive.
bool | can_stop () const
DriveStartStopType | get_start_stop_type () const
| Gets a hint about how a drive can be started/stopped.
Glib::SignalProxy0< void > | signal_changed ()
Glib::SignalProxy0< void > | signal_disconnected ()
Glib::SignalProxy0< void > | signal_eject_button ()
Glib::SignalProxy0< void > | signal_stop_button ()
## Static Public Member Functions
static void | add_interface (GType gtype_implementer)
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::Drive > | wrap (GDrive* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Virtual File System drive management.

This represent a piece of hardware connected to the machine. It's generally only created for removable hardware or hardware with removable media. Gio::Drive is a container class for Gio::Volume 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.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::Drive::~Drive | ( |  | ) | `[virtual]`

## Member Function Documentation

static void Gio::Drive::add_interface | ( | GType | gtype_implementer | ) | `[static]`

bool Gio::Drive::can_eject | ( |  | ) | const

Checks if a drive can be ejected.

Returns:
  `true` if the drive can be ejected, `false` otherwise.

bool Gio::Drive::can_poll_for_media | ( |  | ) | const

Checks if a drive can be polled for media changes.

Returns:
  `true` if the drive can be polled for media changes, `false` otherwise.

bool Gio::Drive::can_start | ( |  | ) | const

Since glibmm 2.22:

bool Gio::Drive::can_start_degraded | ( |  | ) | const

Since glibmm 2.22:

bool Gio::Drive::can_stop | ( |  | ) | const

Since glibmm 2.22:

void Gio::Drive::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

void Gio::Drive::eject | ( | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` | ) |

Ejects the drive.

Parameters:

  | slot | A callback which will be called when the eject is completed.
  | flags | Flags affecting the unmount if required for eject.

void Gio::Drive::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady & | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

void Gio::Drive::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

void Gio::Drive::eject | ( | const SlotAsyncReady & | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

Ejects the drive.

Parameters:

  | slot | A callback which will be called when the eject is completed.
  | flags | Flags affecting the unmount if required for eject.

void Gio::Drive::eject | ( | const SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

Ejects the drive.

Parameters:

  | slot | A callback which will be called when the eject is completed or canceled.
  | flags | Flags affecting the unmount if required for eject.
  | cancellable | A cancellable object which can be used to cancel the eject.

bool Gio::Drive::eject_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes ejecting a drive.

If any errors occurred during the operation, error will be set to contain the errors and `false` will be returned.

Since glibmm 2.22:

Parameters:

  | result | A AsyncResult.

Returns:
  `true` if the drive was successfully ejected. `false` otherwise.

Glib::StringArrayHandle Gio::Drive::enumerate_identifiers | ( |  | ) | const

Gets the kinds of identifiers that drive has.

Use Glib::drive_get_identifer() to obtain the identifiers themselves.

Returns:
  A `0`-terminated array of strings containing kinds of identifiers. Use Glib::strfreev() to free.

Glib::RefPtr<const Icon> Gio::Drive::get_icon | ( |  | ) | const

Gets the icon for drive.

Returns:
  Icon for the drive. Free the returned object with Glib::object_unref().

Glib::RefPtr<Icon> Gio::Drive::get_icon | ( |  | ) |

Gets the icon for drive.

Returns:
  Icon for the drive. Free the returned object with Glib::object_unref().

std::string Gio::Drive::get_identifier | ( | const std::string & | kind | ) | const

Gets the identifier of the given kind for drive.

Parameters:

  | kind | The kind of identifier to return.

Returns:
  A newly allocated string containing the requested identfier, or `0` if the Drive doesn't have this kind of identifier.

Glib::ustring Gio::Drive::get_name | ( |  | ) | const

Gets the name of drive.

Returns:
  A string containing drive's name. The returned string should be freed when no longer needed.

DriveStartStopType Gio::Drive::get_start_stop_type | ( |  | ) | const

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

Since glibmm 2.22:

Returns:
  A value from the DriveStartStopType enumeration.

Glib::ListHandle< Glib::RefPtr<Volume> > Gio::Drive::get_volumes | ( |  | ) |

Get a list of mountable volumes for drive.

The returned list should be freed with Glib::list_free(), after its elements have been unreffed with Glib::object_unref().

Returns:
  List containing any Volume objects on the given drive.

const GDrive* Gio::Drive::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

GDrive* Gio::Drive::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

bool Gio::Drive::has_media | ( |  | ) | const

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.

Returns:
  `true` if drive has media, `false` otherwise.

bool Gio::Drive::has_volumes | ( |  | ) | const

Check if drive has any mountable volumes.

Returns:
  `true` if the drive contains volumes, `false` otherwise.

bool Gio::Drive::is_media_check_automatic | ( |  | ) | const

Checks if drive is capabable of automatically detecting media changes.

Returns:
  `true` if the drive is capabable of automatically detecting media changes, `false` otherwise.

bool Gio::Drive::is_media_removable | ( |  | ) | const

Checks if the drive supports removable media.

Returns:
  `true` if drive supports removable media, `false` otherwise.

void Gio::Drive::poll_for_media | ( |  | ) |

Polls drive to see if media has been inserted or removed.

void Gio::Drive::poll_for_media | ( | const SlotAsyncReady & | slot | ) |

Polls drive to see if media has been inserted or removed.

Parameters:

  | slot | A callback which will be called when the poll is completed.

void Gio::Drive::poll_for_media | ( | const SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable |
| ) |  |  |

Polls drive to see if media has been inserted or removed.

Parameters:

  | slot | A callback which will be called when the poll is completed.
  | cancellable | A cancellable object which can be used to cancel the operation.

bool Gio::Drive::poll_for_media_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

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

Parameters:

  | result | A AsyncResult.

Returns:
  `true` if the drive has been poll_for_mediaed successfully, `false` otherwise.

Glib::SignalProxy0< void > Gio::Drive::signal_changed | ( |  | ) |

Since glibmm 2.20:

Prototype:
  `void on_my_changed()`

Glib::SignalProxy0< void > Gio::Drive::signal_disconnected | ( |  | ) |

Since glibmm 2.20:

Prototype:
  `void on_my_disconnected()`

Glib::SignalProxy0< void > Gio::Drive::signal_eject_button | ( |  | ) |

Since glibmm 2.20:

Prototype:
  `void on_my_eject_button()`

Glib::SignalProxy0< void > Gio::Drive::signal_stop_button | ( |  | ) |

Since glibmm 2.22:
  *

Prototype:
  `void on_my_stop_button()`

void Gio::Drive::start | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady & | slot,
|  | DriveStartFlags | flags = `DRIVE_START_NONE` |
| ) |  |  |

Since glibmm 2.22:

void Gio::Drive::start | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const SlotAsyncReady & | slot,
|  | DriveStartFlags | flags = `DRIVE_START_NONE` |
| ) |  |  |

Since glibmm 2.22:

bool Gio::Drive::start_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes starting a drive.

Since glibmm 2.22:

Parameters:

  | result | A AsyncResult.

Returns:
  `true` if the drive has been started successfully, `false` otherwise.

void Gio::Drive::stop | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady & | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

Since glibmm 2.22:

void Gio::Drive::stop | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const SlotAsyncReady & | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` |
| ) |  |  |

Since glibmm 2.22:

bool Gio::Drive::stop_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes stopping a drive.

Since glibmm 2.22:

Parameters:

  | result | A AsyncResult.

Returns:
  `true` if the drive has been stopped successfully, `false` otherwise.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Drive > wrap | ( | GDrive * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.