I would just assume it is a drive (of some sort) if it is mounted under /Volumes... if it isn't then the user is probably an advanced user that is mucking about. Advanced users like that can deal with the consequences of their actions.
Though disk images that get mounted will also show up there - whether or not you consider them "drives" (they are considered mounted disks) is open to interpretation I suppose.
The best solution would be to tap into whatever the native platform offers... as you've attempted with JNA.. but you didn't state what didn't work about it.
Scott
On 2010-11-26, at 9:35 AM, Tobias Bley wrote:
> Sure it''s possible to poll the "/Volumes" directory - but how to distinguish between a directory and a drive?
>
> Yes, I need a crossplatform solution (mac/win)
>
> Tobi
>
> Am 26.11.2010 um 15:05 schrieb Scott Palmer:
>
>>
>> On 2010-11-26, at 8:35 AM, Tobias Bley wrote:
>>
>>> Hi,
>>>
>>> does anybody know a good solution in Java for watching for new connected external storage devices? (external hard disc, usb stick, ...)
>>>
>>> I tried the FileMonitor of JNA but this approach doesn't seems to work...
>>
>> What exactly did you try with FileMonitor?
>> I would have expected monitoring the /Volumes folder to do the job. You could always poll that folder to see what mount points come and go if FileMonitor isn't working for some reason.
>> Does the solution have to work cross-platform?
>> On Windows you could poll the filesystem roots to see when a new drive letter appears.
>> ("drive letters" - the bad idea of DOS still around on Windows 7, it makes me laugh!)
>>
>> Scott
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden