Open vasyl-shumskyi opened 6 years ago
For now I can say that it's much harder to implement than labels for parts. Furthermore I need to provide the same functionality for unix based system (and mac-OS) because I'm trying to maintain the project fully cross-platform. Additionally it's harder to test properly (I need to test it on a few platforms with a few device types (flashdrive, external hdd storage etc.)).
I would say I cannot see for now any way of detecting type of a storage without huge overhead (in times both code and performance).
As for me It could be a good idea for the separate project. Let's say media-info
which could take a place
in terms hdd-space
(cross-platform string like: X:
, /dev/sda2
, etc.) and returns something ilke this:
{
type: 'flashdrive',
interface: 'usb',
filesystem: 'ntfs'
...
}
or
{
type: 'ssd',
interface: 'SCSI',
filesystem: 'ext4'
...
}
Speaking about your case, I suggest you don't need support of unix based system (surely I can be wrong) thus It'd be much easier for you to implement that logic for the only one platform. https://ardamis.com/2012/08/21/getting-a-list-of-logical-and-physical-drives-from-the-command-line/ here's the article about wmic util (which output is used in hdd-space
internally), I hope that will help you.
It's not a final decision and we can discuss it further.
Unfortunately, I do need USB-detection cross-platform :-]
Earlier i've handled all 3 platforms via and @sindresorhus/df
and one of wmic
npms. Until discovered you nice cross-platform module. So switched to it.
https://www.npmjs.com/package/@sindresorhus/df (linux, darwin)
My first thoughts was to track on *nix platforms via mount-points somehow
if (process.platform == 'linux')
return
disk.place.startsWith('/media') ||
disk.place.startsWith('/mnt') ||
disk.place.startsWith('/mount')
But I'm not pretty sure how to handle this on win32
, since place
will be just another letter. So declined this solution.
Since I need to find a way to detect USB flash storages mostly and use appropriate icon for them, I thought it would be fine to use same hdd-icon for removable and internal hard drives. But its not always will be quite true
to track as flash storage anything with a size < 64G
, since there can be smaller partitions on Linux.
Cross-platform drivelist
seems to detect flash-storages via system: true/false
but its not showing free/used space:
https://www.npmjs.com/package/drivelist
So I believe there should be the way to detect connected interface somehow
Related issues: Detect a drive type https://github.com/resin-io-modules/drivelist/issues/64 Removable drive https://github.com/resin-io-modules/drivelist/issues/18
Thanks for you help!
Is it possible to detect external media connected via USB and process such disks or flash drives separately?
Like so:
Thanks!