ITzTravelInTime / TINU

TINU: The open tool to create bootable macOS installers.
GNU General Public License v2.0
492 stars 37 forks source link

[Suggestion] Use FileManager.default.mountedVolumeURLs(...) for fetching volumes #7

Closed mayankk2308 closed 5 years ago

mayankk2308 commented 5 years ago

Consider retrieving mounted volumes for selection using something like:

let volumes = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: [.volumeNameKey, .volumeAvailableCapacityKey, .volumeTotalCapacityKey, .volumeUUIDStringKey, .volumeIsInternalKey], options: [.skipHiddenVolumes])

With URLResourceKeys and VolumeEnumerationOptions suited to your needs.

ITzTravelInTime commented 5 years ago

I use a system based on the parsing of a plist string i get by reading the output of this command diskutil list -plist and using it like a json basically

The reason i use it is because i need some specific information about the drive and also there is some information i can’t get with system apis like the presence of an efi partition in a drive, all of this is used not only to detect drives but to also detect if each drive is suitable for the creation of an installer and if a specific drive needs some extra operations like mandatory format or not, i want to be sure that the finished installer created with tinu will have an EFI partition because it’s mandatory to get clover to work in some computers and also because i want to introduce an automatic clover installer inside of tinu in a future release.

So that’s why i decided to skip on using system apis for that and instead using a more complex system, and also this system gives me all the information i want to use in one plist string so no multiple calls to get information needed.

mayankk2308 commented 5 years ago

Thank you for the explanation.

You could likely accomplish what you need using DiskArbitration as well. Maybe if the skipHiddenVolumes option is disabled, you may be able to get the EFI disks too (whose information you could fetch by creating a DADisk and getting its information dictionary, also including the whole disk if needed) - though I have not tested myself.

Nonetheless, your approach to retrieving the disks piqued my interest as I am working on a different app related to disks, hence the meddling :)

Unrelated to this: It would be cool if the app included the ability to download the installer. You could refer to installinstallmacOS.py perhaps.

ITzTravelInTime commented 5 years ago

the app has already links to download the installer from the app store, just open the app and go to the menu bar and click on help and then click on download a mac os installer. I am working also on making this screen more accessible in the ui.

I did not integrate the download of the installer directly from TINU for legal reasons because i want to avoid problems with apple by provviding unuthorized distribution or download for their software.

And i did use that approach for drive detection because i was more familir with some terminal commands than system apis and also to the use of json like parsing, in fact when i worked on some commercial projects i used json a lot

ITzTravelInTime commented 4 years ago

Just to add some news, the new version 3.0 beta 1 has mooved from the old complicated system to a way more simpler one based on codable classes, so it always inteprets the output of diskutil list -plist, but it's a mutch better implementation of that and now it shows also the usb drivers entirerly rather than just usable partitions