Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 1 - Introduction to File Management / File Management Reference
File and Directory Manipulation Routines / Creating File System Specifications


FSMakeFSSpec

You can use the FSMakeFSSpec function to initialize an FSSpec record to particular values for a file or directory.

FUNCTION FSMakeFSSpec (vRefNum: Integer; dirID: LongInt; 
                        fileName: Str255; VAR spec: FSSpec): 
                        OSErr;
vRefNum
A volume specification. This parameter can contain a volume reference number, a working directory reference number, a drive number, or 0 (to specify the default volume).
dirID
A directory specification. This parameter usually specifies the parent directory ID of the target object. If the directory is sufficiently specified by either the vRefNum or fileName parameter, dirID can be set to 0. If you explicitly specify dirID (that is, if it has any value other than 0), and if vRefNum specifies a working directory reference number, dirID overrides the directory ID included in vRefNum. If the fileName parameter contains an empty string, FSMakeFSSpec creates an FSSpec record for a directory specified by either the dirID or vRefNum parameter.
fileName
A full or partial pathname. If fileName specifies a full pathname, FSMakeFSSpec ignores both the vRefNum and dirID parameters. A partial pathname might identify only the final target, or it might include one or more parent directory names. If fileName specifies a partial pathname, then vRefNum, dirID, or both must be valid.
spec
A file system specification to be filled in by FSMakeFSSpec.
DESCRIPTION
The FSMakeFSSpec function fills in the fields of the spec parameter using the information contained in the other three parameters. Call FSMakeFSSpec whenever
you want to create an FSSpec record.

You can pass the input to FSMakeFSSpec in several ways. The chapter "File
Manager" in this book explains how FSMakeFSSpec interprets its input.

If the specified volume is mounted and the specified parent directory exists, but the target file or directory doesn't exist in that location, FSMakeFSSpec fills in the record and then returns fnfErr instead of noErr. The record is valid, but it describes a target that doesn't exist. You can use the record for other operations, such as creating a file with the FSpCreate function.

In addition to the result codes that follow, FSMakeFSSpec can return a number of other File Manager error codes. If your application receives any result code other than noErr or fnfErr, all fields of the resulting FSSpec record are set to 0.

RESULT CODES
noErr0No error
nsvErr-35Volume doesn't exist
fnfErr-43File or directory does not exist (FSSpec is still valid)

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996