Important: The information in this document is obsolete and should not be used for new development.
GetDiskFragment
You can use theGetDiskFragment
function to locate and possibly also load a fragment contained in a file's data fork into your application's context.
OSErr GetDiskFragment (FSSpecPtr fileSpec, long offset, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName);
fileSpec
- A file system specification that identifies the disk-based fragment to load.
offset
- The number of bytes from the beginning of the file's data fork at which the beginning of the fragment is located.
length
- The length (in bytes) of the fragment. Specify the constant
kWholeFork
for this parameter if the fragment extends to the end-of-file of the data fork. Specify a nonzero value for the exact length of the fragment.fragName
- An optional name of the fragment. (This information is used primarily to allow you to identify the fragment during debugging.)
findFlags
- A flag that specifies the operation to perform on the fragment. See the description below for the values you can pass in this parameter.
connID
- On exit, the connection ID that identifies the connection to the fragment. You can pass this ID to other Code Fragment Manager routines.
mainAddr
- On exit, the main address of the fragment. The value returned is specific to the fragment itself. Your application can use this parameter for its
own purposes.errName
- On exit, the name of the fragment that could not successfully be loaded. This parameter is meaningful only if the call to
GetDiskFragment
fails.DESCRIPTION
TheGetDiskFragment
function locates and possibly also loads a disk-based fragment into your application's context. The actions ofGetDiskFragment
depend on the action flag you pass in thefindFlags
parameter. The Code Fragment Manager recognizes these constants:
enum { kLoadLib = 1, /*load fragment*/ kFindLib = 2, /*find fragment*/ kLoadNewCopy = 5 /*load fragment with new copy of data*/ };ThekFindLib
constant specifies that the Code Fragment Manager search for the specified fragment. If the fragment is already prepared and connected to your application,GetDiskFragment
returnsfragNoErr
as its function result and the existing connection ID in theconnID
parameter. If the specified fragment is not found,GetDiskFragment
returns the result codefragLibNotFound
. If the specified fragment is found but could
not be connected to your application,GetDiskFragment
returns the result codefragLibConnErr
.The
kLoadLib
constant specifies that the Code Fragment Manager search for the specified fragment and, if it finds it, load it into memory. If the fragment has already been loaded, it's not loaded again. The Code Fragment Manager uses the data-
instantiation method specified in the fragment's container (which is either global or per-connection instantiation).The
kLoadNewCopy
constant specifies that the Code Fragment Manager load the specified fragment, creating a new copy of any writable data maintained by the fragment. You specifykLoadNewCopy
to obtain one instance per load of the fragment's data and to override the data-instantiation method specified in the container itself. This is most useful for application extensions (for example, drop-in tools).RESULT CODES
fragNoErr 0 No error paramErr -50 Parameter error fragLibNotFound -2804 Specified fragment not found fragHadUnresolveds -2807 Loaded fragment has unacceptable unresolved symbols fragNoMem -2809 Not enough memory for internal bookkeeping fragNoAddrSpace -2810 Not enough memory in user's address
space for sectionfragObjectInitSeqErr -2812 Order error during user initialization function fragImportTooOld -2813 Import library is too old fragImportTooNew -2814 Import library is too new fragInitLoop -2815 Circularity in required initialization order fragLibConnErr
-2817 Error connecting to fragment fragUserInitProcErr -2821 Initialization procedure did not return noErr
SEE ALSO
See "Loading Code Fragments" on page 3-10 for more details on the fragment-
loading process.