PageRenderTime 23ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/Common/KSDiskImage.h

http://macfuse.googlecode.com/
C++ Header | 114 lines | 24 code | 19 blank | 71 comment | 0 complexity | a3485d1e8261fdbd5ef69c390605232f MD5 | raw file
  1// Copyright 2008 Google Inc.
  2//
  3// Licensed under the Apache License, Version 2.0 (the "License");
  4// you may not use this file except in compliance with the License.
  5// You may obtain a copy of the License at
  6//
  7//     http://www.apache.org/licenses/LICENSE-2.0
  8//
  9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#import <Foundation/Foundation.h>
 16
 17
 18// KSDiskImage
 19//
 20// This class represents a disk image file. It lets you perform common
 21// operations on the disk image including mounting, unmounting, removing a
 22// software license agreement, detecting if the DMG is encrypted, etc.
 23//
 24// Example usage:
 25//
 26//   KSDiskImage *di = [KSDiskImage diskImageWithPath:@"/tmp/foo.dmg"];
 27//   NSString *mountPoint = [di mount];
 28//   /* [di isMounted] == YES */
 29//   [di unmount];
 30//
 31@interface KSDiskImage : NSObject {
 32 @private
 33  NSString *path_;
 34  NSString *mountPoint_;
 35}
 36
 37// Returns an autoreleased KSDiskImage object for the DMG at |path|.
 38+ (id)diskImageWithPath:(NSString *)path;
 39
 40// Returns a KSDiskImage object for the DMG at |path|. The file at |path| must
 41// exist and it must point to a disk image. This method is the designated
 42// initializer.
 43- (id)initWithPath:(NSString *)path;
 44
 45// Returns the path to the DMG represented by this object.
 46- (NSString *)path;
 47
 48// Returns the path where this DMG is mounted, or nil if not mounted. This
 49// method only returns a string if *this* KSDiskImage instance was the one that
 50// mounted the DMG, i.e., if two KSDiskImage objects point to the same DMG and
 51// one mounts it, the other's mountPoint will not be updated.
 52- (NSString *)mountPoint;
 53
 54// Returns YES if the disk image is encrypted.
 55- (BOOL)isEncrypted;
 56
 57// Returns YES if the disk image has a software license agreement.
 58- (BOOL)hasLicense;
 59
 60// *Attempts* to remove the license agreement from the DMG. This may not be
 61// possible for a number of reasons. It is the caller's responsiblity to make
 62// sure the license was indeed removed by calling -hasLicense.
 63- (void)removeLicense;
 64
 65// Mounts the disk image and returns the path to the mount point. If a nil
 66// value is specified, a default value is chosen. Otherwise, the requested
 67// mountPoint is used.  The mount point is not visible in the Finder.
 68- (NSString *)mount:(NSString *)mountPoint;
 69
 70// Mounts the disk image and returns the path to the mount point. If a nil
 71// value is specified, a default value is chosen. Otherwise, the requested
 72// mountPoint is used.
 73// Unlike a normal mount, the mounted image *IS* visible in the Finder.
 74- (NSString *)mountBrowsable:(NSString *)mountPoint;
 75
 76// Returns YES if the disk image is currently mounted.
 77- (BOOL)isMounted;
 78
 79// Unmounts the disk image.
 80- (BOOL)unmount;
 81
 82@end
 83
 84
 85// KSHDIUtilTask
 86//
 87// An object wrapper for the hdiutil command-line program. Users should prefer
 88// to use the KSDiskImage class in preference to this class. KSDiskImage is a
 89// higher-level abstraction. Only use this class when you need direct access to
 90// hdiutil(1).
 91//
 92// Sample usage:
 93//   NSString *output = nil;
 94//   rc = [hdiutil runWithArgs:[NSArray arrayWithObject:@"info"]
 95//                 inputString:nil
 96//                outputString:&output];
 97//   if (rc == 0) {
 98//     ... use |output|, which contains hdiutil's stdout
 99//   }
100//
101@interface KSHDIUtilTask : NSObject
102
103// Returns an autoreleased hdiutil task instance. The hdiutil task will not
104// be running yet, this is just a handle for running it with the
105// -runWithArgs:input:output: command.
106+ (id)hdiutil;
107
108// Runs an hdiutil command with the specified arguments, |input| as stdin, and
109// returns the stdout in |*output|. Any argument may be nil. The return value
110// is the exit code from hdiutil.
111- (int)runWithArgs:(NSArray *)args
112       inputString:(NSString *)input
113      outputString:(NSString **)output;
114@end