PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/core/sdk-objc/GMResourceFork.h

http://macfuse.googlecode.com/
C++ Header | 148 lines | 36 code | 19 blank | 93 comment | 0 complexity | fa297e7ebc18991f4972ae320f577642 MD5 | raw file
  1// ================================================================
  2// Copyright (c) 2007, Google Inc.
  3// All rights reserved.
  4//
  5// Redistribution and use in source and binary forms, with or without
  6// modification, are permitted provided that the following conditions are
  7// met:
  8//
  9// * Redistributions of source code must retain the above copyright
 10//   notice, this list of conditions and the following disclaimer.
 11// * Redistributions in binary form must reproduce the above
 12//   copyright notice, this list of conditions and the following disclaimer
 13//   in the documentation and/or other materials provided with the
 14//   distribution.
 15// * Neither the name of Google Inc. nor the names of its
 16//   contributors may be used to endorse or promote products derived from
 17//   this software without specific prior written permission.
 18//
 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30// ================================================================
 31//
 32//  GMResourceFork.h
 33//  MacFUSE
 34//
 35//  Created by ted on 12/29/07.
 36//
 37
 38/*!
 39 * @header GMResourceFork
 40 *
 41 * A utility class to construct raw resource fork data.
 42 * 
 43 * In OS 10.4, the ResourceFork for a file may be present in an AppleDouble (._) 
 44 * file that is associated with the file. In 10.5+, the ResourceFork is present 
 45 * in the com.apple.ResourceFork extended attribute on a file.
 46 */
 47
 48#import <Foundation/Foundation.h>
 49
 50#define GM_EXPORT __attribute__((visibility("default")))
 51
 52@class GMResource;
 53
 54/*!
 55 * @class
 56 * @discussion This class can be used to construct raw NSData for a resource 
 57 * fork. For more information about resource forks, see the CarbonCore/Finder.h 
 58 * header file.
 59 */
 60GM_EXPORT @interface GMResourceFork : NSObject {
 61 @private
 62  NSMutableDictionary* resourcesByType_;
 63}
 64
 65/*! @abstract Returns an autoreleased GMResourceFork */
 66+ (GMResourceFork *)resourceFork;
 67
 68/*! 
 69 * @abstract Adds a resource to the resource fork by specifying components.
 70 * @discussion See CarbonCore/Finder.h for some common resource identifiers.
 71 * @param resType The four-char code for the resource, e.g. 'icns'
 72 * @param resID The ID of the resource, e.g. 256 for webloc 'url' contents
 73 * @param name The name of the resource; may be nil (retained)
 74 * @param data The raw data for the resource (retained)
 75 */
 76- (void)addResourceWithType:(ResType)resType
 77                      resID:(ResID)resID
 78                       name:(NSString *)name
 79                       data:(NSData *)data;
 80
 81/*! 
 82 * @abstract Adds a resource to the resource fork.
 83 * @discussion See CarbonCore/Finder.h for some common resource identifiers.
 84 * @param resource The resource to add.
 85 */
 86- (void)addResource:(GMResource *)resource;
 87
 88/*! 
 89 * @abstract Constucts the raw data for the resource fork.
 90 * @result NSData for the resource fork containing all added resources.
 91 */
 92- (NSData *)data;
 93
 94@end
 95
 96/*!
 97 * @class
 98 * @discussion This class represents a single resource in a resource fork.
 99 */
100GM_EXPORT @interface GMResource : NSObject {
101 @private
102  ResType resType_;  // FourCharCode, i.e. 'icns'
103  ResID resID_;    // SInt16, i.e. 256 for webloc 'url ' contents.
104  NSString* name_;  // Retained: The name of the resource.
105  NSData* data_;  // Retained: The raw data for the resource.
106}
107
108/*! 
109 * @abstract Returns an autoreleased resource by specifying components.
110 * @discussion See CarbonCore/Finder.h for some common resource identifiers.
111 * @param resType The four-char code for the resource, e.g. 'icns'
112 * @param resID The ID of the resource, e.g. 256 for webloc 'url' contents
113 * @param name The name of the resource; may be nil (retained)
114 * @param data The raw data for the resource (retained)
115 */
116+ (GMResource *)resourceWithType:(ResType)resType
117                           resID:(ResID)resID
118                            name:(NSString *)name  // May be nil
119                            data:(NSData *)data;
120
121/*! 
122 * @abstract Initializes a resource by specifying components.
123 * @discussion See CarbonCore/Finder.h for some common resource identifiers.
124 * @param resType The four-char code for the resource, e.g. 'icns'
125 * @param resID The ID of the resource, e.g. 256 for webloc 'url' contents
126 * @param name The name of the resource; may be nil (retained)
127 * @param data The raw data for the resource (retained)
128 */
129- (id)initWithType:(ResType)resType
130             resID:(ResID)resID 
131              name:(NSString *)name  // May be nil
132              data:(NSData *)data;
133
134/*! @abstract The resource ID */
135- (ResID)resID;
136
137/*! @abstract The four-char code resource type */
138- (ResType)resType;
139
140/*! @abstract The resource name or nil if none */
141- (NSString *)name;
142
143/*! @abstract The resource data */
144- (NSData *)data;
145
146@end
147
148#undef GM_EXPORT