Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Volume/device attachment and removal events #5

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant

eisnerd commented Dec 15, 2011

This adds platform-specific code to fire global "volume.added" and "volume.removed" events when removable devices containing filesystems are attached or ejected/removed. One event is fired per device, rather than per filesystem, and no specific information about the device(s) in question is provided.

I have added these same simple, you might say crude, system-related events to this branch for OS X and to the v1.2-windows branch with a similar implementation for Windows. Rather than providing a full device/volume information API, we have found simply being notified that some kind of change has occurred very useful in our application, with further platform-specific code that it may not be worth lumbering the SDK with being used in response to these events to identify and examine the devices of interest, such as USB flash drives.

The DiskDescriptionChanged callback is used, with the VolumePath property being monitored, instead of the DiskAppeared callback, to provide the event at a time when the volume has been mounted ready for use in the application. Disks without partitions and/or volumes or volumes that do not get mounted would be filtered by the code in report_disk anyway, which also filter out readonly, network and fixed-disk volumes, as this has been geared for an application wishing to manipulate removable storage devices. A more full API for disk information and notification would of course need the flexibility for such filters to be choosen by the application and in a platform-neutral way, but I think may be a useful interim for a variety of projects.

Thank you for considering this submission.

Report volume removal and attachment events
on OS X, as volume.removed and volume.added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment