/usr/bin/hdiutil
developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/hdiutil.1.html
The default options for hdiutil attach.
The default options for hdiutil.
Perform read-only actions on the input image.
If a block is given the block will be yielded with the path of the mount point directory, otherwise a shell will be open.
input - The String path to the input image.
# File lib/iesd/utility/hdiutil.rb, line 22 def self.read input Dir.mktmpdir { |mountpoint| attach input, mountpoint, [*DEFAULT_OPTIONS, *DEFAULT_MOUNT_OPTIONS] if block_given? yield mountpoint else shell mountpoint end detach input, mountpoint, [*DEFAULT_OPTIONS] } end
Returns true if the image is valid, false otherwise.
url - The String path to the image.
# File lib/iesd/utility/hdiutil.rb, line 75 def self.validate url Kernel.system(%[/usr/bin/env hdiutil imageinfo #{url.shellescape} >/dev/null 2>&1]) end
Perform read-write actions on the input image and export as the output image.
If a block is given the block will be yielded with the path of the mount point directory, otherwise a shell will be open.
input - The String path to the input image. output - The String path to the output image. options - The Dictionary of hdiutil options.
# File lib/iesd/utility/hdiutil.rb, line 41 def self.write input, output, options = {} options = { :resize => { :grow => 0, :shrink => false } }.merge(options) Dir.mktmpdir { |tmp| shadow = File.join(tmp, "#{File.basename input}.shadow") shadow_options = ["-shadow", shadow] format_options = ["-format", `/usr/bin/env hdiutil imageinfo -format #{input.shellescape}`.chomp] Dir.mktmpdir(nil, tmp) { |mountpoint| resize_limits = `/usr/bin/env hdiutil resize -limits -shadow #{shadow.shellescape} #{input.shellescape}`.chomp.split.map { |s| s.to_i } sectors = (resize_limits[1] + options[:resize][:grow]).to_s system("/usr/bin/env", "hdiutil", "resize", "-growonly", "-sectors", sectors, *shadow_options, input) attach input, mountpoint, [*DEFAULT_OPTIONS, *DEFAULT_MOUNT_OPTIONS, *shadow_options] if block_given? yield mountpoint else shell mountpoint end detach input, mountpoint, [*DEFAULT_OPTIONS] system("/usr/bin/env", "hdiutil", "resize", "-shrinkonly", "-sectors", "min", *shadow_options, input) if options[:resize][:shrink] } oh1 "Merging #{shadow}" system("/usr/bin/env", "hdiutil", "convert", *DEFAULT_OPTIONS, *format_options, *shadow_options, "-o", output, input) puts "Merged: #{output}" } end
Generated with the Darkfish Rdoc Generator 2.