Is there any library to create a disk image from Cocoa, or is it only possible through Finder?
Asked
Active
Viewed 1,416 times
2 Answers
7
I'm not aware of a way to do it directly from Cocoa (though there might be one) but there is another way. The hdiutil
tool can be used from the Terminal, and you can call it from your program as well. Here's a sample usage for creating a disk image from a folder:
hdiutil create -fs HFS+ -volname "Volume Name" \
-srcfolder "/path/to/source/directory" "path/to/filename.dmg"
Seems that http://www.cocoabuilder.com/archive/cocoa/152742-disc-image-apis.html describes the same problem.

Felixyz
- 19,053
- 14
- 65
- 60

Quinn Taylor
- 44,553
- 16
- 113
- 131
-
This is the path I had to go down when I wanted to automate DMG creation from my app. It's not all too painful, but it feels like it could crumble easily with the next release of OS X. – dreamlax Jun 28 '10 at 03:55
-
1Yeah, it would be nice if there was a Cocoa API to use, but the good news is that `hdiutil` has been backwards compatible, and will likely continue to be. – Quinn Taylor Jun 28 '10 at 03:59