UsbStorage¶
Description¶
The UsbStorage object is a Storage object which provides access to a USB drive connected to the local device. Whenever a USB drive is detected by the system, the UsbStorage object mounts it automatically and updates the Storage.available property. When writing files to a USB drive make sure to call eject() before allowing the user to unplug the drive.
› Inherits: | Storage |
---|
Properties¶
error¶
This property holds the most recently occurred error or UsbStorage.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
› Type: | Error |
---|---|
› Signal: | errorChanged() |
› Attributes: | Readonly |
Methods¶
eject()¶
This method writes all pending data to the USB drive and unmounts it so it can be removed safely. After unmounting it’s not accessible any longer until the USB drive is physically plugged in again.
› Returns: | Boolean |
---|
sync()¶
This method writes all pending data (i.e. write buffers/caches) to the USB drive.
Signals¶
Enumerations¶
Example¶
import InCore.Foundation 2.5
Application {
CsvWriter {
id: csvWriter
// create fictional measurements
Repeater on objects {
model: 3
Measurement {
name: "meas" + index
data: index
}
}
// write one data row to CSV file to USB drive whenever it is plugged in and eject it afterwards
output: File {
fileName: "measurements.csv"
storage: UsbStorage {
onAvailableChanged: {
csvWriter.submit()
eject();
}
}
}
}
}