summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdecore/tdehardwaredevices.cpp15
-rw-r--r--tdecore/tdehardwaredevices.h7
2 files changed, 22 insertions, 0 deletions
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index b385538fb..b8d6cf29f 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -449,6 +449,21 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
}
}
+bool TDEStorageDevice::ejectDriveMedia() {
+ int fd = open(deviceNode().ascii(), O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ return false;
+ }
+ if (ioctl(fd, CDROMEJECT) != 0) {
+ close(fd);
+ return false;
+ }
+ else {
+ close(fd);
+ return true;
+ }
+}
+
TQString TDEStorageDevice::diskLabel() {
return m_diskName;
}
diff --git a/tdecore/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index 1f41f6267..a31fc8eef 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -661,6 +661,13 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*/
bool lockDriveMedia(bool lock);
+ /**
+ * @return TRUE on success, FALSE on failure
+ *
+ * This method currently works on CD-ROM drives and similar devices
+ */
+ bool ejectDriveMedia();
+
protected:
/**
* @param a TQString with the disk or partition label, if any