Methods



addData:type:Id:name:

Abstract: Adds a resource to the receivers resource file.
- (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

Parameters

NameDescription
aDataAn NSData object containing the data to be added as a resource to the receivers resource file.
aTypeThe resource type of the resource to be added.
anIDThe resource ID of the resource to be added.
aNameThe name of the resource to be added.
Result: Returns YES if the resource was successfully added, otherwise it returns NO.

addData:type:name:

Abstract: Adds a resource to the receivers resource file.
- (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

Parameters

NameDescription
aDataAn NSData object containing the data to be added as a resource to the receivers resource file.
aTypeThe resource type of the resource to be added.
aNameThe name of the resource to be added.
Result: Returns YES if the resource was successfully added, otherwise it returns NO.

dataForEntireResourceFork

Abstract: Reads the receivers entire resource data.
- (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.

dataForType:Id:

Abstract: Gets resource data for a resource in the receivers resource file.
- (NSData *)dataForType:(ResType)aType Id:(short int)anID; 

dataForType:Id: searches the receivers resource file's resource map in memory for the specified resource.

Parameters

NameDescription
aTypeThe resource type of the resource which you wish to retrieve data.
anIDAn integer that uniquely identifies the resource which you wish to retrieve data.
Result: Returns an NSData object if successful otherwise returns nil.

dataForType:named:

Abstract: Gets resource data for a resource in the receivers resource file.
- (NSData *)dataForType:(ResType)aType named:(NSString *)aName; 

dataForType:Id: searches the receivers resource file's resource map in memory for the specified resource.

Parameters

NameDescription
aTypeThe resource type of the resource which you wish to retrieve data.
aNameA name that uniquely identifies the resource which you wish to retrieve data. Strings passed in this parameter are case-sensitive.
Result: Returns an NSData object if successful otherwise returns nil.

everyResourceType

Abstract: Gets every resource type available in the receivers resource file.
- (NSArray *)everyResourceType; 

everyResourceType returns an NSArray of NSNumbers each containing a unsigned long or ResTypes.

Result: A NSArray of NSNumbers containing ResTypes.

getAttributeFlags:forResourceType:Id:

Abstract: Gets a resource's attributes.
- (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.

Parameters

NameDescription
attributesA pointer to an short int that on return contains the resources attributes, if the returned value is YES.
aTypeThe resource type of the resource for which you wish to retrieve the attributes.
anIdAn integer that uniquely identifies the resource for which you wish to retrieve the attributes.
Result: A YES if retrieval was successful.

getId:ofResourceType:named:

Abstract: Gets a named resource's resource id.
- (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.

Parameters

NameDescription
anIDA pointer to an short int that on return contains the resources id, if the returned value is YES.
aTypeThe resource type of the resource for which you wish to retrieve the id.
aNameThe resource name of the resource for which you wish to retrieve the id.
Result: A YES if retrieval was successful.

iconFamilyDataForFile:

Abstract: Gets a files or directories Icon Family Data.
+ (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.

Parameters

NameDescription
aPathThe path for which the Icon Family Data is required.
Result: A NSData contain the Icon Family Data, returns nil if iconFamilyDataForURL: failed.

iconFamilyDataForURL:

Abstract: Gets a files or directories Icon Family Data.
+ (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.

Parameters

NameDescription
aURLThe file url for which the Icon Family Data is required.
Result: A NSData contain the Icon Family Data, returns nil if iconFamilyDataForURL: failed.

initForPermission:AtPath:

Abstract: Initalises a NDResourceFork.
- (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.

Parameters

NameDescription
aPermissionread/write permissions for the opened resource fork.
aPathA path specifying the name and location of the file whose resource fork is to be opened.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

initForPermission:AtURL:

Abstract: Initalises a NDResourceFork.
- (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.

Parameters

NameDescription
aPermissionread/write permissions for the opened resource fork.
aURLA file url specifying the name and location of the file whose resource fork is to be opened.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

initForReadingAtPath:

Abstract: Initalises a NDResourceFork.
- (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.

Parameters

NameDescription
aPathA path specifying the name and location of the file whose resource fork is to be opened.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

initForReadingAtURL:

Abstract: Initalises a NDResourceFork.
- (id)initForReadingAtURL:(NSURL *)aURL; 

Intializes the receiver and opens a resource fork for reading using the file url.

Parameters

NameDescription
aURLA 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.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

initForReadingAtURL:

Abstract: Initalises a NDResourceFork.
- (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.

Parameters

NameDescription
aURLA file url specifying the name and location of the file whose resource fork is to be opened.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

initForWritingAtPath:

Abstract: Initalises a NDResourceFork.
- (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.

Parameters

NameDescription
aPathA path specifying the name and location of the file whose resource fork is to be opened.
Result: An initialized NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or initalization failed.

nameOfResourceType:Id:

Abstract: Gets a resource's resource name.
- (NSString *)nameOfResourceType:(ResType)aType Id:(short int)anID; 

Returns a resources name as an NSString.

Parameters

NameDescription
aTypeThe resource type of the resource for which you wish to retrieve the name.
anIDAn integer that uniquely identifies the resource for which you wish to retrieve the name.
Result: An NSString containing the resources name.

removeType:Id:

Abstract: Removes a resource's entry from the receivers resource file.
- (BOOL)removeType:(ResType)aType Id:(short int)anID; 

If the resProtected attribute for the resource is set, removeType:Id: does nothing, and returns NO.

Parameters

NameDescription
aTypeThe resource type of the resource which you wish to remove.
anIDAn integer that uniquely identifies the resource which you wish to remove.
Result: Returns YES if the resource was successfully removed, otherwise if returns NO.

resourceForkForReadingAtPath:

Abstract: Creates and initalises a NDResourceFork.
+ (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.

Parameters

NameDescription
aPathA path specifying the name and location of the file whose resource fork is to be opened.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.

resourceForkForReadingAtURL:

Abstract: Creates and initalises a NDResourceFork.
+ (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.

Parameters

NameDescription
aURLA file url specifying the name and location of the file whose resource fork is to be opened.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.

resourceForkForWritingAtPath:

Abstract: Creates and initalises a NDResourceFork.
+ (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.

Parameters

NameDescription
aPathA path specifying the name and location of the file whose resource fork is to be opened.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.

resourceForkForWritingAtURL:

Abstract: Creates and initalises a NDResourceFork.
+ (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.

Parameters

NameDescription
aURLA file url specifying the name and location of the file whose resource fork is to be opened.
Result: A NDResourceFork for an opened resource fork, returns nil if the resource fork could not be opened or Create and initalise failed.

setAttributeFlags:forResourceType:Id:

Abstract: Sets a resource's attributes.
- (BOOL)setAttributeFlags:(short int)attributes forResourceType:(ResType)aType Id:(short int)anId; 

ĒDiscussionČ

Parameters

NameDescription
attributesA short int that contains the resources attributes to be set.
aTypeThe resource type of the resource for which you wish to set the attributes.
anIdAn integer that uniquely identifies the resource for which you wish to set the attributes.
Result: A YES if setAttributeFlags:forResourceType:Id: was successful in setting the resources attributes.

writeEntireResourceFork:

Abstract: Writes complete resource data to the receivers resource fork.
- (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:.

Parameters

NameDescription
aDataThe complete resource data in a NSData object.
Result: Returns YES if writting was successful, returns NO otherwise.

© 2003 Nathan Day — (Last Updated 11/30/2003)