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 theFindFolderfunction.
FUNCTION FindFolder (vRefNum: Integer; folderType: OSType; createFolder: Boolean; VAR foundVRefNum: Integer; VAR foundDirID: LongInt): OSErr;
vRefNum- The volume reference number (or the constant
kOnSystemDiskfor 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
kCreateFolderin 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 thefolderTypeparameter.foundDirID- The directory ID number, returned by
FindFolder, for the directory you specify in thefolderTypeparameter.DESCRIPTION
For the folder type on the particular volume (specified, respectively, in thefolderTypeandvRefNumparameters), theFindFolderfunction returns the directory's volume reference number in thefoundVRefNumparameter and its directory ID in thefoundDirIDparameter.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 invRefNumand the volume returned infoundVRefNumwill be the same.Specify a volume reference number (or the constant
kOnSystemDiskfor the startup disk) in thevRefNumparameter.Specify a four-character folder type--or the constant that represents it--in the
folderTypeparameter. Use thekTrashFolderTypeconstant 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 thekWhereToEmptyTrashFolderTypeconstant to locate the parent directory of all logged-on users' Trash subdirectories.Use the constant
kCreateFolderin thecreateFolderparameter to tellFindFolderto 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. TheFindFolderfunction will not create a System Folder directory even if you specify thekCreateFolderconstant in thecreateFolderparameter.The
FindFolderfunction 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 theFindFolderfunction to find the appropriate directories.To determine the availability of the
FindFolderfunction, use theGestaltfunction with the Gestalt selectorgestaltFindFolderAttr. Test the bit field indicated by thegestaltFindFolderPresentconstant in the response parameter. If the bit is set, then theFindFolderfunction 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 theFindFolderfunction are described in "Using the System Folder and Its Related Directories" beginning on page 7-39.