开发者

How do you get the mount point/disk drive of a USB stick in cross-platform C++ or C?

开发者 https://www.devze.com 2023-01-01 07:23 出处:网络
I\'m trying to get the mount point(linux/osx) or disk drive (wi开发者_开发技巧ndows) of a specific USB mass storage device.

I'm trying to get the mount point(linux/osx) or disk drive (wi开发者_开发技巧ndows) of a specific USB mass storage device.

I can use libusb to determine if the correct device is inserted but how do I determine where it is mounted?

I'm using C++ but I assume C code would work just as well. Cross-platform code would be preferable.


The C standard library provides no facilities for this, so true cross platform compatibility is not possible. On Windows you use a combination of GetLogicalDrives, and GetLogicalDriveType, as described here. You could probably map that information to your device by using GetVolumeInformationByHandleW.

0

精彩评论

暂无评论...
验证码 换一张
取 消