Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC System Software /
Chapter 3 - Code Fragment Manager / Code Fragment Manager Reference
Code Fragment Manager Routines / Loading Fragments


GetDiskFragment

You can use the GetDiskFragment 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
The GetDiskFragment function locates and possibly also loads a disk-based fragment into your application's context. The actions of GetDiskFragment depend on the action flag you pass in the findFlags 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*/
};
The kFindLib constant specifies that the Code Fragment Manager search for the specified fragment. If the fragment is already prepared and connected to your application, GetDiskFragment returns fragNoErr as its function result and the existing connection ID in the connID parameter. If the specified fragment is not found, GetDiskFragment returns the result code fragLibNotFound. If the specified fragment is found but could
not be connected to your application, GetDiskFragment returns the result code fragLibConnErr.

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 specify kLoadNewCopy 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
fragNoErr0No error
paramErr-50Parameter error
fragLibNotFound-2804Specified fragment not found
fragHadUnresolveds-2807Loaded fragment has unacceptable unresolved symbols
fragNoMem-2809Not enough memory for internal bookkeeping
fragNoAddrSpace-2810Not enough memory in user's address
space for section
fragObjectInitSeqErr-2812Order error during user initialization function
fragImportTooOld-2813Import library is too old
fragImportTooNew-2814Import library is too new
fragInitLoop-2815Circularity in required initialization order
fragLibConnErr-2817Error connecting to fragment
fragUserInitProcErr-2821Initialization procedure did not return noErr
SEE ALSO
See "Loading Code Fragments" on page 3-10 for more details on the fragment-
loading process.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice