I have a path to a partition. How can I retrieve UUID of that partition programatically without using terminal commands? An example will be more helpful.
相关问题
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Avoid cmake to add the flags -search_paths_first a
- installing packages for python 3
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
- git command-line on Mac OS error “dyld: Symbol not
You can use the Disk Arbitration framework (Apple reference). There is also a good summary at this blog by Chris Suter.
You can get the UUID by using the kDADiskDescriptionMediaUUIDKey. Aaron Burghardt described it well in this mailing list thread. Here is a quote from that link:
I think the easiest is to use polkit
Download the DiskWatcher.h and .m from http://polkit.googlecode.com/svn/trunk/FileSystem/DiskWatcher.h http://polkit.googlecode.com/svn/trunk/FileSystem/DiskWatcher.m
Add it to your project (It has no ARC so add -fno-objc-arc flag if you use ARC)
Add DiskArbiratation framework You can use
$ diskutil info / | grep UUID
Running this from C is left as an exercise for the reader.
If you want a partition other than the root, you can specify the mount point or device name (eg. disk0s2) in place of
/
.