/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. #import <Foundation/Foundation.h>
  15. // KSDiskImage
  16. //
  17. // This class represents a disk image file. It lets you perform common
  18. // operations on the disk image including mounting, unmounting, removing a
  19. // software license agreement, detecting if the DMG is encrypted, etc.
  20. //
  21. // Example usage:
  22. //
  23. // KSDiskImage *di = [KSDiskImage diskImageWithPath:@"/tmp/foo.dmg"];
  24. // NSString *mountPoint = [di mount];
  25. // /* [di isMounted] == YES */
  26. // [di unmount];
  27. //
  28. @interface KSDiskImage : NSObject {
  29. @private
  30. NSString *path_;
  31. NSString *mountPoint_;
  32. }
  33. // Returns an autoreleased KSDiskImage object for the DMG at |path|.
  34. + (id)diskImageWithPath:(NSString *)path;
  35. // Returns a KSDiskImage object for the DMG at |path|. The file at |path| must
  36. // exist and it must point to a disk image. This method is the designated
  37. // initializer.
  38. - (id)initWithPath:(NSString *)path;
  39. // Returns the path to the DMG represented by this object.
  40. - (NSString *)path;
  41. // Returns the path where this DMG is mounted, or nil if not mounted. This
  42. // method only returns a string if *this* KSDiskImage instance was the one that
  43. // mounted the DMG, i.e., if two KSDiskImage objects point to the same DMG and
  44. // one mounts it, the other's mountPoint will not be updated.
  45. - (NSString *)mountPoint;
  46. // Returns YES if the disk image is encrypted.
  47. - (BOOL)isEncrypted;
  48. // Returns YES if the disk image has a software license agreement.
  49. - (BOOL)hasLicense;
  50. // *Attempts* to remove the license agreement from the DMG. This may not be
  51. // possible for a number of reasons. It is the caller's responsiblity to make
  52. // sure the license was indeed removed by calling -hasLicense.
  53. - (void)removeLicense;
  54. // Mounts the disk image and returns the path to the mount point. If a nil
  55. // value is specified, a default value is chosen. Otherwise, the requested
  56. // mountPoint is used. The mount point is not visible in the Finder.
  57. - (NSString *)mount:(NSString *)mountPoint;
  58. // Mounts the disk image and returns the path to the mount point. If a nil
  59. // value is specified, a default value is chosen. Otherwise, the requested
  60. // mountPoint is used.
  61. // Unlike a normal mount, the mounted image *IS* visible in the Finder.
  62. - (NSString *)mountBrowsable:(NSString *)mountPoint;
  63. // Returns YES if the disk image is currently mounted.
  64. - (BOOL)isMounted;
  65. // Unmounts the disk image.
  66. - (BOOL)unmount;
  67. @end
  68. // KSHDIUtilTask
  69. //
  70. // An object wrapper for the hdiutil command-line program. Users should prefer
  71. // to use the KSDiskImage class in preference to this class. KSDiskImage is a
  72. // higher-level abstraction. Only use this class when you need direct access to
  73. // hdiutil(1).
  74. //
  75. // Sample usage:
  76. // NSString *output = nil;
  77. // rc = [hdiutil runWithArgs:[NSArray arrayWithObject:@"info"]
  78. // inputString:nil
  79. // outputString:&output];
  80. // if (rc == 0) {
  81. // ... use |output|, which contains hdiutil's stdout
  82. // }
  83. //
  84. @interface KSHDIUtilTask : NSObject
  85. // Returns an autoreleased hdiutil task instance. The hdiutil task will not
  86. // be running yet, this is just a handle for running it with the
  87. // -runWithArgs:input:output: command.
  88. + (id)hdiutil;
  89. // Runs an hdiutil command with the specified arguments, |input| as stdin, and
  90. // returns the stdout in |*output|. Any argument may be nil. The return value
  91. // is the exit code from hdiutil.
  92. - (int)runWithArgs:(NSArray *)args
  93. inputString:(NSString *)input
  94. outputString:(NSString **)output;
  95. @end