PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/core/sdk-objc/GMAppleDouble.h

http://macfuse.googlecode.com/
C++ Header | 167 lines | 41 code | 17 blank | 109 comment | 0 complexity | 21c8682a26590b59819230d4925e2ca0 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//  GMAppleDouble.h
 33//  MacFUSE
 34//
 35//  Created by ted on 12/29/07.
 36//
 37
 38/*!
 39 * @header GMAppleDouble
 40 *
 41 * A utility class to construct an AppleDouble (._) file.
 42 *
 43 * AppleDouble files contain information about a corresponding file and are 
 44 * typically used on file systems that do not support extended attributes.
 45 */
 46
 47#import <Foundation/Foundation.h>
 48
 49#define GM_EXPORT __attribute__((visibility("default")))
 50
 51/*!
 52 * <pre>
 53 * Based on "AppleSingle/AppleDouble Formats for Foreign Files Developer's Note"
 54 *
 55 * Notes:
 56 * DoubleEntryFileDatesInfo
 57 *    File creation, modification, backup, and access times as number of seconds 
 58 *    before or after 12:00 AM Jan 1 2000 GMT as SInt32.
 59 *  DoubleEntryFinderInfo
 60 *    16 bytes of FinderInfo followed by 16 bytes of extended FinderInfo.
 61 *    New FinderInfo should be zero'd out. For a directory, when the Finder 
 62 *    encounters an entry with the init'd bit cleared, it will initialize the 
 63 *    frView field of the to a value indicating how the contents of the
 64 *    directory should be shown. Recommend to set frView to value of 256.
 65 *  DoubleEntryMacFileInfo
 66 *    This is a 32 bit flag that stores locked (bit 0) and protected (bit 1).
 67 * </pre>
 68 */
 69typedef enum {
 70  DoubleEntryInvalid = 0,
 71  DoubleEntryDataFork = 1,
 72  DoubleEntryResourceFork = 2,
 73  DoubleEntryRealName = 3,
 74  DoubleEntryComment = 4,
 75  DoubleEntryBlackAndWhiteIcon = 5,
 76  DoubleEntryColorIcon = 6,
 77  DoubleEntryFileDatesInfo = 8,  // See notes
 78  DoubleEntryFinderInfo = 9,     // See notes
 79  DoubleEntryMacFileInfo = 10,   // See notes
 80  DoubleEntryProDosFileInfo = 11,
 81  DoubleEntryMSDosFileinfo = 12,
 82  DoubleEntryShortName = 13,
 83  DoubleEntryAFPFileInfo = 14,
 84  DoubleEntryDirectoryID = 15,
 85} GMAppleDoubleEntryID;
 86
 87/*!
 88 * @class
 89 * @discussion This class represents a single entry in an AppleDouble file.
 90 */
 91GM_EXPORT @interface GMAppleDoubleEntry : NSObject {
 92 @private
 93  GMAppleDoubleEntryID entryID_;
 94  NSData* data_;  // Format depends on entryID_
 95}
 96/*! 
 97 * @abstract Initializes an AppleDouble entry with ID and data.
 98 * @param entryID A valid entry identifier
 99 * @param data Raw data for the entry
100 */
101- (id)initWithEntryID:(GMAppleDoubleEntryID)entryID data:(NSData *)data;
102
103/*! @abstract The entry ID */
104- (GMAppleDoubleEntryID)entryID;
105
106/*! @abstract The entry data */
107- (NSData *)data;
108@end
109
110/*!
111 * @class
112 * @discussion This class can be used to construct raw AppleDouble data.
113 */
114GM_EXPORT @interface GMAppleDouble : NSObject {  
115 @private
116  NSMutableArray* entries_;
117}
118
119/*! @abstract An autoreleased empty GMAppleDouble file */
120+ (GMAppleDouble *)appleDouble;
121
122/*! 
123 * @abstract An autoreleased GMAppleDouble file.
124 * @discussion The GMAppleDouble is pre-filled with entries from the raw
125 * AppleDouble file data.
126 * @param data Raw AppleDouble file data.
127 */
128+ (GMAppleDouble *)appleDoubleWithData:(NSData *)data;
129
130/*! 
131 * @abstract Adds an entry to the AppleDouble file.
132 * @param entry The entry to add
133 */
134- (void)addEntry:(GMAppleDoubleEntry *)entry;
135
136/*! 
137 * @abstract Adds an entry to the AppleDouble file with ID and data.
138 * @param entryID The ID of the entry to add
139 * @param data The raw data for the entry to add (retained)
140 */
141- (void)addEntryWithID:(GMAppleDoubleEntryID)entryID data:(NSData *)data;
142
143/*! 
144 * @abstract Adds entries based on the provided raw AppleDouble file data.
145 * @discussion This will attempt to parse the given data as an AppleDouble file
146 * and add all entries found.
147 * @param data Raw AppleDouble file data
148 * @param data The raw data for the entry to add (retained)
149 * @result YES if the provided data was parsed correctly.
150 */
151- (BOOL)addEntriesFromAppleDoubleData:(NSData *)data;
152
153/*!
154 * @abstract The set of GMAppleDoubleEntry present in this GMAppleDouble.
155 * @result An array of GMAppleDoubleEntry.
156 */
157- (NSArray *)entries;
158
159/*!
160 * @abstract Constructs raw data for the AppleDouble file.
161 * @result The raw data for an AppleDouble file represented by this GMAppleDouble.
162 */
163- (NSData *)data;
164
165@end
166
167#undef GM_EXPORT