Important: The information in this document is obsolete and should not be used for new development.
FindFolder
To get the path information to gain access to the system-related directories, use theFindFolder
function.
FUNCTION FindFolder (vRefNum: Integer; folderType: OSType; createFolder: Boolean; VAR foundVRefNum: Integer; VAR foundDirID: LongInt): OSErr;
vRefNum
- The volume reference number (or the constant
kOnSystemDisk
for the startup disk) of the volume on which you want to locate a directory.folderType
- A four-character folder type, or a constant that represents the type, for the directory you want to find. The constants and the four-character folder types they represent are listed here:
CONST kAppleMenuFolderType = 'amnu'; {Apple Menu Items} kControlPanelFolderType = 'ctrl'; {Control Panels} kDesktopFolderType = 'desk'; {Desktop Folder} kExtensionFolderType = 'extn'; {Extensions} kFontsFolderType = 'font'; {Fonts folder} kPreferencesFolderType = 'pref'; {Preferences} kPrintMonitorDocsFolderType = 'prnt'; {PrintMonitor } { Documents} kStartupFolderType = 'strt'; {Startup Items} kSystemFolderType = 'macs'; {System Folder} kTemporaryFolderType = 'temp'; {Temporary Items} kTrashFolderType = 'trsh'; {single-user Trash} kWhereToEmptyTrashFolderType = 'empt'; {shared Trash on net}
createFolder
- Pass the constant
kCreateFolder
in this parameter to create a directory if it does not already exist; otherwise, pass the constantkDontCreateFolder
.foundVRefNum
- The volume reference number, returned by
FindFolder
, for the volume containing the directory you specify in thefolderType
parameter.foundDirID
- The directory ID number, returned by
FindFolder
, for the directory you specify in thefolderType
parameter.DESCRIPTION
For the folder type on the particular volume (specified, respectively, in thefolderType
andvRefNum
parameters), theFindFolder
function returns the directory's volume reference number in thefoundVRefNum
parameter and its directory ID in thefoundDirID
parameter.The specified folder used for a given volume might be located on a different volume in future versions of system software; therefore, do not assume the volume that you
specify invRefNum
and the volume returned infoundVRefNum
will be the same.Specify a volume reference number (or the constant
kOnSystemDisk
for the startup disk) in thevRefNum
parameter.Specify a four-character folder type--or the constant that represents it--in the
folderType
parameter. Use thekTrashFolderType
constant to locate the current user's Trash directory for a given volume--even one located on a file server. On a file server, you can use thekWhereToEmptyTrashFolderType
constant to locate the parent directory of all logged-on users' Trash subdirectories.Use the constant
kCreateFolder
in thecreateFolder
parameter to tellFindFolder
to create a directory if it does not already exist; otherwise, use the constantkDontCreateFolder
. Directories inside the System Folder are created only if the System Folder directory exists. TheFindFolder
function will not create a System Folder directory even if you specify thekCreateFolder
constant in thecreateFolder
parameter.The
FindFolder
function returns a nonzero result code if the folder isn't found,
and it can also return other file system errors reported by the File Manager or
Memory Manager.SPECIAL CONSIDERATIONS
The Finder identifies the subdirectories of the System Folder, and their folder types, in a resource of type'fld#'
located in the System file. Do not modify or rely on the contents of the'fld#'
resource in the System file; use only theFindFolder
function to find the appropriate directories.To determine the availability of the
FindFolder
function, use theGestalt
function with the Gestalt selectorgestaltFindFolderAttr
. Test the bit field indicated by thegestaltFindFolderPresent
constant in the response parameter. If the bit is set, then theFindFolder
function is present.
CONST gestaltFindFolderPresent = 0; {if this bit is set, } { FindFolder is present}RESULT CODES
noErr 0 No error fnfErr -43 Type not found in 'fld#'
resource, or disk doesn't have System Folder support or System Folder in volume header, or disk does not have desktop database support for Desktop Folder--in all cases, folder not founddupFNErr -48 File found instead of folder SEE ALSO
The system-related directories located by theFindFolder
function are described in "Using the System Folder and Its Related Directories" beginning on page 7-39.