- (BOOL)addData:(NSData *)aData type:(ResType)aType Id:(short int)anID name:(NSString *)aName;
addData:type:name: doesn't verify whether the resource ID you pass in the parameter anID is already assigned to another resource of the same type. You should use the methods addData:type:name: or dataForType:named: to get a unique resource ID when adding a resource . addData:type:Id:named: returns YES on success
Result: Returns YES if the resource was successfully added, otherwise it returns NO.
Name Description aData An NSData object containing the data to be added as a resource to the receivers resource file. aType The resource type of the resource to be added. anID The resource ID of the resource to be added. aName The name of the resource to be added.
- (BOOL)addData:(NSData *)aData type:(ResType)aType name:(NSString *)aName;
addData:type:name: uses an unique resource ID when adding a resource . addData:type:Id:named: returns YES on success
Result: Returns YES if the resource was successfully added, otherwise it returns NO.
Name Description aData An NSData object containing the data to be added as a resource to the receivers resource file. aType The resource type of the resource to be added. aName The name of the resource to be added.
- (NSData *)dataForEntireResourceFork;
dataForEntireResourceFork returns a NSData object that contains the entire contents of the resource fork. dataForEntireResourceFork and it's conpanion method writeEntireResourceFork can be used for duplicating the resource fork for on file to the resource fork of another. dataForEntireResourceFork can also be used to convert a resource stored in a files resource fork into a resource stored in a data fork, simple by using the NSData methods writeToFile:atomically: or writeToURL:atomically:.
Result: A NSData object containing the resources data.- (NSData *)dataForType:(ResType)aType Id:(short int)anID;
dataForType:Id: searches the receivers resource file's resource map in memory for the specified resource.
Result: Returns an NSData object if successful otherwise returns nil.
Name Description aType The resource type of the resource which you wish to retrieve data. anID An integer that uniquely identifies the resource which you wish to retrieve data.
- (NSData *)dataForType:(ResType)aType named:(NSString *)aName;
dataForType:Id: searches the receivers resource file's resource map in memory for the specified resource.
Result: Returns an NSData object if successful otherwise returns nil.
Name Description aType The resource type of the resource which you wish to retrieve data. aName A name that uniquely identifies the resource which you wish to retrieve data. Strings passed in this parameter are case-sensitive.
- (NSArray *)everyResourceType;
everyResourceType returns an NSArray of NSNumbers each containing a unsigned long or ResTypes.
Result: A NSArray of NSNumbers containing ResTypes.- (BOOL)getAttributeFlags:(short int*)attributes forResourceType:(ResType)aType Id:(short int)anId;
Returns the attributes for a resource in a pointer to a short int and returns YES if retrieval of the attributes is succeeded. If getAttributeFlags:forResourceType:Id: returns NO then the value returned through the pointer attributes is garabage.
Result: A YES if retrieval was successful.
Name Description attributes A pointer to an short int that on return contains the resources attributes, if the returned value is YES. aType The resource type of the resource for which you wish to retrieve the attributes. anId An integer that uniquely identifies the resource for which you wish to retrieve the attributes.
- (BOOL)getId:(short int *)anId ofResourceType:(ResType)aType named:(NSString *)aName;
Returns a resources id in a pointer to a short int and returns YES if retrieval of the id is succeeded. If getId:ofResourceType:named: returns NO then the value returned through the pointer anId is garabage.
Result: A YES if retrieval was successful.
Name Description anID A pointer to an short int that on return contains the resources id, if the returned value is YES. aType The resource type of the resource for which you wish to retrieve the id. aName The resource name of the resource for which you wish to retrieve the id.
+ (NSData *)iconFamilyDataForFile:(NSString *)aPath;
iconFamilyDataForURL: returns the Icon Family Data for any file or directory. The file does not have to have an actual resource fork with the Icon Family Data in it, neither does a directory have to have an Icon/r file with the Icon Family Data.
Result: A NSData contain the Icon Family Data, returns nil if iconFamilyDataForURL: failed.
Name Description aPath The path for which the Icon Family Data is required.
+ (NSData *)iconFamilyDataForURL:(NSURL *)aURL;
iconFamilyDataForURL: returns the Icon Family Data for any file or directory. The file does not have to have an actual resource fork with the Icon Family Data in it, neither does a directory have to have an Icon/r file with the Icon Family Data.
Result: A NSData contain the Icon Family Data, returns nil if iconFamilyDataForURL: failed.
Name Description aURL The file url for which the Icon Family Data is required.
- (id)initForPermission:(char)aPermission AtPath:(NSString *)aPath;
Intializes the receiver and opens a resource fork for reading and/or writting using the path. If write permission is specified, then an empty resource fork created before hand if it does not already exists. The receivers resource fork is closed when the receiver is deallocated. Possible permission values are as follows;
fsCurPerm | Requests whatever permissions are currently allowed. If write access in unavailable (because the file is locked or the file is already open with write permission), then read permission is granted. Otherwise read/write permission is granted. |
fsRdPerm | Requests permission to read the file. |
fsWrPerm | Requests permission to write to the file. If write permission is granted, no other access paths are granted write permission. Note, however, that the File Manager does not support write-only access to a file. Thus, fsWrPerm is synonymous with fsRdWrPerm . |
fsRdWrPerm | Requests exclusive read and write permission. If exclusive read/ write permission is granted, no other users are granted permission to write to the file. Other users may, however, be granted permission to read the file. |
fsRdWrShPerm | Requests shared read and write permission. Shared read/ write permission allows mutliple access paths for reading and writing. This is safe only if there is some way of locking portions of the file before writing to them. Use the functions PBLockRangeSync and PBUnlockRangeSync to lock and unlock ranges of bytes within a file. On Mac OS 8 and 9, these functions are supported only on remotely mounted volumes, or on local volumes that are shareable on the network. You should check that range locking is available before requesting shared read/ write permission. On Mac OS X, range locking is available on all volumes. |
fsRdDenyPerm | Requests that any other paths be prevented from having read access. A path cannot be opened if you request read permission (with the fsRdPerm constant) but some other path has requested deny-read access. Similarly, the path cannot be opened if you request deny-read permission, but some other path already has read access. This constant is used with the PBHOpenDenySync and PBHOpenRFDenySync functions. |
fsWrDenyPerm | Requests that any other paths be prevented from having write access. A path cannot be opened if you request write permission (with the fsWrPerm constant) but some other path has requested deny-write access. Similarly, the path cannot be opened if you request deny-write permission, but some other path already has write access. This constant is used with the PBHOpenDenySync and PBHOpenRFDenySync functions. |
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aPermission read/write permissions for the opened resource fork. aPath A path specifying the name and location of the file whose resource fork is to be opened.
- (id)initForPermission:(char)aPermission AtURL:(NSURL *)aURL;
Intializes the receiver and opens a resource fork for reading and/or writting using the file url. If write permission is specified, then an empty resource fork created before hand if it does not already exists. The receivers resource fork is closed when the receiver is deallocated.Possible permission values are as follows;
fsCurPerm | Requests whatever permissions are currently allowed. If write access in unavailable (because the file is locked or the file is already open with write permission), then read permission is granted. Otherwise read/write permission is granted. |
fsRdPerm | Requests permission to read the file. |
fsWrPerm | Requests permission to write to the file. If write permission is granted, no other access paths are granted write permission. Note, however, that the File Manager does not support write-only access to a file. Thus, fsWrPerm is synonymous with fsRdWrPerm . |
fsRdWrPerm | Requests exclusive read and write permission. If exclusive read/ write permission is granted, no other users are granted permission to write to the file. Other users may, however, be granted permission to read the file. |
fsRdWrShPerm | Requests shared read and write permission. Shared read/ write permission allows mutliple access paths for reading and writing. This is safe only if there is some way of locking portions of the file before writing to them. Use the functions PBLockRangeSync and PBUnlockRangeSync to lock and unlock ranges of bytes within a file. On Mac OS 8 and 9, these functions are supported only on remotely mounted volumes, or on local volumes that are shareable on the network. You should check that range locking is available before requesting shared read/ write permission. On Mac OS X, range locking is available on all volumes. |
fsRdDenyPerm | Requests that any other paths be prevented from having read access. A path cannot be opened if you request read permission (with the fsRdPerm constant) but some other path has requested deny-read access. Similarly, the path cannot be opened if you request deny-read permission, but some other path already has read access. This constant is used with the PBHOpenDenySync and PBHOpenRFDenySync functions. |
fsWrDenyPerm | Requests that any other paths be prevented from having write access. A path cannot be opened if you request write permission (with the fsWrPerm constant) but some other path has requested deny-write access. Similarly, the path cannot be opened if you request deny-write permission, but some other path already has write access. This constant is used with the PBHOpenDenySync and PBHOpenRFDenySync functions. |
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aPermission read/write permissions for the opened resource fork. aURL A file url specifying the name and location of the file whose resource fork is to be opened.
- (id)initForReadingAtPath:(NSString *)aPath;
Intializes the receiver and opens a resource fork for reading using the path. The receivers resource fork is closed when the receiver is deallocated.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aPath A path specifying the name and location of the file whose resource fork is to be opened.
- (id)initForReadingAtURL:(NSURL *)aURL;
Intializes the receiver and opens a resource fork for reading using the file url.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aURL A file url specifying the name and location of the file whose resource fork is to be opened. The receivers resource fork is closed when the receiver is deallocated.
- (id)initForWritingAtURL:(NSURL *)aURL;
Intializes the receiver and opens a resource fork for writting, creating it before hand if it does not already exists, using the file url. The receivers resource fork is closed when the receiver is deallocated.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aURL A file url specifying the name and location of the file whose resource fork is to be opened.
- (id)initForWritingAtPath:(NSString *)aPath;
Intializes the receiver and opens a resource fork for writting, creating it before hand if it does not already exists, using the path. The receivers resource fork is closed when the receiver is deallocated.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.
Name Description aPath A path specifying the name and location of the file whose resource fork is to be opened.
- (NSString *)nameOfResourceType:(ResType)aType Id:(short int)anID;
Returns a resources name as an NSString.
Result: An NSString containing the resources name.
Name Description aType The resource type of the resource for which you wish to retrieve the name. anID An integer that uniquely identifies the resource for which you wish to retrieve the name.
- (BOOL)removeType:(ResType)aType Id:(short int)anID;
If the resProtected attribute for the resource is set, removeType:Id: does nothing, and returns NO.
Result: Returns YES if the resource was successfully removed, otherwise if returns NO.
Name Description aType The resource type of the resource which you wish to remove. anID An integer that uniquely identifies the resource which you wish to remove.
+ (id)resourceForkForReadingAtPath:(NSString *)aPath;
Creates and intializes a NDResourceFork and opens a resource fork for reading using the path. The receivers resource fork is closed when the receiver is deallocated.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.
Name Description aPath A path specifying the name and location of the file whose resource fork is to be opened.
+ (id)resourceForkForReadingAtURL:(NSURL *)aURL;
Creates and intializes a NDResourceFork and opens a resource fork for reading using the file url.. The NDResourceFork resource fork is closed when the receiver is deallocated.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.
Name Description aURL A file url specifying the name and location of the file whose resource fork is to be opened.
+ (id)resourceForkForWritingAtPath:(NSString *)aPath;
Creates and intializes a NDResourceForkr and opens a resource fork for writting, creating it before hand if it does not already exists, using the path. The receivers resource fork is closed when the receiver is deallocated.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.
Name Description aPath A path specifying the name and location of the file whose resource fork is to be opened.
+ (id)resourceForkForWritingAtURL:(NSURL *)aURL;
Creates and intializes a NDResourceFork and opens a resource fork for writting, creating it before hand if it does not already exists, using the file url. The NDResourceFork resource fork is closed when the receiver is deallocated.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.
Name Description aURL A file url specifying the name and location of the file whose resource fork is to be opened.
- (BOOL)setAttributeFlags:(short int)attributes forResourceType:(ResType)aType Id:(short int)anId;
ĒDiscussionČ
Result: A YES if setAttributeFlags:forResourceType:Id: was successful in setting the resources attributes.
Name Description attributes A short int that contains the resources attributes to be set. aType The resource type of the resource for which you wish to set the attributes. anId An integer that uniquely identifies the resource for which you wish to set the attributes.
- (BOOL)writeEntireResourceFork:(NSData *)aData;
writeEntireResourceFork: writes the data in the NSData object out the the recievers resource fork. writeEntireResourceFork and it's conpanion method dataForEntireResourceFork can be used for duplicating the resource fork for on file to the resource fork of another. writeEntireResourceFork: can also be used to convert a resource stored in a files data fork into a resource stored in a files resource fork, simple by creating the NSData object with the methods dataWithContentsOfFile or dataWithContentsOfURL:.
Result: Returns YES if writting was successful, returns NO otherwise.
Name Description aData The complete resource data in a NSData object.
© 2003 Nathan Day (Last Updated 11/30/2003)