Deprecated File Manager Functions

A function identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in OS X v10.4

Allocate

Allocates additional space on a volume to an open file. (Deprecated in OS X v10.4. Use FSAllocateFork instead.)

OSErr Allocate (
   FSIORefNum refNum,
   SInt32 *count
);
Parameters
refNum

The file reference number of the open file.

count

On input, a pointer to the number of additional bytes to allocate to the file. On return, a pointer to the number of bytes actually allocated, rounded up to the nearest multiple of the allocation block size.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The Allocate function adds the specified number of bytes to the file and sets the physical end-of-file to 1 byte beyond the last block allocated. If there isn’t enough empty space on the volume to satisfy the allocation request, Allocate allocates the rest of the space on the volume and returns dskFulErr as its function result.

The Allocate function always attempts to allocate contiguous blocks. If the total number of requested bytes is unavailable, Allocate allocates whatever space, contiguous or not, is available. To force the allocation of the entire requested space as a contiguous piece, call AllocContig instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the Allocate or AllocContig function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

When the File Manager allocates (or deallocates) file blocks automatically, it always adds (or removes) blocks in clumps. The Allocate function allows you to add blocks in allocation blocks, which may be smaller than clumps.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, if there is not enough space left on the volume to allocate the requested number of bytes, the Allocate function does not return the number of bytes actually allocated. Your application should not rely on the value returned in the count parameter.

To determine the remaining space on a volume before calling Allocate, use the functions PBXGetVolInfoSync or PBXGetVolInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

AllocContig

Allocates additional contiguous space on a volume to an open file. (Deprecated in OS X v10.4. Use FSAllocateFork instead.)

OSErr AllocContig (
   FSVolumeRefNum refNum,
   SInt32 *count
);
Parameters
refNum

The file reference number of an open file.

count

On input, a pointer to the number of additional bytes to allocate to the file; on return, a pointer to the number of bytes allocated, rounded up to the nearest multiple of the allocation block size.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The AllocContig function is identical to the Allocate function except that if there isn’t enough contiguous empty space on the volume to satisfy the allocation request, AllocContig does nothing and returns dskFulErr as its function result. If you want to allocate whatever space is available, even when the entire request cannot be filled by the allocation of a contiguous piece, call Allocate instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the AllocContig function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

When the File Manager allocates (or deallocates) file blocks automatically, it always adds (or removes) blocks in clumps. The AllocContig function allows you to add blocks in allocation blocks, which may be smaller than clumps.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, when there is not enough space to allocate the requested number of bytes, AllocContig does not return 0 in the count parameter, so your application cannot rely upon this value.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

CatMove

Moves files or directories from one directory to another on the same volume. (Deprecated in OS X v10.4. Use FSMoveObject instead.)

OSErr CatMove (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param oldName,
   SInt32 newDirID,
   ConstStr255Param newName
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The parent directory ID of the file or directory to move.

oldName

The existing name of the file or directory to move.

newDirID

If the newName parameter is empty, the directory ID of the destination directory; otherwise, the parent directory ID of the destination directory.

newName

The name of the destination directory. If a valid directory name is provided in this parameter, the destination directory’s parent directory is specified in the newDirID parameter. However, you can specify an empty name for newName, in which case newDirID should be set to the directory ID of the destination directory.

It is usually simplest to specify the destination directory by passing its directory ID in the newDirID parameter and by setting newName to an empty name. To specify an empty name, set newName to ':'.

Return Value

A result code. See “File Manager Result Codes.” This function returns permErr if called on a locked file.

Discussion

CatMove is strictly a file catalog operation; it does not actually change the location of the file or directory on the disk.

The CatMove function cannot move a file or directory to another volume (that is, the vRefNum parameter is used in specifying both the source and the destination). Also, you cannot use it to rename files or directories; to rename a file or directory, use HRename.

If you need to move files or directories with named forks other than the data and resource forks, with long Unicode names, or files larger than 2GB, you should use the FSMoveObject function, or one of the corresponding parameter block calls, PBMoveObjectSync and PBMoveObjectAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

DirCreate

Creates a new directory. (Deprecated in OS X v10.4. Use FSCreateDirectoryUnicode instead.)

OSErr DirCreate (
   FSVolumeRefNum vRefNum,
   SInt32 parentDirID,
   ConstStr255Param directoryName,
   SInt32 *createdDirID
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

parentDirID

The directory ID of the parent directory. If the parent directory ID is 0 and the volume specified in the vRefNum parameter is the default volume, the new directory is placed in the default directory of the volume. If the parent directory ID is 0 and the volume specified in the vRefNum parameter is a volume other than the default volume, the new directory is placed in the root directory of the volume. To create a directory at the root of a volume, regardless of whether that volume is the current default volume, pass the constant fsRtDirID(2) in this parameter.

directoryName

The name of the new directory.

createdDirID

On return, a pointer to the directory ID of the new directory. Note that a directory ID, unlike a volume reference number, is a long integer.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The date and time of the new directory’s creation and last modification are set to the current date and time.

To create a directory with a Unicode name, use the function FSCreateDirectoryUnicode , or one of the corresponding parameter block calls, PBCreateDirectoryUnicodeSync and PBCreateDirectoryUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSClose

Closes an open file. (Deprecated in OS X v10.4. Use FSCloseFork instead.)

OSErr FSClose (
   FSIORefNum refNum
);
Parameters
refNum

The file reference number of the open file.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSClose function removes the access path for the specified file and writes the contents of the volume buffer to the volume.

The FSClose function calls the PBFlushFileSync function internally to write the file’s bytes onto the volume. To ensure that the file’s catalog entry is updated, you should call FlushVol after you call FSClose.

Special Considerations

Make sure that you do not call FSClose with a file reference number of a file that has already been closed. Attempting to close the same file twice may result in loss of data on a volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSMakeFSSpec

Creates an FSSpec structure describing a file or directory. (Deprecated in OS X v10.4. Use FSMakeFSRefUnicode instead.)

OSErr FSMakeFSSpec (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   FSSpec *spec
);
Parameters
vRefNum

A volume specification for the volume containing the file or directory. This parameter can contain a volume reference number, a drive number, or 0 to specify the default volume.

dirID

The parent directory ID of the target object. If the directory is sufficiently specified in the fileName parameter, the dirID parameter can be set to 0. If the fileName parameter contains an empty string, FSMakeFSSpec creates an FSSpec structure for the directory specified by the dirID parameter.

fileName

A full or partial pathname. If the fileName parameter 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 pointer to a file system specification to be filled in by FSMakeFSSpec. The FSMakeFSSpec function fills in the fields of the file system specification using the information contained in the other three parameters. If your application receives any result code other than noErr or fnfErr, all fields of the resulting FSSpec structure are set to 0.

The file system specification structure that you pass in this parameter should not share storage space with the input pathname; the name field may be initialized to the empty string before the pathname has been processed. For example, fileName should not refer to the name field of the output file system specification.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

You should call FSMakeFSSpec, or one of the corresponding parameter block functions, PBMakeFSSpecSync and PBMakeFSSpecAsync , whenever you want to create an FSSpec structure. You should not create an FSSpec by filling in the fields of the structure yourself.

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 structure and then returns fnfErr instead of noErr. The structure is valid, but it describes a target that doesn’t exist. You can use the structure for other operations, such as creating a file with the FSpCreate function.

Carbon Porting Notes

Non-Carbon applications can also specify a working directory reference number in the vRefNum parameter. However, because working directories are not supported in Carbon, you cannot specify a working directory reference number if you wish your application to be Carbon-compatible.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpCatMove

Moves a file or directory from one location to another on the same volume. (Deprecated in OS X v10.4. Use FSMoveObject instead.)

OSErr FSpCatMove (
   const FSSpec *source,
   const FSSpec *dest
);
Parameters
source

A pointer to an FSSpec structure specifying the name and location of the file or directory to move. See FSSpec for a description of the FSSpec data type.

dest

A pointer to an FSSpec structure specifying the name and location of the directory into which the source file or directory is to be moved. The directory ID specified in the parID field of this FSSpec is the directory ID of the parent of the directory into which you want to move the source file or directory. The name field of this FSSpec specifies the name of the directory into which you want to move the source file or directory.

If you don’t already know the parent directory ID of the destination directory, it might be easier to use the PBCatMoveSync or PBCatMoveAsync function, which allow you to specify only the directory ID of the destination directory.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSpCatMove function is strictly a file catalog operation; it does not actually change the location of the file or directory on the disk. You cannot use FSpCatMove to move a file or directory to another volume (that is, the vRefNum field in both FSSpec structures in the source and dest parameters must be the same). Also, you cannot use FSpCatMove to rename files or directories; to rename a file or directory, use FSpRename.

If you need to move files or directories with named forks other than the data and resource forks, with long Unicode names, or files larger than 2GB, you should use the FSMoveObject function, or one of the corresponding parameter block calls, PBMoveObjectSync and PBMoveObjectAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpCreate

Creates a new file. (Deprecated in OS X v10.4. Use FSCreateFileUnicode instead.)

OSErr FSpCreate (
   const FSSpec *spec,
   OSType creator,
   OSType fileType,
   ScriptCode scriptTag
);
Parameters
spec

A pointer to an FSSpec structure specifying the file to be created. See FSSpec for a description of the FSSpec data type.

creator

The creator of the new file. See the documentation for the Finder Interface for more information on file creators.

fileType

The file type of the new file. See the documentation for the Finder Interface for more information on file types.

scriptTag

The code of the script system in which the filename is to be displayed. If you have established the name and location of the new file using either the NavAskSaveChanges or NavCustomAskSaveChanges function, specify the script code returned in the reply structure. Otherwise, specify the system script by setting the scriptTag parameter to the value smSystemScript.

For more information about the functions NavAskSaveChanges and NavCustomAskSaveChanges, see Programming With Navigation Services. See the Script Manager Reference for a description of the smSystemScript constant.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSpCreate function creates a new file (both data and resource forks) with the specified type, creator, and script code. The new file is unlocked and empty. The date and time of creation and last modification are set to the current date and time.

Files created using FSpCreate are not automatically opened. If you want to write data to the new file, you must first open the file using one of the file access functions, FSpOpenDF , HOpenDF , PBHOpenDFSync or PBHOpenDFAsync.

The resource fork of the new file exists but is empty. You’ll need to call one of the Resource Manager functions HCreateResFile or FSpCreateResFile to create a resource map in the file before you can open it by calling one of the Resource Manager functions HOpenResFile or FSpOpenResFile).

Before calling this function, you should call the Gestalt function to check that the function is available. If FSpCreate is not available, you can use the function HCreate instead. To create a file with a Unicode filename, use the function FSCreateFileUnicode , or one of the corresponding parameter block calls, PBCreateFileUnicodeSync and PBCreateFileUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpDelete

Deletes a file or directory. (Deprecated in OS X v10.4. Use FSDeleteObject instead.)

OSErr FSpDelete (
   const FSSpec *spec
);
Parameters
spec

A pointer to an FSSpec structure specifying the file or directory to delete. See FSSpec for a description of the FSSpec data type.

Return Value

A result code. See “File Manager Result Codes.” If you attempt to delete an open file or a non-empty directory, FSpDelete returns the result code fBsyErr. FSpDelete also returns the result code fBsyErr if the directory has an open working directory associated with it.

Discussion

If the specified target is a file, both forks of the file are deleted. The file ID reference, if any, is removed. A file must be closed before you can delete it. Similarly, a directory must be empty before you can delete it.

Before calling this function, you should call the Gestalt function to check that the function is available. If FSpDelete is not available, you can use the function HDelete instead.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpDirCreate

Creates a new directory. (Deprecated in OS X v10.4. Use FSCreateDirectoryUnicode instead.)

OSErr FSpDirCreate (
   const FSSpec *spec,
   ScriptCode scriptTag,
   SInt32 *createdDirID
);
Parameters
spec

A pointer to an FSSpec structure specifying the directory to be created.

Note that if the parent directory ID for the directory described by this FSSpec is 0 and the volume specified in this FSSpec is the default volume, the new directory is placed in the default directory of the volume. If the parent directory ID is 0 and the specified volume is a volume other than the default volume, the new directory is placed in the root directory of the volume. To create a directory at the root of a volume, regardless of whether that volume is the current default volume, set the parent directory ID to the constant fsRtDirID(2).

scriptTag

The code of the script system in which the directory name is to be displayed. If you have established the name and location of the new directory using either the NavAskSaveChanges or NavCustomAskSaveChanges function, specify the script code returned in the reply structure. Otherwise, specify the system script by setting the scriptTag parameter to the value smSystemScript.

For more information on the functions NavAskSaveChanges and NavCustomAskSaveChanges, see Programming With Navigation Services. For a description of the smSystemScript constant, see the Script Manager Reference.

createdDirID

On return, a pointer to the directory ID of the directory that was created.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSpDirCreate function sets the date and time of creation and last modification to the current date and time.

Before calling this function, you should call the Gestalt function to check that the function is available. If FSpDirCreate is not available, you can use the function DirCreate instead. To create a directory with a Unicode name, use the function FSCreateDirectoryUnicode , or one of the corresponding parameter block calls, PBCreateDirectoryUnicodeSync and PBCreateDirectoryUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpExchangeFiles

Exchanges the data stored in two files on the same volume. (Deprecated in OS X v10.4. Use FSExchangeObjects instead.)

OSErr FSpExchangeFiles (
   const FSSpec *source,
   const FSSpec *dest
);
Parameters
source

A pointer to an FSSpec for the first file to swap. The contents of this file and its file information are placed in the file specified in the dest parameter. See FSSpec for a description of the FSSpec data type.

dest

A pointer to an FSSpec for the second file to swap. The contents of this file and its file information are placed in the file specified in the source parameter.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSpExchangeFiles function swaps the data in two files by changing the information in the volume’s catalog and, if either of the files are open, in the file control blocks. The following fields in the catalog entries for the files are exchanged:

  • ioFlStBlk

  • ioFlLgLen

  • ioFlPyLen

  • ioFlRStBlk

  • ioFlRLgLen

  • ioFlRPyLen

  • ioFlMdDat

In the file control blocks, the fcbFlNum, fcbDirID, and fcbCName fields are exchanged.

You should use FSpExchangeFiles when updating an existing file, so that the file ID remains valid in case the file is being tracked through its file ID. The FSpExchangeFiles function changes the fields in the catalog entries that record the location of the data and the modification dates. It swaps both the data forks and the resource forks.

The FSpExchangeFiles function works on both open and closed files. If either file is open, FSpExchangeFiles updates any file control blocks associated with the file. Exchanging the contents of two files requires essentially the same access permissions as opening both files for writing.

The files whose data is to be exchanged must both reside on the same volume. If they do not, FSpExchangeFiles returns the result code diffVolErr.

To exchange the contents of files with named forks other than the data and resource forks, or of files larger than 2 GB, use the FSExchangeObjects , PBExchangeObjectsSync , or PBExchangeObjectsAsync function.

Special Considerations

The “compatibility code,” by which FSpExchangeFiles attempted to perform the file exchange itself if it suspected that the underlying filesystem did not have Exchange capability, has been removed in Mac OS 9 and X.

Because other programs may have access paths open to one or both of the files exchanged, your application should have exclusive read/write access permission (fsRdWrPerm) to both files before calling FSpExchangeFiles. Exclusive read/write access to both files will ensure that FSpExchangeFiles doesn't affect another application because it prevents other applications from obtaining write access to one or both of the files exchanged.

FSpExchangeFiles does not respect the file-locked attribute; it will perform the exchange even if one or both of the files are locked. Obtaining exclusive read/write access to both files before calling FSpExchangeFiles ensures that the files are unlocked because locked files cannot be opened with write access.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpGetFInfo

Obtains the Finder information for a file. (Deprecated in OS X v10.4. Use FSGetCatalogInfo instead.)

OSErr FSpGetFInfo (
   const FSSpec *spec,
   FInfo *fndrInfo
);
Parameters
spec

A pointer to an FSSpec structure specifying the file. See FSSpec for a description of the FSSpec data type.

fndrInfo

On return, a pointer to information used by the Finder. The FSpGetFInfo function returns the Finder information from the volume catalog entry for the specified file. The function provides only the original Finder information—the information in the FInfo or DInfo structures, not the information in the FXInfo or DXInfo structures. For a description of the FInfo structure, see the Finder Interface Reference.

Return Value

A result code. If the specified object is a folder, this function returns fnfErr. For other possible return values, see “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpOpenDF

Opens the data fork of a file. (Deprecated in OS X v10.4. Use FSOpenFork instead.)

OSErr FSpOpenDF (
   const FSSpec *spec,
   SInt8 permission,
   FSIORefNum *refNum
);
Parameters
spec

A pointer to an FSSpec structure specifying the file whose data fork is to be opened. See FSSpec for a description of the FSSpec data type.

permission

A constant indicating the type of access with which to open the file’s data fork. In most cases, you can simply set the permission parameter to fsCurPerm. Some applications request fsRdWrPerm, to ensure that they can both read from and write to a file. For a description of the types of access that you can request, see “File Access Permission Constants.”

refNum

On return, a pointer to the file reference number for accessing the open data fork.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Before calling this function, you should call the Gestalt function to check that the function is available. If FSpOpenDF is not available, you can use the function HOpenDF instead.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync. If you try to open a fork larger than 2GB with the FSpOpenDF function, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpOpenRF

Opens the resource fork of a file. (Deprecated in OS X v10.4. Use FSOpenFork instead.)

OSErr FSpOpenRF (
   const FSSpec *spec,
   SInt8 permission,
   FSIORefNum *refNum
);
Parameters
spec

A pointer to an FSSpec structure specifying the file whose resource fork is to be opened. See FSSpec for a description of the FSSpec data type.

permission

A constant indicating the type of access with which to open the file’s resource fork. For a description of the types of access you can request, see “File Access Permission Constants.”

refNum

On return, a pointer to the file reference number for accessing the open resource fork.

Return Value

A result code. See “File Manager Result Codes.” On some file systems, FSpOpenRF will return the error eofErr if you try to open the resource fork of a file for which no resource fork exists with read-only access.

Discussion

Before calling this function, you should call the Gestalt function to check that the function is available. If FSpOpenRF is not available, you can use the function HOpenRF instead.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the FSpOpenRF function, you will receive an error message.

Special Considerations

Generally, your application should use Resource Manager functions rather than File Manager functions to access a file’s resource fork. The FSpOpenRF function does not read the resource map into memory and is generally useful only for applications (such as utilities that copy files) that need block-level access to a resource fork.

You should not use the resource fork of a file to hold non-resource data. Many parts of the system software assume that a resource fork always contains resource data.

Because there is no support for locking and unlocking file ranges on local disks in OS X, regardless of whether File Sharing is enabled, you cannot open more than one path to a resource fork with read/write permission. If you try to open a more than one path to a file's resource fork with fsRdWrShPerm permission, only the first attempt will succeed. Subsequent attempts will return an invalid reference number and the ResError function will return the error opWrErr.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpRename

Renames a file or directory. (Deprecated in OS X v10.4. Use FSRenameUnicode instead.)

OSErr FSpRename (
   const FSSpec *spec,
   ConstStr255Param newName
);
Parameters
spec

A pointer to an FSSpec structure specifying the file or directory to rename. See FSSpec for a description of the FSSpec data type.

newName

The new name of the file or directory.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If a file ID reference for the specified file exists, it remains with the renamed file.

If you want to change the name of a new copy of an existing file, you should use the FSpExchangeFiles function instead. To rename a file or directory using a long Unicode name, use the FSRenameUnicode function or one of the corresponding parameter block calls, PBRenameUnicodeSync and PBRenameUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpRstFLock

Unlocks a file or directory. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr FSpRstFLock (
   const FSSpec *spec
);
Parameters
spec

A pointer to an FSSpec structure specifying the file to unlock. See FSSpec for a description of the FSSpec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use FSpRstFLock to unlock a directory. Otherwise, you can only use this function to unlock a file.

You can lock a file or directory with the FSpSetFLock , HSetFLock , PBHSetFLockSync , and PBHSetFLockAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpSetFInfo

Sets the Finder information about a file. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr FSpSetFInfo (
   const FSSpec *spec,
   const FInfo *fndrInfo
);
Parameters
spec

A pointer to an FSSpec structure specifying the file for which to set the Finder information. See FSSpec for a description of the FSSpec data type.

fndrInfo

A pointer to the new Finder information. For a description of the FInfo data type, see the Finder Interface Reference.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSpSetFInfo function changes the Finder information in the volume catalog entry for the specified file. FSpSetFInfo allows you to set only the original Finder information—the information in the FInfo or DInfo structures, not the information in the FXInfo or DXInfo structures.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpSetFLock

Locks a file or directory. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr FSpSetFLock (
   const FSSpec *spec
);
Parameters
spec

A pointer to an FSSpec structure specifying the file or directory to lock. See FSSpec for a description of the FSSpec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the PBHGetVolParmsSync or PBHGetVolParmsAsync functions indicate that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use FSpSetFLock to lock a directory. Otherwise, you can only use this function to lock a file.

After you lock a file, all new access paths to that file are read-only. This function has no effect on existing access paths.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSRead

Reads any number of bytes from an open file. (Deprecated in OS X v10.4. Use FSReadFork instead.)

OSErr FSRead (
   FSIORefNum refNum,
   SInt32 *count,
   void *buffPtr
);
Parameters
refNum

The file reference number of the open file from which to read.

count

On input, a pointer to the number of bytes to read; on output, a pointer to the number of bytes actually read.

buffPtr

A pointer to the data buffer into which the data will be read. This buffer is allocated by your application and must be at least as large as the count parameter.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Because the read operation begins at the current mark, you might want to set the mark first by calling the SetFPos function. If you try to read past the logical end-of-file, FSRead reads in all the data up to the end-of-file, moves the mark to the end-of-file, and returns eofErr as its function result. Otherwise, FSRead moves the file mark to the byte following the last byte read and returns noErr.

The low-level functions PBReadSync and PBReadAsync let you set the mark without having to call SetFPos. Furthermore, if you want to read data in newline mode, you must use PBReadSync or PBReadAsync instead of FSRead.

If you wish to read from named forks other than the data or resource forks, or from files larger than 2GB, you must use the FSReadFork function, or one of its corresponding parameter block calls, PBReadForkSync and PBReadForkAsync. If you attempt to use FSRead to read from a file larger than 2GB, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

FSWrite

Writes any number of bytes to an open file. (Deprecated in OS X v10.4. Use FSWriteFork instead.)

OSErr FSWrite (
   FSIORefNum refNum,
   SInt32 *count,
   const void *buffPtr
);
Parameters
refNum

The file reference number of the open file to which to write.

count

On input, a pointer to the number of bytes to write to the file. Passing 0 in this parameter will return a paramErr error.

On output, a pointer to the number of bytes actually written.

buffPtr

A pointer to the data buffer containing the data to write.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSWrite function takes the specified number of bytes from the data buffer and attempts to write them to the file. Because the write operation begins at the current mark, you might want to set the mark first by calling the SetFPos function.

If the write operation completes successfully, FSWrite moves the file mark to the byte following the last byte written and returns noErr. If you try to write past the logical end-of-file, FSWrite moves the logical end-of-file. If you try to write past the physical end-of-file, FSWrite adds one or more clumps to the file and moves the physical end-of-file accordingly.

The low-level functions PBWriteSync and PBWriteAsync let you set the mark without having to call SetFPos.

If you wish to write to named forks other than the data or resource forks, or grow files larger than 2GB, you must use the FSWriteFork function, or one of its corresponding parameter block calls, PBWriteForkSync and PBWriteForkAsync. If you attempt to use FSWrite to write to a file larger than 2GB, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

GetEOF

Determines the current logical size of an open file. (Deprecated in OS X v10.4. Use FSGetForkSize instead.)

OSErr GetEOF (
   FSIORefNum refNum,
   SInt32 *logEOF
);
Parameters
refNum

The file reference number of an open file.

logEOF

On return, a pointer to the logical size (the logical end-of-file) of the given file.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

To determine the size of a named fork other than the data or resource forks, or of a fork larger than 2 GB, use the FSGetForkSize function, or one of the corresponding parameter block functions, PBGetForkSizeSync and PBGetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

GetFPos

Returns the current position of the file mark. (Deprecated in OS X v10.4. Use FSGetForkPosition instead.)

OSErr GetFPos (
   FSIORefNum refNum,
   SInt32 *filePos
);
Parameters
refNum

The file reference number of an open file.

filePos

On return, a pointer to the current position of the mark. The position value is zero-based; that is, the value of filePos is 0 if the file mark is positioned at the beginning of the file.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Because the read and write operations performed by the functions FSRead and FSWrite begin at the current mark, you should call GetFPos, or one of the parameter block functions, PBGetFPosSync and PBGetFPosAsync , to determine the current position of the file mark before reading from or writing to the file.

To determine the current position of a named fork, or of a fork larger than 2GB, use the FSGetForkPosition function, or one of the corresponding parameter block calls, PBGetForkPositionSync and PBGetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

GetVRefNum

Gets a volume reference number from a file reference number. (Deprecated in OS X v10.4. Use FSGetCatalogInfo instead.)

OSErr GetVRefNum (
   FSIORefNum fileRefNum,
   FSVolumeRefNum *vRefNum
);
Parameters
fileRefNum

The file reference number of an open file.

vRefNum

On return, a pointer to the volume reference number of the volume containing the file specified in the refNum parameter.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you also want to determine the directory ID of the specified file’s parent directory, call the PBGetFCBInfoSync or PBGetFCBInfoAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HCreate

Creates a new file. (Deprecated in OS X v10.4. Use FSCreateFileUnicode instead.)

OSErr HCreate (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   OSType creator,
   OSType fileType
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The directory ID of the directory in which to create the new file.

fileName

The name of the new file. This can be a full or partial pathname.

You should not allow users to give files names that begin with a period (.). This ensures that files can be successfully opened by applications calling HOpen instead of HOpenDF.

creator

The creator of the new file. For more information on a file’s creator, see the Finder Interface documentation.

fileType

The file type of the new file. For more information on a file’s type, see the Finder Interface documentation.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The HCreate function creates a new file (both data and resource forks) with the specified name, creator, and file type. The new file is unlocked and empty. The date and time of its creation and last modification are set to the current date and time.

Files created using HCreate are not automatically opened. If you want to write data to the new file, you must first open the file using a file access function.

The resource fork of the new file exists but is empty. You’ll need to call one of the Resource Manager functions HCreateResFile or FSpCreateResFile to create a resource map in the file before you can open it (by calling one of the Resource Manager functions HOpenResFile or FSpOpenResFile).

To create a file with a Unicode filename, use the function FSCreateFileUnicode , or one of the corresponding parameter block calls, PBCreateFileUnicodeSync and PBCreateFileUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HDelete

Deletes a file or directory. (Deprecated in OS X v10.4. Use FSDeleteObject instead.)

OSErr HDelete (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The directory ID of the parent directory of the file or directory to delete.

fileName

The name of the file or directory to delete. This can be a full or partial pathname.

Return Value

A result code. See “File Manager Result Codes.” If you attempt to delete an open file or a non-empty directory, HDelete returns the result code fBsyErr. HDelete also returns the result code fBsyErr if the directory has an open working directory associated with it.

Discussion

If the specified target is a file, both the data and the resource fork of the file are deleted. In addition, if a file ID reference for the specified file exists, that reference is removed. A file must be closed before you can delete it. Similarly, you cannot delete a directory unless it’s empty.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HGetFInfo

Obtains the Finder information for a file. (Deprecated in OS X v10.4. Use FSGetCatalogInfo instead.)

OSErr HGetFInfo (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   FInfo *fndrInfo
);
Parameters
vRefNum

The volume reference number, drive number, or 0 for the default volume.

dirID

The parent directory ID of the file.

fileName

The name of the file.

fndrInfo

On return, a pointer to the Finder information stored in the specified volume’s catalog. The function returns only the original Finder information—that contained in an FInfo structure, not that in an FXInfo structure.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HGetVol

Determines the current default volume and default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr HGetVol (
   StringPtr volName,
   FSVolumeRefNum *vRefNum,
   SInt32 *dirID
);
Parameters
volName

On return, a pointer to the name of the default volume. If you do not want the name of the default volume returned, set this parameter to NULL.

vRefNum

On return, a pointer to the volume reference number of the default volume.

dirID

On return, a pointer to the directory ID of the default directory.

Return Value

A result code. See “File Manager Result Codes.”

Version Notes

When CarbonLib is not present, the HGetVol function returns a working directory reference number in the vRefNum parameter if the previous call to HSetVol (or one of the corresponding parameter block calls) passed in a working directory reference number.

Carbon Porting Notes

Carbon applications should use HGetVol and HSetVol to get and set the default directory. the functions GetVol and SetVol, as well as working directories, are no longer supported.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HOpen

Opens the data fork of a file. (Deprecated in OS X v10.4. Use FSOpenFork instead.)

OSErr HOpen (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   SInt8 permission,
   FSIORefNum *refNum
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The directory ID of the file’s parent directory.

fileName

The name of the file.

permission

A constant specifying the type of access with which to open the file’s data fork. For a description of the types of access you can request, see “File Access Permission Constants.”

refNum

On return, a pointer to the file reference number for accessing the open fork.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you use HOpen to try to open a file whose name begins with a period, you might mistakenly open a driver instead; subsequent attempts to write data might corrupt data on the target device. To avoid these problems, you should always use HOpenDF instead of HOpen.

Special Considerations

If you use HOpen to try to open a file whose name begins with a period, you might mistakenly open a driver instead; subsequent attempts to write data might corrupt data on the target device. To avoid these problems, you should always use HOpenDF instead of HOpen.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HOpenDF

Opens the data fork of a file. (Deprecated in OS X v10.4. Use FSOpenFork instead.)

OSErr HOpenDF (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   SInt8 permission,
   FSIORefNum *refNum
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The directory ID of the file’s parent directory.

fileName

The name of the file.

permission

A constant specifying the type of access with which to open the file’s data fork. For a description of the types of access which you can request, see “File Access Permission Constants.”

refNum

On return, a pointer to the file reference number for accessing the open data fork.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of the corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the HOpenDF function, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HOpenRF

Opens the resource fork of a file. (Deprecated in OS X v10.4. Use FSOpenFork instead.)

OSErr HOpenRF (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   SInt8 permission,
   FSIORefNum *refNum
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The directory ID for the file’s parent directory.

fileName

The name of the file.

permission

A constant specifying the type of access with which to open the file’s resource fork. For a description of the types of access you can request, see “File Access Permission Constants.”

refNum

On return, a pointer to the file reference number for accessing the open resource fork.

Return Value

A result code. See “File Manager Result Codes.” If you try to open the resource fork of a file for which no resource fork exists with read-only access, HOpenRF returns the error eofErr.

Discussion

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the HOpenRF function, you will receive an error message.

Special Considerations

Generally, your application should use Resource Manager functions rather than File Manager functions to access a file’s resource fork. The HOpenRF function does not read the resource map into memory and is generally useful only for applications (such as utilities that copy files) that need block-level access to a resource fork.

You should not use the resource fork of a file to hold non-resource data. Many parts of the system software assume that a resource fork always contains resource data.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HRename

Renames a file, directory, or volume. (Deprecated in OS X v10.4. Use FSRenameUnicode instead.)

OSErr HRename (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param oldName,
   ConstStr255Param newName
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

A directory ID.

oldName

An existing filename, directory name, or volume name.

newName

The new filename, directory name, or volume name.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Given the name of a file or directory in the oldName parameter, HRename changes it to the name in the newName parameter. Given a volume name in the oldName parameter or a volume reference number in the vRefNum parameter, HRename changes the name of the volume to the name in newName. Access paths currently in use aren’t affected by this function.

If a file ID reference exists for a file you are renaming, the file ID remains with the renamed file.

To rename a file or directory using a long Unicode name, use the FSRenameUnicode function or one of the corresponding parameter block calls, PBRenameUnicodeSync and PBRenameUnicodeAsync.

Special Considerations

You cannot use HRename to change the directory in which a file resides. To move a file or directory, use the FSpCatMove, PBCatMoveSync, or PBCatMoveAsync functions.

If you’re renaming a volume, make sure that both names end with a colon.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HRstFLock

Unlocks a file or directory. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr HRstFLock (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The parent directory ID of the file or directory to unlock.

fileName

The name of the file or directory.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use HRstFLock to unlock a directory. Otherwise, you can only use this function to unlock a file.

You can lock a file or directory with the FSpSetFLock , HSetFLock , PBHSetFLockSync , and PBHSetFLockAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HSetFInfo

Sets the Finder information for a file. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr HSetFInfo (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName,
   const FInfo *fndrInfo
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The parent directory ID of the file.

fileName

The name of the file.

fndrInfo

A pointer to the new Finder information. The function changes the Finder information stored in the volume’s catalog. HSetFInfo changes only the original Finder information—that contained in an FInfo structure, not that contained in an FXInfo structure. For a description of the FInfo data type, see the Finder Interface Reference.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HSetFLock

Locks a file or directory. (Deprecated in OS X v10.4. Use FSSetCatalogInfo instead.)

OSErr HSetFLock (
   FSVolumeRefNum vRefNum,
   SInt32 dirID,
   ConstStr255Param fileName
);
Parameters
vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

The parent directory ID of the file or directory to lock.

fileName

The name of the file or directory.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use HSetFLock to lock a directory. Otherwise, you can only use this function to lock a file.

After you lock a file, all new access paths to that file are read-only. This function has no effect on existing access paths.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

HSetVol

Sets the default volume and the default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr HSetVol (
   ConstStr63Param volName,
   FSVolumeRefNum vRefNum,
   SInt32 dirID
);
Parameters
volName

The name of a mounted volume or the partial pathname of a directory. This parameter can be NULL.

vRefNum

A volume reference number, drive number, or 0 for the default volume.

dirID

A directory ID.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The HSetVol function lets you specify the default directory by volume reference number or by directory ID.

Both the default volume and the default directory are used in calls made with no volume name, a volume reference number of 0, and a directory ID of 0.

Special Considerations

Use of the HSetVol function is discouraged if your application may execute in system software versions prior to version 7.0. Because the specified directory might not itself be a working directory, HSetVol records the default volume and directory separately, using the volume reference number of the volume and the actual directory ID of the specified directory. Subsequent calls to GetVol (or PBGetVolSync or PBGetVolAsync) return only the volume reference number, which will cause that volume’s root directory (rather than the default directory, as expected) to be accessed.

Carbon Porting Notes

Carbon applications should use HGetVol and HSetVol to get and set the default directory. the functions GetVol and SetVol, as well as working directories, are no longer supported.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBAllocateAsync

Allocates additional space on a volume to an open file. (Deprecated in OS X v10.4. Use PBAllocateForkAsync instead.)

OSErr PBAllocateAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the file to which to allocate additional blocks.

ioReqCount

On input, the number of bytes to allocate.

ioActCount

On output, the number of bytes actually allocated, rounded up to the nearest multiple of the allocation block size.

The PBAllocateAsync function adds ioReqCount bytes to the specified file and sets the physical end-of-file to 1 byte beyond the last block allocated. If there isn’t enough empty space on the volume to satisfy the allocation request, PBAllocateAsync allocates the rest of the space on the volume and returns dskFulErr as its function result.

If the total number of requested bytes is unavailable, PBAllocateAsync allocates whatever space, contiguous or not, is available. To force the allocation of the entire requested space as a contiguous piece, call PBAllocContigAsync instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the PBAllocateAsync function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, if there is not enough space left on the volume to allocate the requested number of bytes, the PBAllocateAsync function does not return the number of bytes actually allocated in the ioActCount field.

To determine the remaining space on a volume before calling PBAllocateAsync, use the functions PBXGetVolInfoSync or PBXGetVolInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBAllocateSync

Allocates additional space on a volume to an open file. (Deprecated in OS X v10.4. Use PBAllocateForkSync instead.)

OSErr PBAllocateSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for the file to which to allocate additional blocks.

ioReqCount

On input, the number of bytes to allocate.

ioActCount

On output, the number of bytes actually allocated, rounded up to the nearest multiple of the allocation block size.

The PBAllocateSync function adds ioReqCount bytes to the specified file and sets the physical end-of-file to 1 byte beyond the last block allocated. If there isn’t enough empty space on the volume to satisfy the allocation request, PBAllocateSync allocates the rest of the space on the volume and returns dskFulErr as its function result.

If the total number of requested bytes is unavailable, PBAllocateSync allocates whatever space, contiguous or not, is available. To force the allocation of the entire requested space as a contiguous piece, call PBAllocContigSync instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the PBAllocateSync function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, if there is not enough space left on the volume to allocate the requested number of bytes, the PBAllocateSync function does not return the number of bytes actually allocated in the ioActCount field.

To determine the remaining space on a volume before calling PBAllocateSync, use the functions PBXGetVolInfoSync or PBXGetVolInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBAllocContigAsync

Allocates additional contiguous space on a volume to an open file. (Deprecated in OS X v10.4. Use PBAllocateForkAsync instead.)

OSErr PBAllocContigAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the open file.

ioReqCount

On input, the number of bytes to allocate.

ioActCount

On output, the number of bytes actually allocated, rounded up to the nearest multiple of the allocation block size.

The PBAllocContigAsync function is identical to the PBAllocateAsync function except that if there isn’t enough contiguous empty space on the volume to satisfy the allocation request, PBAllocContigAsync does nothing and returns dskFulErr as its function result. If you want to allocate whatever space is available, even when the entire request cannot be filled by the allocation of a contiguous piece, call PBAllocateAsync instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the PBAllocContigAsync function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, when there is not enough space to allocate the requested number of bytes, PBAllocContigAsync does not return 0 in the ioActCount field, so your application cannot rely upon this value.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBAllocContigSync

Allocates additional contiguous space on a volume to an open file. (Deprecated in OS X v10.4. Use PBAllocateForkSync instead.)

OSErr PBAllocContigSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for the open file.

ioReqCount

On input, the number of bytes to allocate.

ioActCount

On output, the number of bytes actually allocated, rounded up to the nearest multiple of the allocation block size.

The PBAllocContigSync function is identical to the PBAllocateSync function except that if there isn’t enough contiguous empty space on the volume to satisfy the allocation request, PBAllocContigSync does nothing and returns dskFulErr as its function result. If you want to allocate whatever space is available, even when the entire request cannot be filled by the allocation of a contiguous piece, call PBAllocateSync instead.

The File Manager automatically allocates file blocks if you move the logical end-of-file past the physical end-of-file, and it automatically deallocates unneeded blocks from a file if you move the logical end-of-file to a position more than one allocation block before the current physical end-of-file. Consequently, you do not in general need to be concerned with allocating or deallocating file blocks. However, you can improve file block contiguity if you use the PBAllocContigSync function to preallocate file blocks. This is most useful if you know in advance how big a file is likely to become.

The space allocated with this function is not permanently assigned to the file until the file’s logical end-of-file is changed to include the allocated space. When a file (or volume) is closed, the space beyond the file’s logical EOF is made available for other purposes, even if previously allocated to the file with a call to this function. You can change the end-of-file by setting it with the SetEOF function, or by writing data to the file with the FSWrite function.

This function is not supported by all file systems; for example, volumes mounted by the AppleShare file system do not support this function. To allocate space for a file on any volume, use the SetEOF function, or one of the related parameter block calls, PBSetEOFSync and PBSetEOFAsync.

To allocate space for a file beyond 2 GB, use the FSAllocateFork function, or one of the corresponding parameter block functions, PBAllocateForkSync and PBAllocateForkAsync.

Special Considerations

In Mac OS 7.5.5 through Mac OS 8.5, when there is not enough space to allocate the requested number of bytes, PBAllocContigSync does not return 0 in the ioActCount field, so your application cannot rely upon this value.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCatMoveAsync

Moves files or directories from one directory to another on the same volume. (Deprecated in OS X v10.4. Use PBMoveObjectAsync instead.)

OSErr PBCatMoveAsync (
   CMovePBPtr paramBlock
);
Parameters
paramBlock

A pointer to a catalog move parameter block. See CMovePBRec for a description of the CMovePBRec data type.

Return Value

A result code. See “File Manager Result Codes.” This function returns permErr if called on a locked file.

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the file or directory to move.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioNewName

On input, a pointer to the name of the destination directory. Pass NULL in this field if you wish to specify the destination directory by its directory ID.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, this is the parent directory ID of the directory into which the file or directory is to be moved. It is usually simplest to specify the destination directory by passing its directory ID in the ioNewDirID field and by setting ioNewName to NULL.

ioDirID

On input, the parent directory ID of the file or directory to move.

PBCatMoveAsync is strictly a file catalog operation; it does not actually change the location of the file or directory on the disk. If a file ID reference exists for the file, the file ID reference remains with the moved file.

The PBCatMoveAsync function cannot move a file or directory to another volume (that is, the value in the ioVRefNum field is used in specifying both the source and the destination). Also, you cannot use it to rename files or directories; to rename a file or directory, use FSpRename , PBHRenameSync , or PBHRenameAsync .

If you need to move files or directories with named forks other than the data and resource forks, with long Unicode names, or files larger than 2GB, you should use the FSMoveObject function, or one of the corresponding parameter block calls, PBMoveObjectSync and PBMoveObjectAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCatMoveSync

Moves files or directories from one directory to another on the same volume. (Deprecated in OS X v10.4. Use PBMoveObjectSync instead.)

OSErr PBCatMoveSync (
   CMovePBPtr paramBlock
);
Parameters
paramBlock

A pointer to a catalog move parameter block. See CMovePBRec for a description of the CMovePBRec data type.

Return Value

A result code. See “File Manager Result Codes.” This function returns permErr if called on a locked file.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file or directory to move.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioNewName

On input, a pointer to the name of the destination directory. Pass NULL in this field if you wish to specify the destination directory by its directory ID.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, this is the parent directory ID of the destination directory. It is usually simplest to specify the destination directory by passing its directory ID in the ioNewDirID field and by setting ioNewName to NULL.

ioDirID

On input, the parent directory ID of the file or directory to move.

PBCatMoveSync is strictly a file catalog operation; it does not actually change the location of the file or directory on the disk. If a file ID reference exists for the file, the file ID reference remains with the moved file.

The PBCatMoveSync function cannot move a file or directory to another volume (that is, the value in the ioVRefNum field is used in specifying both the source and the destination). Also, you cannot use it to rename files or directories; to rename a file or directory, use FSpRename , PBHRenameSync , or PBHRenameAsync.

If you need to move files or directories with named forks other than the data and resource forks, with long Unicode names, or files larger than 2GB, you should use the FSMoveObject function, or one of the corresponding parameter block calls, PBMoveObjectSync and PBMoveObjectAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCatSearchAsync

Searches a volume’s catalog file using a set of search criteria that you specify. (Deprecated in OS X v10.4. Use PBCatalogSearchAsync instead.)

OSErr PBCatSearchAsync (
   CSParamPtr paramBlock
);
Parameters
paramBlock

A pointer to a CSParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. When PBCatSearchAsync has searched the entire volume, it returns eofErr. If it exits because it either spends the maximum time allowed in the ioSearchTime field or finds the maximum number of matches allowed in the ioReqMatchCount field, it returns noErr.

ioNamePtr

On input, a pointer to the name of the volume to search.

ioVRefNum

On input, a volume reference number or drive number for the volume to search; or 0 for the default volume.

ioMatchPtr

On input, a pointer to an array of FSSpec structure to hold the matches found by this function. On return, the FSSpec structures in this array identify the files and directories that match the criteria.

ioReqMatchCount

On input, the maximum number of matches to return.

ioActMatchCount

On output, the actual number of matches returned.

ioSearchBits

On input, a bitmap specifying the fields in the criteria structures to match against. See “Catalog Search Masks” for a description of the bits in this field.

ioSearchInfo1

On input, a pointer to a CInfoPBRec union containing search information. For values that match by mask and value (Finder information, for example), set the bits in the structure passed in ioSearchInfo2, and set the matching value in this structure. For values that match against a range (such as dates), set the lower bounds for the range in this structure.

ioSearchInfo2

On input, a pointer to a CInfoPBRec union containing search information. For values that match by mask and value (Finder information, for example), set the bits in this structure, and set the matching value in the structure passed in the ioSearchInfo1 field. For values that match against a range (such as dates), set the upper bounds for the range in this structure.

ioSearchTime

On input, the maximum allowed search time. If you pass 0 in this field, no time limit is set.

ioCatPosition

The current catalog position, specified as a CatPositionRec structure. You can use this field, along with the ioSearchTime field, to search a volume in segments. To search a volume in segments, set a time limit for the search in the ioSearchTime field and set the initialize field of the CatPositionRec structure to the location for the start of the search (0 if you wish to start searching at the beginning of the volume). On return, the catalog position will be updated. You can then pass this updated CatPositionRec structure to the next call to PBCatSearchSync to continue searching at the place where you left off.

ioOptBuffer

On input, a pointer to an optional read buffer.

ioOptBufSize

On input, the length of the optional read buffer.

If the catalog file changes between two timed calls to PBCatSearchAsync (that is, when you are using ioSearchTime and ioCatPosition to search a volume in segments and the catalog file changes between searches), PBCatSearchAsync returns a result code of catChangedErr and no matches. Depending on what has changed on the volume, ioCatPosition might be invalid, most likely by a few entries in one direction or another. You can continue the search, but you risk either skipping some entries or reading some twice.

Special Considerations

Not all volumes support the PBCatSearchAsync function. Before you call PBCatSearchAsync to search a particular volume, you should call the PBHGetVolParmsAsync function to determine whether that volume supports PBCatSearchAsync. If the bHasCatSearch bit is set in the vMAttrib field, then the volume supports PBCatSearchAsync.

Even though AFP volumes support PBCatSearchSync, they do not support all of its features that are available on local volumes. These restrictions apply to AFP volumes:

  • AFP volumes do not use the ioSearchTime field. Current versions of the AppleShare server software search for 1 second or until 4 matches are found. The AppleShare workstation software keeps requesting the appropriate number of matches until the server returns either the number specified in the ioReqMatchCount field or an error.

  • AFP volumes do not support both logical and physical fork lengths. If you request a search using the length of a fork, the actual minimum length used is the smallest of the values in the logical and physical fields of the ioSearchInfo1 structure and the actual maximum length used is the largest of the values in the logical and physical fields of the ioSearchInfo2 structure.

  • The fsSBNegate bit of the ioSearchBits field is ignored during searches of remote volumes that support AFP version 2.1.

  • If the AFP server returns afpCatalogChanged, the catalog position structure returned to your application (in the ioCatPosition field) is the same one you passed to PBCatSearchAsync. You should clear the initialize field of that structure to restart the search from the beginning.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCatSearchSync

Searches a volume’s catalog file using a set of search criteria that you specify. (Deprecated in OS X v10.4. Use PBCatalogSearchSync instead.)

OSErr PBCatSearchSync (
   CSParamPtr paramBlock
);
Parameters
paramBlock

A pointer to a CSParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” When PBCatSearchSync has searched the entire volume, it returns eofErr. If it exits because it either spends the maximum time allowed in the ioSearchTime field or finds the maximum number of matches allowed in the ioReqMatchCount field, it returns noErr.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the volume to search.

ioVRefNum

On input, a volume reference number or drive number for the volume to search; or 0 for the default volume.

ioMatchPtr

On input, a pointer to an array of FSSpec structure to hold the matches found by this function. On return, the FSSpec structures in this array identify the files and directories that match the criteria.

ioReqMatchCount

On input, the maximum number of matches to return.

ioActMatchCount

On output, the actual number of matches returned.

ioSearchBits

On input, a bitmap specifying the fields in the criteria structures to match against. See “Catalog Search Masks” for a description of the bits in this field.

ioSearchInfo1

On input, a pointer to a CInfoPBRec union containing search information. For values that match by mask and value (Finder information, for example), set the bits in the structure passed in ioSearchInfo2, and set the matching value in this structure. For values that match against a range (such as dates), set the lower bounds for the range in this structure.

ioSearchInfo2

On input, a pointer to a CInfoPBRec union containing search information. For values that match by mask and value (Finder information, for example), set the bits in this structure, and set the matching value in the structure passed in the ioSearchInfo1 field. For values that match against a range (such as dates), set the upper bounds for the range in this structure.

ioSearchTime

On input, the maximum allowed search time. If you pass 0 in this field, no time limit is set.

ioCatPosition

The current catalog position, specified as a CatPositionRec structure. You can use this field, along with the ioSearchTime field, to search a volume in segments. To search a volume in segments, set a time limit for the search in the ioSearchTime field and set the initialize field of the CatPositionRec structure to the location for the start of the search (0 if you wish to start searching at the beginning of the volume). On return, the catalog position will be updated. You can then pass this updated CatPositionRec structure to the next call to PBCatSearchSync to continue searching at the place where you left off.

ioOptBuffer

On input, a pointer to an optional read buffer.

ioOptBufSize

On input, the length of the optional read buffer.

If the catalog file changes between two timed calls to PBCatSearchSync (that is, when you are using ioSearchTime and ioCatPosition to search a volume in segments and the catalog file changes between searches), PBCatSearchSync returns a result code of catChangedErr and no matches. Depending on what has changed on the volume, ioCatPosition might be invalid, most likely by a few entries in one direction or another. You can continue the search, but you risk either skipping some entries or reading some twice.

Special Considerations

Not all volumes support the PBCatSearchSync function. Before you call PBCatSearchSync to search a particular volume, you should call the PBHGetVolParmsSync function to determine whether that volume supports PBCatSearchSync.If the bHasCatSearch bit is set in the vMAttrib field, then the volume supports PBCatSearchSync.

Even though AFP volumes support PBCatSearchSync, they do not support all of its features that are available on local volumes. These restrictions apply to AFP volumes:

  • AFP volumes do not use the ioSearchTime field. Current versions of the AppleShare server software search for 1 second or until 4 matches are found. The AppleShare workstation software keeps requesting the appropriate number of matches until the server returns either the number specified in the ioReqMatchCount field or an error.

  • AFP volumes do not support both logical and physical fork lengths. If you request a search using the length of a fork, the actual minimum length used is the smallest of the values in the logical and physical fields of the ioSearchInfo1 structure and the actual maximum length used is the largest of the values in the logical and physical fields of the ioSearchInfo2 structure.

  • The fsSBNegate bit of the ioSearchBits field is ignored during searches of remote volumes that support AFP version 2.1.

  • If the AFP server returns afpCatalogChanged, the catalog position structure returned to your application (in the ioCatPosition field) is the same one you passed to PBCatSearchSync. You should clear the initialize field of that structure to restart the search from the beginning.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDirCreateAsync

Creates a new directory. (Deprecated in OS X v10.4. Use PBCreateDirectoryUnicodeAsync instead.)

OSErr PBDirCreateAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name for the new directory.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID. If the parent directory ID is 0 and the volume specified in the ioVRefNum field is the default volume, the new directory is placed in the default directory of the volume. If the parent directory ID is 0 and the volume specified in the ioVRefNum field is a volume other than the default volume, the new directory is placed in the root directory of the volume. To create a directory at the root of a volume, regardless of whether that volume is the current default volume, pass the constant fsRtDirID (2) in this field. On output, the directory ID of the new directory. Note that a directory ID, unlike a volume reference number, is a long integer.

The PBDirCreateAsync function is identical to PBHCreateAsync except that it creates a new directory instead of a file. The date and time of the directory’s creation and last modification are set to the current date and time.

To create a directory with a Unicode name, use the function FSCreateDirectoryUnicode , or one of the corresponding parameter block calls, PBCreateDirectoryUnicodeSync and PBCreateDirectoryUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDirCreateSync

Creates a new directory. (Deprecated in OS X v10.4. Use PBCreateDirectoryUnicodeSync instead.)

OSErr PBDirCreateSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name for the new directory.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID. If the parent directory ID is 0 and the volume specified in the ioVRefNum field is the default volume, the new directory is placed in the default directory of the volume. If the parent directory ID is 0 and the volume specified in the ioVRefNum field is a volume other than the default volume, the new directory is placed in the root directory of the volume. To create a directory at the root of a volume, regardless of whether that volume is the current default volume, pass the constant fsRtDirID (2) in this field. On output, the directory ID of the new directory. Note that a directory ID, unlike a volume reference number, is a long integer.

The PBDirCreateSync function is identical to PBHCreateSync except that it creates a new directory instead of a file. The date and time of the directory’s creation and last modification are set to the current date and time.

To create a directory with a Unicode name, use the function FSCreateDirectoryUnicode , or one of the corresponding parameter block calls, PBCreateDirectoryUnicodeSync and PBCreateDirectoryUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTAddAPPLAsync

Adds an application to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTAddAPPLAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database to which you wish to add an application.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDirID

On input, the ID of the application’s parent directory.

ioFileCreator

On input, the application’s signature.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTAddAPPLSync

Adds an application to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTAddAPPLSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database to which you wish to add an application.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDirID

On input, the ID of the application’s parent directory.

ioFileCreator

On input, the application’s signature.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTAddIconAsync

Adds an icon definition to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTAddIconAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioDTRefNum

On input, the desktop database reference number of the database to which you wish to add an icon.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTBuffer

On input, a pointer to the buffer holding the icon’s bitmap.

ioDTReqCount

On input, the size in bytes of the buffer that you’ve allocated for the icon’s bitmap. This value depends on the icon type. Be sure to allocate enough storage for the icon data 1024 bytes is the largest amount required for any icon in System 7. For a description of the values you can use to indicate the icon’s size, see “Icon Size Constants.”

ioIconType

On input, the icon type. See “Icon Type Constants” for a description of the values you can use in this field.

ioFileCreator

On input, the icon’s file creator.

ioFileType

On input, the icon’s file type.

If the database already contains an icon definition for an icon of that type, file type, and file creator, the new definition replaces the old.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTAddIconSync

Adds an icon definition to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTAddIconSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioDTRefNum

On input, the desktop database reference number of the database to which you wish to add an icon.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTBuffer

On input, a pointer to the buffer holding the icon’s bitmap.

ioDTReqCount

On input, the size in bytes of the buffer that you’ve allocated for the icon’s bitmap. This value depends on the icon type. Be sure to allocate enough storage for the icon data 1024 bytes is the largest amount required for any icon in System 7 For a description of the values you can use to indicate the icon’s size, see “Icon Size Constants.”

ioIconType

On input, the icon type. See “Icon Type Constants” for a description of the values you can use in this field.

ioFileCreator

On input, the icon’s file creator.

ioFileType

On input, the icon’s file type.

If the database already contains an icon definition for an icon of that type, file type, and file creator, the new definition replaces the old.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTCloseDown

Closes the desktop database, though your application should never do this itself. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTCloseDown (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant field of the parameter block for this function is:

ioDTRefNum

On input, the desktop database reference number.

System software uses the PBDTCloseDown function to close the desktop database; your application should never use this function, which is described here only for completeness. The system software closes the database when the volume is unmounted.

PBDTCloseDown runs synchronously only, and though it will not close down the desktop databases of remote volumes, it will invalidate all local desktop database reference values for remote desktop databases.

When the PBDTCloseDown function closes the database, it frees all resources allocated by PBDTOpenInform or PBDTGetPath.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTDeleteAsync

Removes the desktop database. Unless you are manipulating the desktop database in the absence of the Finder, you should never use this function. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTDeleteAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTDeleteAsync function removes the desktop database from a local volume. You can call PBDTDeleteAsync only when the database is closed. Your application should not call PBDTDeleteAsync unless absolutely necessary.

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioVRefNum

On input, the volume reference number of the desktop database to remove.

ioIndex

Reserved; on input, this field must be set to 0.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTDeleteSync

Removes the desktop database. Unless you are manipulating the desktop database in the absence of the Finder, you should never use this function. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTDeleteSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTDeleteSync function removes the desktop database from a local volume. You can call PBDTDeleteSync only when the database is closed. Your application should not call PBDTDeleteSync unless absolutely necessary.

The relevant fields of the parameter block for this function are:

ioVRefNum

On input, the volume reference number of the desktop database to remove.

ioIndex

Reserved; on input, this field must be set to 0.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTFlushAsync

Saves your changes to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTFlushAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If your application adds information to or removes information from the desktop database, use the PBDTFlushAsync function to save your changes. The PBDTFlushAsync function writes the contents of the desktop database specified in the ioDTRefNum field to the volume.

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioDTRefNum

On input, the desktop database reference number of the desktop database to flush.

You must call PBDTFlushAsync or PBDTFlushSync to update the copy of the desktop database stored on the volume if your application has manipulated information in the database using any of the following functions:

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTFlushSync

Saves your changes to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTFlushSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If your application adds information to or removes information from the desktop database, use the PBDTFlushSync function to save your changes. The PBDTFlushSync function writes the contents of the desktop database specified in the ioDTRefNum field to the volume.

The relevant field of the parameter block for this function is:

ioDTRefNum

On input, the desktop database reference number of the desktop database to flush.

You must call PBDTFlushSync or PBDTFlushAsync to update the copy of the desktop database stored on the volume if your application has manipulated information in the database using any of the following functions:

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetAPPLAsync

Identifies the application that can open a file with a given creator. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetAPPLAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code. See “File Manager Result Codes”.

ioNamePtr

On output, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database containing the specified application.

ioIndex

On input, an index into the application list.

ioTagInfo

On output, the application’s creation date.

ioFileCreator

On input, the signature of the application.

ioAPPLParID

On output, the application’s parent directory.

A single call, with the ioIndex field set to 0, finds the application file with the most recent creation date. If you want to retrieve information about all copies of the application with the given signature, start with ioIndex set to 1 and increment this value by 1 with each call to PBDTGetAPPLAsync until the result code afpItemNotFound is returned in the ioResult field; when called multiple times in this fashion, PBDTGetAPPLAsync returns information about all the application’s copies, including the file with the most recent creation date, in arbitrary order.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetAPPLSync

Identifies the application that can open a file with a given creator. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetAPPLSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On output, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database containing the specified application.

ioIndex

On input, an index into the application list.

ioTagInfo

On output, the application’s creation date.

ioFileCreator

On input, the signature of the application.

ioAPPLParID

On output, the application’s parent directory.

A single call, with the ioIndex field set to 0, finds the application file with the most recent creation date. If you want to retrieve information about all copies of the application with the given signature, start with ioIndex set to 1 and increment this value by 1 with each call to PBDTGetAPPLSync until the result code afpItemNotFound is returned in the ioResult field; when called multiple times in this fashion, PBDTGetAPPLSync returns information about all the application’s copies, including the file with the most recent creation date, in arbitrary order.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetCommentAsync

Retrieves the user comments for a file or directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetCommentAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to the name of the file or directory for which you want to retrieve comments.

ioDTRefNum

On input, the desktop database reference number of the database in which the specified file or directory is found.

ioDTBuffer

On input, a pointer to a buffer allocated to hold the comment text. On output, a pointer to the comment text. Allocate a buffer at least 255 bytes in size. The PBDTGetCommentAsync function places up to ioDTReqCount bytes of the comment into the buffer as a plain text string and places the actual length of the comment in the ioDTActCount field.

ioDTReqCount

On input, the size of the buffer allocated to hold the comment.

ioDTActCount

On output, the comment size.

ioDirID

On input, the parent directory of the file or directory.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetCommentSync

Retrieves the user comments for a file or directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetCommentSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the name of the file or directory for which you want to retrieve comments.

ioDTRefNum

On input, the desktop database reference number of the database in which the specified file or directory is found.

ioDTBuffer

On input, a pointer to a buffer allocated to hold the comment text. On output, a pointer to the comment text. Allocate a buffer at least 255 bytes in size. The PBDTGetCommentSync function places up to ioDTReqCount bytes of the comment into the buffer as a plain text string and places the actual length of the comment in the ioDTActCount field.

ioDTReqCount

On input, the size of the buffer allocated to hold the comment.

ioDTActCount

On output, the comment size.

ioDirID

On input, the parent directory of the file or directory.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Related Sample Code
Declared In
Files.h

PBDTGetIconAsync

Retrieves an icon definition. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetIconAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTGetIconAsync function returns the bitmap for an icon that represents a file of a given type and creator. For example, to get the icon for a file of file type 'SFWR' created by the application with a signature of 'WAVE', specify these two values in the ioFileType and ioFileCreator fields.

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioDTRefNum

On input, the desktop database reference number.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTBuffer

On input, a pointer to a buffer to hold the icon’s data. On return, a pointer to the bitmap returned in the buffer.

ioDTReqCount

On input, the requested size of the icon’s bitmap. Pass the size in bytes of the buffer that you’ve allocated for the icon’s bitmap pointed to by the ioDTBuffer field; this value depends on the icon type. Be sure to allocate enough storage for the icon data; 1024 bytes is the largest amount required for any icon in System 7. You can use the constants described in “Icon Size Constants” to indicate the amount of memory you have provided for the icon’s data.

ioDTActCount

On return, the actual size of the icon’s bitmap. If this value is larger than the value specified in the ioDTReqCount field, only the amount of data allowed by the value in the ioDTReqCount field is valid.

ioIconType

On input, the icon type. For a description of the constants which you can use in this field, see “Icon Type Constants.”

ioFileCreator

On input, the icon’s file creator.

ioFileType

On input, the icon’s file type.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetIconInfoAsync

Retrieves an icon type and the associated file type supported by a given creator in the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetIconInfoAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioDTRefNum

On input, the desktop database reference number.

ioIndex

On input, an index into the icon list.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTActCount

On output, the size of the icon’s bitmap.

ioIconType

On output, the icon type, including the icon size and color depth. For a description of the values which may be returned in this field, see “Icon Type Constants.” Ignore any values returned in ioIconType that are not listed there; they represent special icons and information used only by the Finder.

ioFileCreator

On input, the icon’s file creator.

ioFileType

On output, the icon’s file type.

To step through a list of the icon types and file types supported by an application, make repeated calls to PBDTGetIconInfoAsync, specifying a creator and an index value in the ioIndex field for each call. Set the index to 1 on the first call, and increment it on each subsequent call until the result code afpItemNotFound is returned in the ioResult field.

To get a list of file types that an application can natively open, you can use the Translation Manager function, GetFileTypesThatAppCanNativelyOpen. For a description of this function, see the Translation Manager Reference .

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetIconInfoSync

Retrieves an icon type and the associated file type supported by a given creator in the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetIconInfoSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioDTRefNum

On input, the desktop database reference number.

ioIndex

On input, an index into the icon list.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTActCount

On output, the size of the icon’s bitmap.

ioIconType

On output, the icon type, including the icon size and color depth. For a description of the values which may be returned in this field, see “Icon Type Constants.” Ignore any values returned in ioIconType that are not listed there; they represent special icons and information used only by the Finder.

ioFileCreator

On input, the icon’s file creator.

ioFileType

On output, the icon’s file type.

To step through a list of the icon types and file types supported by an application, make repeated calls to PBDTGetIconInfoSync, specifying a creator and an index value in the ioIndex field for each call. Set the index to 1 on the first call, and increment it on each subsequent call until the result code afpItemNotFound is returned in the ioResult field.

To get a list of file types that an application can natively open, you can use the Translation Manager function, GetFileTypesThatAppCanNativelyOpen. For a description of this function, see the Translation Manager Reference .

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetIconSync

Retrieves an icon definition. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetIconSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTGetIconSync function returns the bitmap for an icon that represents a file of a given type and creator. For example, to get the icon for a file of file type 'SFWR' created by the application with a signature of 'WAVE', specify these two values in the ioFileType and ioFileCreator fields.

The relevant fields of the parameter block for this function are:

ioDTRefNum

On input, the desktop database reference number.

ioTagInfo

Reserved; on input, this field must be set to 0.

ioDTBuffer

On input, a pointer to a buffer to hold the icon’s data. On return, a pointer to the bitmap returned in the buffer.

ioDTReqCount

On input, the requested size of the icon’s bitmap. Pass the size in bytes of the buffer that you’ve allocated for the icon’s bitmap, pointed to by the ioDTBuffer field; this value depends on the icon type. Be sure to allocate enough storage for the icon data; 1024 bytes is the largest amount required for any icon in System 7. You can use the constants described in “Icon Size Constants” to indicate the amount of memory you have provided for the icon’s data.

ioDTActCount

On output, the actual size of the icon’s bitmap. If this value is larger than the value specified in the ioDTReqCount field, only the amount of data allowed by ioDTReqCount is valid.

ioIconType

On input, the icon type. For a description of the constants which you can use in this field, see “Icon Type Constants.”

ioFileCreator

On input, the icon’s file creator.

ioFileType

On input, the icon’s file type.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetInfoAsync

Determines information about the location and size of the desktop database on a particular volume. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetInfoAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion function. For more information on completion functions, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioVRefNum

On output, the volume reference number of the volume where the database files are stored.

ioDTRefNum

On input, the desktop database reference number of the database which you wish to obtain information about.

ioIndex

On output, the number of files comprising the desktop database on the volume.

ioDirID

On output, the parent directory ID of the desktop database.

ioDTLgLen

On output, the logical length of the database files (the sum of the logical lengths of the files that constitute the desktop database for a given volume).

ioDTPyLen

On output, the physical length of the database files (the sum of the physical lengths of the files that constitute the desktop database for a given volume).

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetInfoSync

Determines information about the location and size of the desktop database on a particular volume. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetInfoSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioVRefNum

On output, the volume reference number of the volume where the database files are stored.

ioDTRefNum

On input, the desktop database reference number of the database which you wish to obtain information about.

ioIndex

On output, the number of files comprising the desktop database on the volume.

ioDirID

On output, the parent directory ID of the desktop database.

ioDTLgLen

On output, the logical length of the database files (the sum of the logical lengths of the files that constitute the desktop database for a given volume).

ioDTPyLen

On output, the physical length of the database files (the sum of the physical lengths of the files that constitute the desktop database for a given volume).

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTGetPath

Gets the reference number of the specified desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTGetPath (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the name of the volume associated with the desktop database or the full pathname of the desktop database.

ioVRefNum

On input, the volume reference number of the volume associated with the desktop database.

ioDTRefNum

On output, the desktop database reference number, which represents the access path to the database. You cannot use the desktop reference number as a file reference number in any File Manager functions other than the desktop database functions. If PBDTGetPath fails, it sets this field to 0.

If the desktop database is not already open, PBDTGetPath opens it and then returns the reference number. If the desktop database doesn’t exist, PBDTGetPath creates it .

Special Considerations

PBDTGetPath allocates memory in the system heap; do not call it at interrupt time.

This function executes synchronously only.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Related Sample Code
Declared In
Files.h

PBDTOpenInform

Gets the reference number of the specified desktop database, reporting whether the desktop database was empty when it was opened. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTOpenInform (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the name of the volume associated with the desktop database or the full pathname of the desktop database.

ioVRefNum

On input, the volume reference number of the volume associated with the desktop database.

ioDTRefNum

On output, the desktop database reference number, which represents the access path to the database. You cannot use the desktop reference number as a file reference number in any File Manager functions other than the desktop database functions. If PBDTOpenInform fails, it sets this field to 0.

ioTagInfo

On output, the return flag (in the low bit of this field). If the desktop database was just created in response to PBDTOpenInform (and is therefore empty), PBDTOpenInform sets the low bit in this field to 0. If the desktop database had been created before you called PBDTOpenInform, PBDTOpenInform sets the low bit in this field to 1.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

This function executes synchronously only.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTRemoveAPPLAsync

Removes an application from the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTRemoveAPPLAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.” When called on an HFS CD volume, PBDTRemoveAPPL returns an afpItemNotFound error, instead of the expected volume locked error (wPrErr).

Discussion

The PBDTRemoveAPPLAsync function removes the mapping information for an application from the database specified in the ioDTRefNum field. You can call PBDTRemoveAPPLAsync even if the application is not present on the volume.

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database containing the application.

ioDirID

On input, the application’s parent directory.

ioFileCreator

On input, the application’s signature.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTRemoveAPPLSync

Removes an application from the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTRemoveAPPLSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTRemoveAPPLSync function removes the mapping information for an application from the database specified in the ioDTRefNum field. You can call PBDTRemoveAPPLSync even if the application is not present on the volume.

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the application’s name.

ioDTRefNum

On input, the desktop database reference number of the desktop database containing the application.

ioDirID

On input, the application’s parent directory.

ioFileCreator

On input, the application’s signature.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTRemoveCommentAsync

Removes a user comment associated with a file or directory from the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTRemoveCommentAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to the filename or directory name.

ioDTRefNum

On input, the desktop database reference number of the database in which the specified file or directory is found.

ioDirID

On input, the parent directory ID of the file or directory.

You cannot remove a comment if the file or directory it is associated with is not present on the volume. If no comment was stored for the file, PBDTRemoveCommentAsync returns an error.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTRemoveCommentSync

Removes a user comment associated with a file or directory from the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTRemoveCommentSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the filename or directory name.

ioDTRefNum

On input, the desktop database reference number of the database in which the specified file or directory is found.

ioDirID

On input, the parent directory ID of the file or directory.

You cannot remove a comment if the file or directory it is associated with is not present on the volume. If no comment was stored for the file, PBDTRemoveCommentSync returns an error.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTResetAsync

Removes information from the desktop database. Unless you are manipulating the desktop database in the absence of the Finder, you should never use this function. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTResetAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTResetAsync function removes all icons, application mappings, and comments from the desktop database specified in the ioDTRefNum field. You can call PBDTResetAsync only when the database is open. It remains open after the data is cleared. Your application should not call PBDTResetAsync unless absolutely necessary.

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioDTRefNum

On input, the desktop database reference number of the desktop database to clear.

ioIndex

Reserved; on input, this field must be set to 0.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTResetSync

Removes information from the desktop database. Unless you are manipulating the desktop database in the absence of the Finder, you should never use this function. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTResetSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBDTResetSync function removes all icons, application mappings, and comments from the desktop database specified in the ioDTRefNum field. You can call PBDTResetSync only when the database is open. It remains open after the data is cleared. Your application should not call PBDTResetSync unless absolutely necessary.

The relevant fields of the parameter block for this function are:

ioDTRefNum

On input, the desktop database reference number of the desktop database to clear.

ioIndex

Reserved; on input, this field must be set to 0.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTSetCommentAsync

Adds a user comment for a file or a directory to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTSetCommentAsync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to the name of the file or directory.

ioDTRefNum

On input, the desktop database reference number for the desktop database to which to add the user comment.

ioDTBuffer

On input, a pointer to the buffer containing the comment text. Put the comment in the buffer as a plain text string.

ioDTReqCount

On input, the length of the buffer (in bytes) containing the comment text. The maximum length of a comment is 200 bytes; longer comments are truncated. Since the comment is a plain text string and not a Pascal string, the File Manager relies on the value in the ioDTReqCount field for determining the length of the buffer.

ioDirID

On input, the parent directory ID of the file or directory.

If the specified object already has a comment in the database, the new comment replaces the old.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDTSetCommentSync

Adds a user comment for a file or a directory to the desktop database. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBDTSetCommentSync (
   DTPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a desktop database parameter block. See DTPBRec for a description of the DTPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block for this function are:

ioNamePtr

On input, a pointer to the name of the file or directory.

ioDTRefNum

On input, the desktop database reference number for the desktop database to which to add the user comment.

ioDTBuffer

On input, a pointer to the buffer containing the comment text. Put the comment in the buffer as a plain text string.

ioDTReqCount

On input, the length of the buffer containing the comment text, in bytes. The maximum length of a comment is 200 bytes; longer comments are truncated. Since the comment is a plain text string and not a Pascal string, the File Manager relies on the value in the ioDTReqCount field for determining the length of the buffer.

ioDirID

On input, the parent directory ID of the file or directory.

If the specified object already has a comment in the database, the new comment replaces the old.

Special Considerations

All of the desktop database functions may move or purge memory blocks in the application heap or for some other reason should not be called from within an interrupt.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBExchangeFilesAsync

Exchanges the data stored in two files on the same volume. (Deprecated in OS X v10.4. Use PBExchangeObjectsAsync instead.)

OSErr PBExchangeFilesAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the first file to swap.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDestNamePtr

On input, a pointer to the name of the second file to swap.

ioDestDirID

On input, the second file’s parent directory ID.

ioSrcDirID

On input, the first file’s parent directory ID.

Typically, you use PBExchangeFilesAsync after creating a new file during a safe save. The PBExchangeFilesAsync function changes the fields in the catalog entries that record the location of the data and the modification dates. It swaps both the data forks and the resource forks.

The PBExchangeFilesAsync function works on either open or closed files. PBExchangeFilesAsync swaps the data in two files by changing some of the information in the volume catalog. If either file is open, PBExchangeFilesAsync updates any file control blocks associated with the file. Exchanging the contents of two files requires essentially the same access privileges as opening both files for writing.

The following fields in the catalog entries for the files are exchanged:

  • ioFlStBlk

  • ioFlLgLen

  • ioFlPyLen

  • ioFlRStBlk

  • ioFlRLgLen

  • ioFlRPyLen

  • ioFlMdDat

In the file control blocks, the fcbFlNum, fcbDirID, and fcbCName fields are exchanged.

You should use PBExchangeFilesAsync to preserve the file ID when updating an existing file, in case the file is being tracked through its file ID. The PBExchangeFilesAsync function does not require that file ID references exist for the files being exchanged.

To exchange the contents of files with named forks other than the data and resource forks, or of files larger than 2 GB, use the FSExchangeObjects , PBExchangeObjectsSync , or PBExchangeObjectsAsync function.

Special Considerations

Your application will have to swap any open reference numbers to the two files because the file's name and parent directory ID are exchanged in the file control blocks.

Because other programs may have access paths open to one or both of the files exchanged, your application should have exclusive read/write access permission (fsRdWrPerm) to both files before calling PBExchangeFilesAsync. Exclusive read/write access to both files will ensure that PBExchangeFilesAsync doesn't affect another application because it prevents other applications from obtaining write access to one or both of the files exchanged.

PBExchangeFilesAsync does not respect the file-locked attribute; it will perform the exchange even if one or both of the files are locked. Obtaining exclusive read/write access to both files before calling PBExchangeFilesAsync ensures that the files are unlocked because locked files cannot be opened with write access.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBExchangeFilesSync

Exchanges the data stored in two files on the same volume. (Deprecated in OS X v10.4. Use PBExchangeObjectsSync instead.)

OSErr PBExchangeFilesSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the first file to swap.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDestNamePtr

On input, a pointer to the name of the second file to swap.

ioDestDirID

On input, the second file’s parent directory ID.

ioSrcDirID

On input, the first file’s parent directory ID.

Typically, you use PBExchangeFilesSync after creating a new file during a safe save. The PBExchangeFilesSync function changes the fields in the catalog entries that record the location of the data and the modification dates. It swaps both the data forks and the resource forks.

The PBExchangeFilesSync function works on either open or closed files. PBExchangeFilesSync swaps the data in two files by changing some of the information in the volume catalog. If either file is open, PBExchangeFilesSync updates any file control blocks associated with the file. Exchanging the contents of two files requires essentially the same access privileges as opening both files for writing.

The following fields in the catalog entries for the files are exchanged:

  • ioFlStBlk

  • ioFlLgLen

  • ioFlPyLen

  • ioFlRStBlk

  • ioFlRLgLen

  • ioFlRPyLen

  • ioFlMdDat

In the file control blocks, the fcbFlNum, fcbDirID, and fcbCName fields are exchanged.

You should use PBExchangeFilesSync to preserve the file ID when updating an existing file, in case the file is being tracked through its file ID. The PBExchangeFilesSync function does not require that file ID references exist for the files being exchanged.

To exchange the contents of files with named forks other than the data and resource forks, or of files larger than 2 GB, use the FSExchangeObjects , PBExchangeObjectsSync , or PBExchangeObjectsAsync function.

Special Considerations

Your application will have to swap any open reference numbers to the two files because the file's name and parent directory ID are exchanged in the file control blocks.

Because other programs may have access paths open to one or both of the files exchanged, your application should have exclusive read/write access permission (fsRdWrPerm) to both files before calling PBExchangeFilesSync. Exclusive read/write access to both files will ensure that PBExchangeFilesSync doesn't affect another application because it prevents other applications from obtaining write access to one or both of the files exchanged.

PBExchangeFilesSync does not respect the file-locked attribute; it will perform the exchange even if one or both of the files are locked. Obtaining exclusive read/write access to both files before calling PBExchangeFilesSync ensures that the files are unlocked because locked files cannot be opened with write access.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBFlushFileAsync

Writes the contents of a file’s access path buffer to the disk. (Deprecated in OS X v10.4. Use PBFlushForkAsync instead.)

OSErr PBFlushFileAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the file to flush.

After writing the contents of the file to the volume, the PBFlushFileAsync function updates the file’s entry in the volume catalog.

In the event of a system crash, all cached data not yet written to disk is lost. If you have made changes to space that already exists within a file (you are overwriting existing data before the file’s end-of-file), you must use PBFlushFileAsync to ensure that everything written to the file will be written to disk. If you flush the fork’s cached blocks using PBFlushFileAsync, the only possible data loss in a system crash will be the file’s modification date.

You do not, however, need to use PBFlushFileAsync to flush a file fork before it is closed; the file is automatically flushed when it is closed and all cache blocks associated with it are removed from the cache.

PBFlushFileSync flushes an open fork’s dirty cached blocks, but may not flush catalog information associated with the file. To flush catalog information, call FlushVol , or one of the related parameter block calls, PBFlushVolSync and PBFlushVolAsync.

To update a file larger than 2GB, or a named fork other than the data and resource forks, you must use the FSFlushFork function, or one of the corresponding parameter block calls, PBFlushForkSync and PBFlushForkAsync.

Special Considerations

Some information stored on the volume won’t be correct until PBFlushVolAsync is called.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBFlushFileSync

Writes the contents of a file’s access path buffer to the disk. (Deprecated in OS X v10.4. Use PBFlushForkSync instead.)

OSErr PBFlushFileSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant field of the parameter block is:

ioRefNum

On input, a file reference number for the file to flush.

After writing the contents of the file to the volume, the PBFlushFileSync function updates the file’s entry in the volume catalog.

In the event of a system crash, all cached data not yet written to disk is lost. If you have made changes to space that already exists within a file (you are overwriting existing data before the file’s end-of-file), you must use PBFlushFileSync to ensure that everything written to the file will be written to disk. If you flush the fork’s cached blocks using PBFlushFileSync, the only possible data loss in a system crash will be the file’s modification date.

You do not, however, need to use PBFlushFileSync to flush a file fork before it is closed; the file is automatically flushed when it is closed and all cache blocks associated with it are removed from the cache.

PBFlushFileSync flushes an open fork’s dirty cached blocks, but may not flush catalog information associated with the file. To flush catalog information, call FlushVol , or one of the related parameter block calls, PBFlushVolSync and PBFlushVolAsync.

To update a file larger than 2GB, or a named fork other than the data and resource forks, you must use the FSFlushFork function, or one of the corresponding parameter block calls, PBFlushForkSync and PBFlushForkAsync.

Special Considerations

Some information stored on the volume won’t be correct until PBFlushVolSync is called.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetCatInfoAsync

Returns catalog information about a file or directory. (Deprecated in OS X v10.4. At the Foundation layer, use getResourceValue:forKey:error: or resourceValuesForKeys:error: instead. At the Core Foundation layer, use CFURLCopyResourcePropertyForKey or CFURLCopyResourcePropertiesForKeys instead.)

OSErr PBGetCatInfoAsync (
   CInfoPBPtr paramBlock
);
Parameters
paramBlock

A pointer to an HFS catalog information parameter block. See CInfoPBRec for a description of the CInfoPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBGetCatInfoAsync function returns information about a file or directory, depending on the values you specify in the ioFDirIndex, ioNamePtr, ioVRefNum, and ioDirID or ioDrDirID fields. If you need to determine whether the information returned is for a file or a directory, you can test bit 4 of the ioFlAttrib field; if that bit is set, the information returned describes a directory.

The PBGetCatInfoAsync function selects a file or directory according to these rules:

  • If the value of ioFDirIndex is positive, ioNamePtr is not used as an input parameter and PBGetCatInfoAsync returns information about the file or directory whose directory index is ioFDirIndex in the directory specified by ioDirID (or ioDrDirID) on the volume specified by ioVRefNum (this will be the root directory if ioVRefNum is a volume reference number or a drive number and ioDirID is 0). If ioNamePtr is not NULL, then it must point to a Str31 buffer where the file or directory name will be returned.

  • If the value of ioFDirIndex is 0, PBGetCatInfoAsync returns information about the file or directory specified by ioNamePtr in the directory specified by ioDirID (or ioDrDirID) on the volume specified by ioVRefNum (again, this will be the root directory if ioVRefNum is a volume reference number or a drive number and ioDirID is 0).

  • If the value of ioFDirIndex is negative, PBGetCatInfoAsync ignores the ioNamePtr field and returns information about the directory specified in the ioDrDirID field. If ioNamePtr is not NULL, then it must point to a Str31 buffer where the directory name will be returned.

With files, PBGetCatInfoAsync is similar to PBHGetFInfoAsync but returns some additional information. If the object is a file, the relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname. On output, the name of the file is returned in this field, if the file is open. If you do not want the name of the file returned, pass NULL in this field.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFRefNum

On output, a file reference number. If the file is open, the reference number of the first access path found is returned here .

ioFDirIndex

On input, a directory index.

ioFlAttrib

On output, the file attributes. See “File Attribute Constants” for the meaning of the file attributes.

ioFlFndrInfo

On output, information used by the Finder.

ioDirID

On input, a directory ID. On output, the file ID. You might need to save the value of ioDirID before calling PBGetCatInfoAsync if you make subsequent calls with the same parameter block.

ioFlStBlk

On output, the first allocation block of the data fork.

ioFlLgLen

On output, the logical size (the logical end-of-file) of the data fork, in bytes.

ioFlPyLen

On output, the physical size (the physical end-of-file) of the data fork, in bytes.

ioFlRStBlk

On output, the first allocation block of the resource fork.

ioFlRLgLen

On output, the logical size of the resource fork, in bytes.

ioFlRPyLen

On output, the physical size of the resource fork, in bytes.

ioFlCrDat

On output, the date and time of the file’s creation. Note that file systems other than AFP, HFS and HFS Plus do not generally support creation dates. For file systems which do not support creation dates, the File Manager sets the ioFlCrDat field to 0.

ioFlMdDat

On output, the date and time of the file’s last modification.

ioFlBkDat

On output, the date and time of the file’s last backup. Note that file systems other than AFP, HFS and HFS Plus do not generally support backup dates. For file systems which do not support backup dates, the File Manager sets the ioFlBkDat field to 0.

ioFlXFndrInfo

On output, additional information used by the Finder.

ioFlParID

On output, the directory ID of the file’s parent directory.

ioFlClpSiz

On output, the file’s clump size.

You can also use PBGetCatInfoAsync to determine whether a file has a file ID reference. The value of the file ID is returned in the ioDirID field. Because that parameter could also represent a directory ID, call PBResolveFileIDRefAsync to see if the value is a real file ID. If you want to determine whether a file ID reference exists for a file and create one if it doesn’t, use PBCreateFileIDRefAsync , which will either create a file ID or return fidExists.

If the object is a directory, the relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname. On output, a pointer to the directory name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFDirIndex

On input, a directory index.

ioFlAttrib

On output, the directory attributes. See “File Attribute Constants” for the meaning of the bits in this field. The bits in this field for directories are read-only. You cannot alter directory attributes by setting these bits using the functions PBSetCatInfoSync or PBSetCatInfoAsync. Instead, you can call the PBHSetFLockSync and PBHRstFLockSync functions to lock and unlock a directory, and the PBShareSync and PBUnshareSync functions to enable and disable file sharing on local directories.

ioACUser

On output, the directory access rights. The PBGetCatInfoAsync function returns the information in this field only for shared volumes. As a result, you should set this field to 0 before calling PBGetCatInfoAsync.PBGetCatInfoAsync does not return the blank access privileges bit in this field; to determine whether a directory has blank access privileges, use the PBHGetDirAccessAsync function. See “User Privileges Constants” for a description of the constants that may be returned in this field.

ioDrUsrWds

On output, information used by the Finder.

ioDrDirID

On input, if you wish to obtain information about a specific directory, that directory’s ID. Otherwise, if the object returned is a directory, this field contains the directory ID on output.

ioDrNmFls

On output, the number of files in the directory.

ioDrCrDat

On output, the date and time of the directory’s creation. Note that file systems other than AFP, HFS and HFS Plus do not generally support creation dates. For file systems which do not support creation dates, the File Manager sets the ioDrCrDat field to 0.

ioDrMdDat

On output, the date and time of the directory’s last modification.

ioDrBkDat

On output, the date and time of the directory’s last backup. Note that file systems other than AFP, HFS and HFS Plus do not generally support backup dates. For file systems which do not support backup dates, the File Manager sets the ioDrBkDat field to 0.

ioDrFndrInfo

On output, additional information used by the Finder.

ioDrParID

On output, the directory ID of the directory’s parent directory.

To get information on a file or directory with named forks, or on a file larger than 2GB, use one of the FSGetCatalogInfo , PBGetCatalogInfoSync , or PBGetCatalogInfoAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetCatInfoSync

Returns catalog information about a file or directory. (Deprecated in OS X v10.4. At the Foundation layer, use getResourceValue:forKey:error: or resourceValuesForKeys:error: instead. At the Core Foundation layer, use CFURLCopyResourcePropertyForKey or CFURLCopyResourcePropertiesForKeys instead.)

OSErr PBGetCatInfoSync (
   CInfoPBPtr paramBlock
);
Parameters
paramBlock

A pointer to an HFS catalog information parameter block. See CInfoPBRec for a description of the CInfoPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBGetCatInfoSync function returns information about a file or directory, depending on the values you specify in the ioFDirIndex, ioNamePtr, ioVRefNum, and ioDirID or ioDrDirID fields. If you need to determine whether the information returned is for a file or a directory, you can test bit 4 of the ioFlAttrib field; if that bit is set, the information returned describes a directory.

The PBGetCatInfoSync function selects a file or directory according to these rules:

  • If the value of ioFDirIndex is positive, ioNamePtr is not used as an input parameter and PBGetCatInfoSync returns information about the file or directory whose directory index is ioFDirIndex in the directory specified by ioDirID (or ioDrDirID) on the volume specified by ioVRefNum (this will be the root directory if ioVRefNum is a volume reference number or a drive number and ioDirID is 0). If ioNamePtr is not NULL, then it must point to a Str31 buffer where the file or directory name will be returned.

  • If the value of ioFDirIndex is 0, PBGetCatInfoSync returns information about the file or directory specified by ioNamePtr in the directory specified by ioDirID (or ioDrDirID) on the volume specified by ioVRefNum (again, this will be the root directory if ioVRefNum is a volume reference number or a drive number and ioDirID is 0).

  • If the value of ioFDirIndex is negative, PBGetCatInfoSync ignores the ioNamePtr field and returns information about the directory specified in the ioDrDirID field. If ioNamePtr is not NULL, then it must point to a Str31 buffer where the directory name will be returned.

With files, PBGetCatInfoSync is similar to PBHGetFInfoSync but returns some additional information. If the object is a file, the relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. On output, the name of the file is returned in this field, if the file is open. If you do not want the name of the file returned, pass NULL in this field.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFRefNum

On output, a file reference number. If the file is open, the reference number of the first access path found is returned here.

ioFDirIndex

On input, a directory index.

ioFlAttrib

On output, the file attributes. See “File Attribute Constants” for the meaning of the file attributes.

ioFlFndrInfo

On output, information used by the Finder.

ioDirID

On input, a directory ID. On output, the file ID. You might need to save the value of ioDirID before calling PBGetCatInfoSync if you make subsequent calls with the same parameter block.

ioFlStBlk

On output, the first allocation block of the data fork.

ioFlLgLen

On output, the logical size (the logical end-of-file) of the data fork, in bytes.

ioFlPyLen

On output, the physical size (the physical end-of-file) of the data fork, in bytes.

ioFlRStBlk

On output, the first allocation block of the resource fork.

ioFlRLgLen

On output, the logical size of the resource fork, in bytes.

ioFlRPyLen

On output, the physical size of the resource fork, in bytes.

ioFlCrDat

On output, the date and time of the file’s creation. Note that file systems other than AFP, HFS and HFS Plus do not generally support creation dates. For file systems which do not support creation dates, the File Manager sets the ioFlCrDat field to 0.

ioFlMdDat

On output, the date and time of the file’s last modification.

ioFlBkDat

On output, the date and time of the file’s last backup. Note that file systems other than AFP, HFS and HFS Plus do not generally support backup dates. For file systems which do not support backup dates, the File Manager sets the ioFlBkDat field to 0.

ioFlXFndrInfo

On output, additional information used by the Finder.

ioFlParID

On output, the directory ID of the file’s parent directory.

ioFlClpSiz

On output, the file’s clump size.

You can also use PBGetCatInfoSync to determine whether a file has a file ID reference. The value of the file ID is returned in the ioDirID field. Because that parameter could also represent a directory ID, call PBResolveFileIDRefSync to see if the value is a real file ID. If you want to determine whether a file ID reference exists for a file and create one if it doesn’t, use PBCreateFileIDRefSync , which will either create a file ID or return fidExists.

If the object is a directory, the relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. On output, a pointer to the directory’s name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFDirIndex

On input, a directory index.

ioFlAttrib

On output, the directory attributes. See “File Attribute Constants” for the meaning of the bits in this field. The bits in this field for directories are read-only. You cannot alter directory attributes by setting these bits using the functions PBSetCatInfoSync or PBSetCatInfoAsync. Instead, you can call the PBHSetFLockSync and PBHRstFLockSync functions to lock and unlock a directory, and the PBShareSync and PBUnshareSync functions to enable and disable file sharing on local directories.

ioACUser

On output, the directory access rights. The PBGetCatInfoSync function returns the information in this field only for shared volumes. As a result, you should set this field to 0 before calling PBGetCatInfoSync. PBGetCatInfoSync does not return the blank access privileges bit in this field; to determine whether a directory has blank access privileges, use the PBHGetDirAccessSync function. See “User Privileges Constants” for a description of the constants that may be returned here.

ioDrUsrWds

On output, information used by the Finder.

ioDrDirID

On input, if you wish to obtain information about a specific directory, that directory’s ID. Otherwise, if the object returned is a directory, this field contains the directory ID on output.

ioDrNmFls

On output, the number of files in the directory.

ioDrCrDat

On output, the date and time of the directory’s creation. Note that file systems other than AFP, HFS and HFS Plus do not generally support creation dates. For file systems which do not support creation dates, the File Manager sets the ioDrCrDat field to 0.

ioDrMdDat

On output, the date and time of the directory’s last modification.

ioDrBkDat

On output, the date and time of the directory’s last backup. Note that file systems other than AFP, HFS and HFS Plus do not generally support backup dates. For file systems which do not support backup dates, the File Manager sets the ioDrBkDat field to 0.

ioDrFndrInfo

On output, additional information used by the Finder.

ioDrParID

On output, the directory ID of the directory’s parent directory.

To get information on a file or directory with named forks, or on a file larger than 2GB, use one of the FSGetCatalogInfo , PBGetCatalogInfoSync , or PBGetCatalogInfoAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetEOFAsync

Determines the current logical size of an open file. (Deprecated in OS X v10.4. Use PBGetForkSizeAsync instead.)

OSErr PBGetEOFAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the open file.

ioMisc

On output, the logical size (the logical end-of-file) of the given file. Because the ioMisc field is of type Ptr, you’ll need to coerce the value to a long integer to interpret the value correctly.

To determine the size of a named fork other than the data or resource forks, or of a fork larger than 2 GB, use the FSGetForkSize function, or one of the corresponding parameter block functions, PBGetForkSizeSync and PBGetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetEOFSync

Determines the current logical size of an open file. (Deprecated in OS X v10.4. Use PBGetForkSizeSync instead.)

OSErr PBGetEOFSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for the open file.

ioMisc

On output, a pointer to the logical size (the logical end-of-file) of the given file. Because the ioMisc field is of type Ptr, you’ll need to coerce the value to a long integer to interpret the value correctly.

To determine the size of a named fork other than the data or resource forks, or of a fork larger than 2 GB, use the FSGetForkSize function, or one of the corresponding parameter block functions, PBGetForkSizeSync and PBGetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetFCBInfoAsync

Gets information about an open file from the file control block. (Deprecated in OS X v10.4. Use PBGetForkCBInfoAsync instead.)

OSErr PBGetFCBInfoAsync (
   FCBPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a file control block parameter block. See FCBPBRec for a description of the FCBPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname. You should pass a pointer to a Str31 value if you want the name of the file returned. If you pass NULL, no filename is returned. On output, if PBGetFCBInfoAsync executes successfully, a pointer to the name of the specified open file.

ioVRefNum

On input, a volume specification. If you specify a valid index number in the ioFCBIndx field, the File Manager returns information on the file having that index in the FCB buffer on the volume specified in this field. This field may contain a drive number or volume reference number. If the value of ioVRefNum is 0, all open files are indexed; otherwise, only open files on the specified volume are indexed.

ioRefNum

On input, if the ioFCBIndx field is 0, the file reference number of the file to get information about. If the value of ioFCBIndx is positive, the ioRefNum field is ignored on input and contains the file reference number on output.

ioFCBIndx

On input, an index. If the value of ioFCBIndx is positive, the File Manager returns information about the file whose index in the FCB buffer is ioFCBIndx and that is located on the volume specified in the ioVRefNum field. If the value of ioFCBIndx is 0, the File Manager returns information about the file whose file reference number is specified by the ioRefNum field.

ioFCBFlNm

On output, the file ID.

ioFCBFlags

On output, file status flags. See “FCB Flags” for a description of the bits in this field.

ioFCBStBlk

On output, the first allocation block of the file.

ioFCBEOF

On output, the logical size (the logical end-of-file) of the file.

ioFCBPLen

On output, the physical size (the physical end-of-file) of the file.

ioFCBCrPs

On output, the position of the file mark.

ioFCBVRefNum

On output, the volume reference number.

ioFCBClpSiz

On output, the file clump size.

ioFCBParID

On output, the directory ID of the file’s parent directory.

To get information about a fork control block, use one of the functions, FSGetForkCBInfo , PBGetForkCBInfoSync , or PBGetForkCBInfoAsync.

Special Considerations

On OS X, the value returned by PBGetFCBInfoAsync in the ioFCBPLen field may differ from the physical file length reported by FSGetCatalogInfo, PBGetCatInfo, and related functions. When a write causes a file to grow in size, the physical length reported by FSGetCatalogInfo and similar calls increases by the clump size, which is a multiple of the allocation block size. However, the physical length returned by PBGetFCBInfoAsync changes according to the allocation block size and the file lengths returned by the respective functions get out of sync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetFCBInfoSync

Gets information about an open file from the file control block. (Deprecated in OS X v10.4. Use PBGetForkCBInfoSync instead.)

OSErr PBGetFCBInfoSync (
   FCBPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a file control block parameter block. See FCBPBRec for a description of the FCBPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. You should pass a pointer to a Str31 value if you want the name of the file returned. If you pass NULL, no filename is returned. On output, if PBGetFCBInfoSync executes successfully, a pointer to the name of the specified open file.

ioVRefNum

On input, a volume specification. If you specify a valid index number in the ioFCBIndx field, the File Manager returns information on the file having that index in the FCB buffer on the volume specified in this field. This field may contain a drive number or volume reference number. If the value of ioVRefNum is 0, all open files are indexed; otherwise, only open files on the specified volume are indexed.

ioRefNum

On input, if the ioFCBIndx field is 0, the file reference number of the file to get information about. If the value of ioFCBIndx is positive, the ioRefNum field is ignored on input and contains the file reference number on output.

ioFCBIndx

On input, an index. If the value of ioFCBIndx is positive, the File Manager returns information about the file whose index in the FCB buffer is ioFCBIndx and that is located on the volume specified in the ioVRefNum field. If the value of ioFCBIndx is 0, the File Manager returns information about the file whose file reference number is specified by the ioRefNum field.

ioFCBFlNm

On output, the file ID.

ioFCBFlags

On output, file status flags. See “FCB Flags” for a description of the bits in this field.

ioFCBStBlk

On output, the first allocation block of the file.

ioFCBEOF

On output, the logical size (the logical end-of-file) of the file.

ioFCBPLen

On output, the physical size (the physical end-of-file) of the file.

ioFCBCrPs

On output, the current position of the file mark.

ioFCBVRefNum

On output, the volume reference number.

ioFCBClpSiz

On output, the file clump size.

ioFCBParID

On output, the directory ID of the file’s parent directory.

To get information about a fork control block, use one of the functions, FSGetForkCBInfo , PBGetForkCBInfoSync , or PBGetForkCBInfoAsync.

Special Considerations

On OS X, the value returned by PBGetFCBInfoSync in the ioFCBPLen field may differ from the physical file length reported by FSGetCatalogInfo, PBGetCatInfo, and related functions. When a write causes a file to grow in size, the physical length reported by FSGetCatalogInfo and similar calls increases by the clump size, which is a multiple of the allocation block size. However, the physical length returned by PBGetFCBInfoSync changes according to the allocation block size and the file lengths returned by the respective functions get out of sync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetForeignPrivsAsync

Determines the native access-control information for a file or directory stored on a volume managed by a foreign file system. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetForeignPrivsAsync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetForeignPrivsSync

Determines the native access-control information for a file or directory stored on a volume managed by a foreign file system. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetForeignPrivsSync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetFPosAsync

Returns the current position of the file mark. (Deprecated in OS X v10.4. Use PBGetForkPositionAsync instead.)

OSErr PBGetFPosAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information about completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, the file reference number of an open file.

ioPosOffset

On output, the current position of the mark. The value returned in ioPosOffset is zero-based. Thus, a call to PBGetFPosAsync returns 0 if you call it when the file mark is positioned at the beginning of the file. The ioReqCount, ioActCount, and ioPosMode fields of the parameter block are all set to 0 on output. To determine the current position of a named fork, or of a fork larger than 2GB, use the FSGetForkPosition function, or one of the corresponding parameter block calls, PBGetForkPositionSync and PBGetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetFPosSync

Returns the current position of the file mark. (Deprecated in OS X v10.4. Use PBGetForkPositionSync instead.)

OSErr PBGetFPosSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, the file reference number of an open file.

ioPosOffset

On output, the current position of the mark. The value returned in ioPosOffset is zero-based. Thus, a call to PBGetFPosSync returns 0 if you call it when the file mark is positioned at the beginning of the file.

The ioReqCount, ioActCount, and ioPosMode fields of the parameter block are all set to 0 on output.

To determine the current position of a named fork, or of a fork larger than 2GB, use the FSGetForkPosition function, or one of the corresponding parameter block calls, PBGetForkPositionSync and PBGetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetUGEntryAsync

Gets a user or group entry from the list of User and Group names and IDs on the local file server. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetUGEntryAsync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetUGEntrySync

Gets a user or group entry from the list of User and Group names and IDs on a local file server. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetUGEntrySync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetXCatInfoAsync

Returns the short name (MS-DOS format name) and the ProDOS information for a file or directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetXCatInfoAsync (
   XCInfoPBPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetXCatInfoSync

Returns the short name (MS-DOS format name) and the ProDOS information for a file or directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBGetXCatInfoSync (
   XCInfoPBPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHCreateAsync

Creates a new file. (Deprecated in OS X v10.4. Use PBCreateFileUnicodeAsync instead.)

OSErr PBHCreateAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion functions, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name for the new file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the parent directory of the new file.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

The PBHCreateAsync function creates both forks of the file the new file is unlocked and empty. The date and time of its creation and last modification are set to the current date and time. If the file created isn’t temporary (that is, if it will exist after the user quits the application), the application should call PBHSetFInfoAsync , after the call to PBHCreateAsync, to fill in the information needed by the Finder.

Files created using PBHCreateAsync are not automatically opened. If you want to write data to the new file, you must first open the file using one of the file access functions, FSpOpenDF , HOpenDF , PBHOpenDFSync or PBHOpenDFAsync.

The resource fork of the new file exists but is empty. You’ll need to call one of the Resource Manager procedures HCreateResFile or FSpCreateResFile to create a resource map in the file before you can open it (by calling one of the Resource Manager functions HOpenResFile or FSpOpenResFile).

To create a file with a Unicode filename, use the function FSCreateFileUnicode , or one of the corresponding parameter block calls, PBCreateFileUnicodeSync and PBCreateFileUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHCreateSync

Creates a new file. (Deprecated in OS X v10.4. Use PBCreateFileUnicodeSync instead.)

OSErr PBHCreateSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name for the new file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the parent directory of the new file.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

The PBHCreateSync function creates both the data and resource fork of the file the new file is unlocked and empty. The date and time of its creation and last modification are set to the current date and time. If the file created isn’t temporary (that is, if it will exist after the user quits the application), the application should call PBHSetFInfoSync after the call to PBHCreateSync to fill in the information needed by the Finder.

Files created using PBHCreateSync are not automatically opened. If you want to write data to the new file, you must first open the file using one of the file access functions, FSpOpenDF , HOpenDF , PBHOpenDFSync or PBHOpenDFAsync.

The resource fork of the new file exists but is empty. You’ll need to call one of the Resource Manager procedures HCreateResFile or FSpCreateResFile to create a resource map in the file before you can open it (by calling one of the Resource Manager functions HOpenResFile or FSpOpenResFile).

To create a file with a Unicode filename, use the function FSCreateFileUnicode , or one of the corresponding parameter block calls, PBCreateFileUnicodeSync and PBCreateFileUnicodeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHDeleteAsync

Deletes a file or directory. (Deprecated in OS X v10.4. Use PBDeleteObjectAsync instead.)

OSErr PBHDeleteAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. If you attempt to delete an open file or a non-empty directory, PBHDeleteAsync returns the result code fBsyErr. PBHDeleteAsync also returns fBsyErr if you attempt to delete a directory that has an open working directory associated with it.

ioNamePtr

On input, a pointer to the name of the file or directory to delete.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the parent directory of the file or directory to delete.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the specified target is a file, both the data and the resource fork of the file are deleted. In addition, if a file ID reference for the specified file exists, that file ID reference is also removed. A file must be closed before you can delete it. Similarly, you cannot delete a directory unless it’s empty.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHDeleteSync

Deletes a file or directory. (Deprecated in OS X v10.4. Use PBDeleteObjectSync instead.)

OSErr PBHDeleteSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” If you attempt to delete an open file or a non-empty directory, PBHDeleteSync returns the result code fBsyErr. PBHDeleteSync also returns fBsyErr if you attempt to delete a directory that has an open working directory associated with it.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file or directory to delete.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the parent directory of the file or directory to delete.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the specified target is a file, both the data and the resource fork of the file are deleted. In addition, if a file ID reference for the specified file exists, that file ID reference is also removed. A file must be closed before you can delete it. Similarly, you cannot delete a directory unless it’s empty.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetFInfoAsync

Obtains information about a file. (Deprecated in OS X v10.4. Use PBGetCatalogInfoAsync instead.)

OSErr PBHGetFInfoAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname. If the value of the ioFDirIndex field is negative or 0, PBHGetFInfoAsync returns information about the file in the volume specified by the reference number in the ioVRefNum field and having the name given here. On output, a pointer to the name of the file, if the file is open. If you do not wish the name returned, pass NULL here.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file, or 0 for the default volume.

ioFRefNum

On output, the reference number of the first access path found, if the file is open and if the ioFDirIndex field is negative or 0; if the ioFDirIndex field is positive...

ioFDirIndex

On input, a directory index. If this value is positive, the function returns information about the file having the directory index specified here, on the volume specified in the ioVRefNum field and in the directory specified in the ioDirID field. If this value is negative or 0, the function returns information about the file on the specified volume, having the name pointed to in the ioNamePtr field.

ioFlAttrib

On output, the file attributes. See “File Attribute Constants” for a description of the file attributes.

ioFlFndrInfo

On output, Finder information about the file. For a description of the FInfo structure, see the Finder Interface Reference .

ioDirID

On input, the parent directory ID of the file. On output, the file’s file ID.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

ioFlStBlk

On output, the first allocation block of the data fork.

ioFlLgLen

On output, the logical size (the logical end-of-file) of the file’s data fork, in bytes.

ioFlPyLen

On output, the physical size (the physical end-of-file) of the file’s data fork, in bytes.

ioFlRStBlk

On output, the first allocation block of the resource fork.

ioFlRLgLen

On output, the logical size of the file’s resource fork, in bytes.

ioFlRPyLen

On output, the physical size of the file’s resource fork, in bytes.

ioFlCrDat

On output, the date and time of the file’s creation.

ioFlMdDat

On output, the date and time of the file’s last modification.

You should call PBHGetFInfoAsync just before PBHSetFInfoAsync , so that the current information is present in the parameter block.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetFInfoSync

Obtains information about a file. (Deprecated in OS X v10.4. Use PBGetCatalogInfoSync instead.)

OSErr PBHGetFInfoSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. If the value of the ioFDirIndex field is negative or 0, PBHGetFInfoSync returns information about the file in the volume specified by the reference number in the ioVRefNum field and having the name given here. On output, a pointer to the name of the file, if the file is open. If you do not wish the name returned, pass NULL here.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file, or 0 for the default volume.

ioFRefNum

On output, the reference number of the first access path found, if the file is open and if the ioFDirIndex field is negative or 0; if the ioFDirIndex field is positive...

ioFDirIndex

On input, a directory index. If this value is positive, the function returns information about the file having the directory index specified here, on the volume specified in the ioVRefNum field and in the directory specified in the ioDirID field. If this value is negative or 0, the function returns information about the file on the specified volume, having the name pointed to in the ioNamePtr field.

ioFlAttrib

On output, the file attributes. See “File Attribute Constants” for a description of the file attributes.

ioFlFndrInfo

On output, Finder information about the file. For a description of the FInfo data type, see the Finder Interface Reference .

ioDirID

On input, the parent directory ID of the file. On output, the file’s file ID.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

ioFlStBlk

On output, the first allocation block of the data fork.

ioFlLgLen

On output, the logical size (the logical end-of-file) of the file’s data fork, in bytes.

ioFlPyLen

On output, the physical size (the physical end-of-file) of the file’s data fork, in bytes.

ioFlRStBlk

On output, the first allocation block of the resource fork.

ioFlRLgLen

On output, the logical size of the resource fork, in bytes.

ioFlRPyLen

On output, the physical size of the resource fork, in bytes.

ioFlCrDat

On output, the date and time of the file’s creation.

ioFlMdDat

On output, the date and time of the file’s last modification.

You should call PBHGetFInfoSync just before PBHSetFInfoSync , so that the current information is present in the parameter block.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetLogInInfoAsync

Determines the login method used to log on to a particular shared volume. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHGetLogInInfoAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the ObjParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname

ioVRefNum

On input, a volume specification for the shared volume. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioObjType

On output, the login method type. See “Authentication Method Constants” for the values that are recognized. Values in the range 7–127 are reserved for future use by Apple Computer, Inc. Values in the range 128–255 are available to your application as user-defined values.

ioObjNamePtr

On output, a pointer to the user name used to establish the session. The login user name is returned as a Pascal string. The maximum size of the user name is 31 characters.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetLogInInfoSync

Determines the login method used to log on to a particular shared volume. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHGetLogInInfoSync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVInfoAsync

Gets detailed information about a volume. (Deprecated in OS X v10.4. Use PBGetVolumeInfoAsync instead.)

OSErr PBHGetVInfoAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HVolumeParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a buffer. If you specify a negative number in the ioVolIndex field, this buffer should hold the name of the volume for which to return information. On output, a pointer to the volume’s name. You should pass a pointer to a Str31 value if you want the name returned. If you pass NULL, no volume name is returned.

ioVRefNum

On input, a volume specification for the volume for which to return information. If the ioVolIndex field is negative, the File Manager uses the value in the ioNamePtr field, along with the value specified in the ioVRefNum field, to determine the volume. If the value in ioVolIndex is 0, the File Manager attempts to access the volume using only the value in this field. On output, the volume reference number.

ioVolIndex

On input, an index used for indexing through all mounted volumes. If this value is positive, the File Manager uses it to find the volume for which to return information. For instance, if the value of ioVolIndex is 2, the File Manager attempts to access the second mounted volume in the VCB queue. If ioVolIndex is negative, the File Manager uses the values in the ioNamePtr and ioVRefNum fields to access the requested volume. If ioVolIndex is 0, the File Manager uses only the value in the ioVRefNum field.

ioVCrDate

On output, the date and time of the volume’s initialization.

ioVLsMod

On output, the date and time of the volume’s last modification.

ioVAtrb

On output, the volume attributes. See “Volume Information Attribute Constants” for a description of the volume attributes returned by this function.

ioVNmFls

On output, the number of files in the root directory of the volume. For performance reasons, the Carbon File Manager does not return the number of files in this field; instead, it sets ioVNmFls to 0.To determine the number of files in the root directory of a volume in Carbon, call PBGetCatInfoAsync for the root directory. The number of files in the root directory is returned in the ioDrNmFls field.

ioVBitMap

On output, the first block of the volume bitmap.

ioVAllocPtr

On output, the block at which the search for the next new file allocation should start.

ioVNmAlBlks

On output, the number of allocation blocks on the volume.

ioVAlBlkSiz

On output, the size of the allocation blocks.

ioVClpSiz

On output, the default clump size.

ioAlBlSt

On output, the first block in the volume block map.

ioVNxtCNID

On output, the next unused catalog node ID.

ioVFrBlk

On output, the number of unused allocation blocks.

ioVSigWord

On output, the volume signature. For HFS volumes, this is ‘BD’ for HFS Plus volumes, this is ‘H+’.

ioVDrvInfo

On output, the drive number. You can determine whether the given volume is online by inspecting the value of this field. For online volumes, the ioVDrvInfo field contains the drive number of the drive containing the specified volume and hence is always greater than 0. If the value returned in ioVDrvInfo is 0, the volume is either offline or ejected.

OS X does not support drive numbers; in OS X, the File Manager always returns a value of 1 in this field.

ioVDRefNum

On output, the driver reference number. You can determine whether the volume is offline or ejected by inspecting the value of this field. If the volume is offline, the value of ioVDRefNum is the negative of the drive number (which is cleared when the volume is placed offline; hence the ioVDrvInfo field for an offline volume is zero), and is a negative number. If the volume is ejected, the value of ioVDRefNum is the drive number itself, and thus is a positive number. For online volumes, ioVDRefNum contains a driver reference number; these numbers are always less than 0.

ioVFSID

On output, the file system handling this volume.

ioVBkUp

On output, the date and time of the volume’s last backup.

ioVSeqNum

Used internally.

ioVWrCnt

On output, the volume write count.

ioVFilCnt

On output, the number of files on the volume.

ioVDirCnt

On output, the number of directories on the volume.

ioVFndrInfo

On output, Finder information for the volume.

You can get information about all the online volumes by making repeated calls to PBHGetVInfoAsync, starting with the value of the ioVolIndex field set to 1 and incrementing that value until PBHGetVInfoAsync returns nsvErr.

If you need to obtain information about HFS Plus volumes, you should use the FSGetVolumeInfo function, or one of the corresponding parameter block calls, PBGetVolumeInfoSync and PBGetVolumeInfoAsync. The PBHGetVInfoAsync function is still supported for HFS Plus volumes, but there is additional information returned by the FSGetVolumeInfo function (such as the date and time that the volume was last checked for consistency).

Special Considerations

After an operation that changes the amount of free space on the volume—such as deleting a file—there may be a delay before a call to PBHGetVInfoAsync returns the updated amount. This is because the File Manager caches and periodically updates file system information, to reduce the number of calls made to retrieve the information from the file system. Currently, the File Manager updates its information every 15 seconds. This primarily affects NFS volumes. DOS, SMB, UFS and WebDAV volumes were also affected by this in previous versions of OS X, but behave correctly in OS X version 10.3 and later.

If the value of ioVolIndex is negative, the File Manager uses ioNamePtr and ioVRefNum in the standard way to determine the volume. However, because PBHGetVInfoAsync returns the volume name in the buffer whose address you passed in ioNamePtr, your input pathname will be modified. If you don't want your input pathname modified, make a copy of it and pass the copy to PBHGetVInfoAsync.

The volume name returned by PBHGetVInfoAsync is not a full pathname to the volume because it does not contain a colon.

For compatibility with older programs, some values returned by PBHGetVInfoAsync are not what is stored in the volume's Volume Control Block (VCB). Specifically:

  • ioVNmAlBlks and ioVFrBlk are pinned to values which, when multiplied by ioVAlBlkSiz, are always less than 2 Gigabytes.

  • ioVNmAlBlks may not include the allocation blocks used by the catalog and extents overflow files.

  • $4244 is returned in ioVSigWord for both HFS and HFS Plus volumes.

For unpinned total and free byte counts, and for the real ioVSigWord, use PBXGetVolInfoAsync instead of PBHGetVInfoAsync.

Version Notes

In non-Carbon applications, you may pass a working directory reference in the ioVRefNum field; if you pass a working directory reference in that field, the number of files and directories in the specified directory is returned in the ioVNmFls field.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVInfoSync

Gets detailed information about a volume. (Deprecated in OS X v10.4. Use PBGetVolumeInfoSync instead.)

OSErr PBHGetVInfoSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HVolumeParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a buffer. If you specify a negative number in the ioVolIndex field, this buffer should hold the name of the volume for which to return information. On output, a pointer to the volume’s name. You should pass a pointer to a Str31 value if you want the name returned. If you pass NULL, no volume name is returned.

ioVRefNum

On input, a volume reference number or drive number for the volume for which to return information; or 0 for the default volume. If the ioVolIndex field is negative, the File Manager uses the value in the ioNamePtr field, along with the value specified in the ioVRefNum field, to determine the volume. If the value in ioVolIndex is 0, the File Manager attempts to access the volume using only the value in this field. On output, the volume reference number.

ioVolIndex

On input, an index used for indexing through all mounted volumes. If this value is positive, the File Manager uses it to find the volume for which to return information. For instance, if the value of ioVolIndex is 2, the File Manager attempts to access the second mounted volume in the VCB queue. If ioVolIndex is negative, the File Manager uses the values in the ioNamePtr and ioVRefNum fields to access the requested volume. If ioVolIndex is 0, the File Manager uses only the value in the ioVRefNum field.

ioVCrDate

On output, the date and time of the volume’s initialization.

ioVLsMod

On output, the date and time of the volume’s last modification.

ioVAtrb

On output, the volume attributes. See “Volume Information Attribute Constants” for a description of the volume attributes returned by this function.

ioVNmFls

On output, the number of files in the root directory of the volume. For performance reasons, the Carbon File Manager does not return the number of files in this field; instead, it sets ioVNmFls to 0.To determine the number of files in the root directory of a volume in Carbon, call PBGetCatInfoSync for the root directory. The number of files in the root directory is returned in the ioDrNmFls field.

ioVBitMap

On output, the first block of the volume bitmap.

ioVAllocPtr

On output, the block at which the search for the next new file allocation should start.

ioVNmAlBlks

On output, the number of allocation blocks on the volume.

ioVAlBlkSiz

On output, the size of the allocation blocks.

ioVClpSiz

On output, the default clump size.

ioAlBlSt

On output, the first block in the volume block map.

ioVNxtCNID

On output, the next unused catalog node ID.

ioVFrBlk

On output, the number of unused allocation blocks.

ioVSigWord

On output, the volume signature. For HFS volumes, this is ‘BD’ for HFS Plus volumes, this is ‘H+’.

ioVDrvInfo

On output, the drive number. You can determine whether the given volume is online by inspecting the value of this field. For online volumes, the ioVDrvInfo field contains the drive number of the drive containing the specified volume and hence is always greater than 0. If the value returned in ioVDrvInfo is 0, the volume is either offline or ejected.

OS X does not support drive numbers; in OS X, the File Manager always returns a value of 1 in this field.

ioVDRefNum

On output, the driver reference number. You can determine whether the volume is offline or ejected by inspecting the value of this field. If the volume is offline, the value of ioVDRefNum is the negative of the drive number (which is cleared when the volume is placed offline; hence the ioVDrvInfo field for an offline volume is zero), and is a negative number. If the volume is ejected, the value of ioVDRefNum is the drive number itself, and thus is a positive number. For online volumes, ioVDRefNum contains a driver reference number; these numbers are always less than 0.

ioVFSID

On output, the file system handling this volume.

ioVBkUp

On output, the date and time of the volume’s last backup.

ioVSeqNum

Used internally.

ioVWrCnt

On output, the volume write count.

ioVFilCnt

On output, the number of files on the volume.

ioVDirCnt

On output, the number of directories on the volume.

ioVFndrInfo

On output, Finder information for the volume.

You can get information about all the online volumes by making repeated calls to PBHGetVInfoSync, starting with the value of the ioVolIndex field set to 1 and incrementing that value until PBHGetVInfoSync returns nsvErr.

If you need to obtain information about HFS Plus volumes, you should use the FSGetVolumeInfo function, or one of the corresponding parameter block calls, PBGetVolumeInfoSync and PBGetVolumeInfoAsync. The PBHGetVInfoSync function is still supported for HFS Plus volumes, but there is additional information returned by the FSGetVolumeInfo function (such as the date and time that the volume was last checked for consistency).

Special Considerations

After an operation that changes the amount of free space on the volume—such as deleting a file—there may be a delay before a call to PBHGetVInfoSync returns the updated amount. This is because the File Manager caches and periodically updates file system information, to reduce the number of calls made to retrieve the information from the file system. Currently, the File Manager updates its information every 15 seconds. This primarily affects NFS volumes. DOS, SMB, UFS and WebDAV volumes were also affected by this in previous versions of OS X, but behave correctly in OS X version 10.3 and later.

If the value of ioVolIndex is negative, the File Manager uses ioNamePtr and ioVRefNum in the standard way to determine the volume. However, because PBHGetVInfoSync returns the volume name in the buffer whose address you passed in ioNamePtr, your input pathname will be modified. If you don't want your input pathname modified, make a copy of it and pass the copy to PBHGetVInfoSync.

The volume name returned by PBHGetVInfoSync is not a full pathname to the volume because it does not contain a colon.

For compatibility with older programs, some values returned by PBHGetVInfoSync are not what is stored in the volume's Volume Control Block (VCB). Specifically:

  • ioVNmAlBlks and ioVFrBlk are pinned to values which, when multiplied by ioVAlBlkSiz, are always less than 2 Gigabytes.

  • ioVNmAlBlks may not include the allocation blocks used by the catalog and extents overflow files.

  • $4244 is returned in ioVSigWord for both HFS and HFS Plus volumes.

For unpinned total and free byte counts, and for the real ioVSigWord, use PBXGetVolInfoSync instead of PBHGetVInfoSync.

Version Notes

In non-Carbon applications, you may pass a working directory reference in the ioVRefNum field; if you pass a working directory reference in that field, the number of files and directories in the specified directory is returned in the ioVNmFls field.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVolAsync

Determines the default volume and default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHGetVolAsync (
   WDPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a working directory parameter block. See WDPBRec for a description of the WDPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBHGetVolAsync function returns the default volume and directory last set by a call to HSetVol or PBHSetVolSync. The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On output, a pointer to the default volume’s name. You should pass a pointer to a Str31 value if you want that name returned. If you pass NULL in this field, no volume name is returned.

ioVRefNum

On output, the volume reference number of the default volume.

ioWDProcID

On output, the working directory user identifier.

ioWDVRefNum

On output, the volume reference number of the volume on which the default directory exists.

ioWDDirID

On output, the directory ID of the default directory.

Version Notes

When CarbonLib is not present, the PBHGetVolAsync function returns a working directory reference number in the ioVRefNum parameter if the previous call to HSetVol (or one of the corresponding parameter block calls) passed in a working directory reference number.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVolSync

Determines the default volume and default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHGetVolSync (
   WDPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a working directory parameter block. See WDPBRec for a description of the WDPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBHGetVolSync function returns the default volume and directory last set by a call to HSetVol or PBHSetVolSync. The relevant fields of the parameter block are:

ioNamePtr

On output, a pointer to the default volume’s name. Pass a pointer to a Str31 value if you want that name returned. If you pass NULL in this field, no volume name is returned.

ioVRefNum

On output, the volume reference number of the default volume.

ioWDProcID

On output, the working directory user identifier.

ioWDVRefNum

On output, the volume reference number of the volume on which the default directory exists.

ioWDDirID

On output, the directory ID of the default directory.

Version Notes

When CarbonLib is not present, the PBHGetVolSync function returns a working directory reference number in the ioVRefNum parameter if the previous call to HSetVol (or one of the corresponding parameter block calls) passed in a working directory reference number.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHMoveRenameAsync

Moves a file or directory and optionally renames it. (Deprecated in OS X v10.4. Use FSMoveObjectAsync instead.)

OSErr PBHMoveRenameAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a CopyParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBHMoveRenameAsync function allows you to move (not copy) a file or directory. The source and destination pathnames must point to the same file server volume. This function is especially useful when you want to copy or move files located on a remote volume, because it allows you to forgo transmitting large amounts of data across a network. This function is used internally by the Finder; most applications do not need to use it.

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the pathname for the source file or directory.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the source file or directory. Pass 0 for the default volume.

ioNewName

On input, a pointer to the destination pathname. If ioNewName is NULL, the destination directory is the directory having the ID specified in the ioNewDirID field. If ioNewName is not NULL, the destination directory is the directory having the partial pathname pointed to by ioNewName in the directory having ID ioNewDirID on the specified volume.

ioCopyName

On input, a pointer to the file’s new name. The string pointed to by this field must be a filename, not a partial pathname. If you do not wish to rename the file, pass NULL in this field.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, the parent directory ID of the destination directory.

ioDirID

On input, the directory ID of the source directory.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHMoveRenameSync

Moves a file or directory and optionally renames it. (Deprecated in OS X v10.4. Use FSMoveObjectSync instead.)

OSErr PBHMoveRenameSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a CopyParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBHMoveRenameSync function allows you to move (not copy) a file or directory. The source and destination pathnames must point to the same file server volume. This function is especially useful when you want to copy or move files located on a remote volume, because it allows you to forgo transmitting large amounts of data across a network. This function is used internally by the Finder; most applications do not need to use it.

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the pathname for the source file or directory.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the source file or directory. Pass 0 for the default volume.

ioNewName

On input, a pointer to the destination pathname. If ioNewName is NULL, the destination directory is the directory having the ID specified in the ioNewDirID field. If ioNewName is not NULL, the destination directory is the directory having the partial pathname pointed to by ioNewName in the directory having ID ioNewDirID on the specified volume.

ioCopyName

On input, a pointer to the file’s new name. The string pointed to by this field must be a filename, not a partial pathname. If you do not wish to rename the file, pass NULL in this field.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, the parent directory ID of the destination directory.

ioDirID

On input, the directory ID of the source directory.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenAsync

Opens the data fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkAsync instead.)

OSErr PBHOpenAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic HFS parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. If you attempt to open a locked file for writing, PBHOpenAsync returns the result code permErr. If you request exclusive read/write permission but another access path is already open, PBHOpenAsync returns the reference number of the existing access path in ioRefNum and opWrErr as its function result.

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, a file reference number for accessing the open data fork. If you request exclusive read/write permission but another access path is already open, PBHOpenAsync returns the reference number of the existing access path. You should not use this reference number unless your application originally opened the file.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.” You can open a path for writing even if it accesses a file on a locked volume, and no error is returned until a PBWriteAsync, PBSetEOFAsync , or PBAllocateAsync call is made.

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If you use PBHOpenAsync to try to open a file whose name begins with a period, you might mistakenly open a driver instead; subsequent attempts to write data might corrupt data on the target device. To avoid these problems, you should always use PBHOpenDFAsync instead of PBHOpenAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenDFAsync

Opens the data fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkAsync instead.)

OSErr PBHOpenDFAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

You should use PBHOpenDFAsync instead of the PBHOpenAsync function; PBHOpenDFAsync allows you to safely open a file whose name begins with a period (.).

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. If you attempt to open a locked file for writing, PBHOpenDFAsync returns the result code permErr. If you request exclusive read/write permission but another access path is already open, PBHOpenDFAsync returns the reference number of the existing access path in ioRefNum and opWrErr as its function result.

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, the file reference number for accessing the open data fork. If you request exclusive read/write permission but another access path is already open, PBHOpenDFAsync returns the reference number of the existing access path. You should not use this reference number unless your application originally opened the file.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.” You can open a path for writing even if it accesses a file on a locked volume, and no error is returned until a PBWriteAsync, PBSetEOFAsync , or PBAllocateAsync call is made.

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the PBHOpenDFAsync function, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenDFSync

Opens the data fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkSync instead.)

OSErr PBHOpenDFSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” . If you attempt to open a locked file for writing, PBHOpenDFSync returns the result code permErr. If you request exclusive read/write permission but another access path is already open, PBHOpenDFSync returns the reference number of the existing access path in ioRefNum and opWrErr as its function result.

Discussion

You should use PBHOpenDFSync instead of the PBHOpenSync function; PBHOpenDFSync allows you to safely open a file whose name begins with a period (.).

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, the file reference number for accessing the open data fork. If you request exclusive read/write permission but another access path is already open, PBHOpenDFSync returns the reference number of the existing access path. You should not use this reference number unless your application originally opened the file.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.” You can open a path for writing even if it accesses a file on a locked volume, and no error is returned until a PBWriteSync, PBSetEOFSync , or PBAllocateSync call is made.

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the PBHOpenDFSync function, you will receive an error message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenRFAsync

Opens the resource fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkAsync instead.)

OSErr PBHOpenRFAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. On some file systems, PBHOpenRFAsync will return the error eofErr if you try to open the resource fork of a file for which no resource fork exists with read-only access.

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, a file reference number for accessing the open resource fork.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.”

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the PBHOpenRFAsync function, you will receive an error message.

Special Considerations

Generally your application should use Resource Manager functions rather than File Manager functions to access a file’s resource fork. The PBHOpenRFAsync function does not read the resource map into memory and is generally useful only for applications (such as utilities that copy files) that need block-level access to a resource fork.

You should not use the resource fork of a file to hold non-resource data. Many parts of the system software assume that a resource fork always contains resource data.

Because there is no support for locking and unlocking file ranges in OS X, regardless of whether File Sharing is enabled, you cannot open more than one path to a resource fork with read/ write permission. If you try to open a more than one path to a file's resource fork with fsRdWrShPerm permission, only the first attempt will succeed. Subsequent attempts will return an invalid reference number and the ResError function will return the error opWrErr.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenRFSync

Opens the resource fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkSync instead.)

OSErr PBHOpenRFSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” On some file systems, PBHOpenRFSync will return the error eofErr if you try to open the resource fork of a file for which no resource fork exists with read-only access.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, a file reference number for accessing the open resource fork.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.”

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Note that if you wish to access named forks other than the data and resource forks, or forks larger than 2GB, you will need to use the FSOpenFork function, or one of its corresponding parameter block calls, PBOpenForkSync or PBOpenForkAsync. If you try to open a fork larger than 2GB with the PBOpenRFSync function, you will receive an error message.

Special Considerations

Generally your application should use Resource Manager functions rather than File Manager functions to access a file’s resource fork. The PBHOpenRFSync function does not read the resource map into memory and is generally useful only for applications (such as utilities that copy files) that need block-level access to a resource fork.

You should not use the resource fork of a file to hold non-resource data. Many parts of the system software assume that a resource fork always contains resource data.

Because there is no support for locking and unlocking file ranges on local disks in OS X, regardless of whether File Sharing is enabled, you cannot open more than one path to a resource fork with read/ write permission. If you try to open a more than one path to a file's resource fork with fsRdWrShPerm permission, only the first attempt will succeed. Subsequent attempts will return an invalid reference number and the ResError function will return the error opWrErr.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenSync

Opens the data fork of a file. (Deprecated in OS X v10.4. Use PBOpenForkSync instead.)

OSErr PBHOpenSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” If you attempt to open a locked file for writing, PBHOpenSync returns the result code permErr. If you request exclusive read/write permission but another access path is already open, PBHOpenSync returns the reference number of the existing access path in ioRefNum and opWrErr as its function result.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioRefNum

On output, a file reference number for accessing the open data fork. If you request exclusive read/write permission but another access path is already open, PBHOpenSync returns the reference number of the existing access path. You should not use this reference number unless your application originally opened the file.

ioPermssn

On input, a constant specifying the type of access with which to open the fork. For a description of the types of access you can request, see “File Access Permission Constants.” You can open a path for writing even if it accesses a file on a locked volume, and no error is returned until a PBWriteSync, PBSetEOFSync , or PBAllocateSync call is made.

ioDirID

On input, the directory ID of the file’s parent directory.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If you use PBHOpenSync to try to open a file whose name begins with a period, you might mistakenly open a driver instead; subsequent attempts to write data might corrupt data on the target device. To avoid these problems, you should always use PBHOpenDFSync instead of PBHOpenSync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHRenameAsync

Renames a file, directory, or volume. (Deprecated in OS X v10.4. Use PBRenameUnicodeAsync instead.)

OSErr PBHRenameAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the existing filename, directory name, or volume name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioMisc

On input, a pointer to the new name for the file, directory or volume.

ioDirID

On input, the parent directory ID of the file or directory to rename.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Given a pointer to the name of a file or directory in the ioNamePtr field, PBHRenameAsync changes it to the name pointed to in the ioMisc field. Given a pointer to a volume name in ioNamePtr or a volume reference number in ioVRefNum, the function changes the name of the volume to the name pointed to in ioMisc.

If a file ID reference exists for the file being renamed, the file ID remains with the file.

To rename a file or directory using a long Unicode name, use the FSRenameUnicode function or one of the corresponding parameter block calls, PBRenameUnicodeSync and PBRenameUnicodeAsync.

Special Considerations

You cannot use PBHRenameAsync to change the directory in which a file is located. To move a file or directory, use the FSpCatMove, PBCatMoveSync, or PBCatMoveAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHRenameSync

Renames a file, directory, or volume. (Deprecated in OS X v10.4. Use PBRenameUnicodeSync instead.)

OSErr PBHRenameSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the existing filename, directory name, or volume name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioMisc

On input, a pointer to the new name for the file, directory or volume.

ioDirID

On input, the parent directory ID of the file or directory to rename.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

Given a pointer to the name of a file or directory in the ioNamePtr field, PBHRenameSync changes it to the name pointed to in the ioMisc field. Given a pointer to a volume name in ioNamePtr or a volume reference number in ioVRefNum, the function changes the name of the volume to the name pointed to in ioMisc.

If a file ID reference exists for the file being renamed, the file ID remains with the file.

To rename a file or directory using a long Unicode name, use the FSRenameUnicode function or one of the corresponding parameter block calls, PBRenameUnicodeSync and PBRenameUnicodeAsync.

Special Considerations

You cannot use PBHRenameSync to change the directory in which a file is located. To move a file or directory, use the FSpCatMove, PBCatMoveSync, or PBCatMoveAsync functions.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHRstFLockAsync

Unlocks a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoAsync instead.)

OSErr PBHRstFLockAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name for the file or directory o unlock.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID of the file or directory to unlock.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use PBHRstFLockAsync to unlock a directory. Otherwise, you can only use this function to unlock a file.

Access paths currently in use aren’t affected by this function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHRstFLockSync

Unlocks a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoSync instead.)

OSErr PBHRstFLockSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name for the file or directory to unlock.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID of the file or directory to unlock.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use PBHRstFLockSync to unlock a directory. Otherwise, you can only use this function to unlock a file.

Access paths currently in use aren’t affected by this function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetFInfoAsync

Sets information for a file. (Deprecated in OS X v10.4. Use PBSetCatalogInfoAsync instead.)

OSErr PBHSetFInfoAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, the volume reference number or drive number for the volume containing the file; or 0 for the default volume.

ioFlFndrInfo

On input, Finder information for the file. For a description of the FInfo data type, see the Finder Interface Reference .

ioDirID

On input, the parent directory ID for the file.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

ioFlCrDat

On input, the date and time of the file’s creation.

ioFlMdDat

On input, the date and time of the file’s last modification.

You should call the PBHGetFInfoAsync function just before calling PBHSetFInfoAsync, so that the current information is present in the parameter block.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetFInfoSync

Sets information for a file. (Deprecated in OS X v10.4. Use PBSetCatalogInfoSync instead.)

OSErr PBHSetFInfoSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file.

ioVRefNum

On input, the volume reference number or drive number for the volume containing the file; or 0 for the default volume.

ioFlFndrInfo

On input, Finder information for the file. For a description of the FInfo data type, see the Finder Interface Reference .

ioDirID

On input, the parent directory ID of the file.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

ioFlCrDat

On input, the date and time of the file’s creation.

ioFlMdDat

On input, the date and time of the file’s last modification.

You should call the PBHGetFInfoSync function just before calling PBHSetFInfoSync, so that the current information is present in the parameter block.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetFLockAsync

Locks a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoAsync instead.)

OSErr PBHSetFLockAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a name for the file or directory to lock.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID of the file or directory to lock.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use PBHSetFLockAsync to lock a directory. Otherwise, you can only use this function to lock a file.

After you lock a file, all new access paths to that file are read-only. Access paths currently in use aren’t affected.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetFLockSync

Locks a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoSync instead.)

OSErr PBHSetFLockSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HFileParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a name for the file or directory to lock.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDirID

On input, the parent directory ID of the file or directory to lock.

ioFVersNum

On input, this field should be initialized to zero; if this field is not zero, the call will fall through to the now-obsolete Macintosh File System (MFS) code if the volume accessed is an MFS volume.

If the PBHGetVolParmsSync or PBHGetVolParmsAsync function indicates that the volume supports folder locking (that is, the bHasFolderLock bit of the vMAttrib field is set), you can use PBHSetFLockSync to lock a directory. Otherwise, you can only use this function to lock a file.

After you lock a file, all new access paths to that file are read-only. Access paths currently in use aren’t affected.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetVolAsync

Sets the default volume and the default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHSetVolAsync (
   WDPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a working directory parameter block. See WDPBRec for a description of the WDPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname. If this field specifies a full pathname, the default volume is set to the volume whose name is contained in that pathname. (A full pathname overrides the ioVRefNum field.)If this field contains a partial pathname and the ioVRefNum field specifies a volume reference number, then the default directory is set to the directory having the partial pathname specified here, in the directory given in the ioWDDirID field. If this field is NULL, then the default directory is set to the directory having the ID specified in the ioWDDirID field.

ioVRefNum

On input, a volume reference number for the default volume. This field is ignored if the ioNamePtr field specifies a full pathname.

ioWDDirID

On input, a directory ID. If the ioVRefNum field contains a volume reference number and ioNamePtr contains a partial pathname, this field contains the directory ID of the directory containing the default directory. If ioNamePtr is NULL, this field contains the directory ID of the default directory.

Both the default volume and the default directory are used in calls made with no volume name, a volume reference number of 0, and a directory ID of 0.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetVolSync

Sets the default volume and the default directory. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBHSetVolSync (
   WDPBPtr paramBlock
);
Parameters
paramBlock

A pointer to a working directory parameter block. See WDPBRec for a description of the WDPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. If this field specifies a full pathname, the default volume is set to the volume whose name is contained in that pathname. (A full pathname overrides the ioVRefNum field.)If this field contains a partial pathname and the ioVRefNum field specifies a volume reference number, then the default directory is set to the directory having the partial pathname specified here, in the directory given in the ioWDDirID field. If this field is NULL, then the default directory is set to the directory having the ID specified in the ioWDDirID field.

ioVRefNum

On input, the volume reference number for the default volume. This field is ignored if the ioNamePtr field specifies a full pathname.

ioWDDirID

On input, a directory ID. If the ioVRefNum field contains a volume reference number and ioNamePtr contains a partial pathname, this field contains the directory ID of the directory containing the default directory. If ioNamePtr is NULL, this field contains the directory ID of the default directory.

Both the default volume and the default directory are used in calls made with no volume name, a volume reference number of 0, and a directory ID of 0.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBLockRangeAsync

Locks a portion of a file. (Deprecated in OS X v10.4. Use PBXLockRangeAsync instead.)

OSErr PBLockRangeAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. If you call PBLockRangeAsync on a file system that does not implement it—for example, SMB—PBLockRangeAsync returns noErr and does nothing.

ioRefNum

On input, the file reference number of the file owning the range to lock.

ioReqCount

On input, the number of bytes in the range. Set ioReqCount to –1 to lock the maximum number of bytes from the position specified in the ioPosOffset field.

ioPosMode

On input, a constant specifying the base location for the start of the locked range. See “Position Mode Constants” for more information on the constants you can use to specify the base location.

You should not use the fsFromLEOF constant when locking a file range. PBLockRangeAsync does not return the start of the locked range; thus, there is no way to determine what range was actually locked when you specify fsFromLEOF.

ioPosOffset

On input, the offset from the base location specified in the ioPosMode field for the start of the locked range.

The PBLockRangeAsync function locks a portion of a file that was opened with shared read/write permission. The beginning of the range to be locked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be locked is determined by the beginning of the range and the ioReqCount field. For example, to lock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0.

The PBLockRangeAsync function uses the same parameters as both PBReadAsync and PBWriteAsync; by calling it immediately before PBReadAsync, you can use the information in the parameter block for the PBReadAsync call.

When you’re finished with the data (typically after a call to PBWriteSync), you can call PBUnlockRangeAsync to free that portion of the file for subsequent read and write calls. Closing a file also releases all locked ranges in that file.

Special Considerations

The PBLockRangeAsync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a sharable local volume. To check whether file sharing is currently on, check that the bHasPersonalAccessPrivileges bit in the vMAttrib field of the GetVolParmsInfoBuffer returned by the PBHGetVolParmsSync function is set.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBLockRangeSync

Locks a portion of a file. (Deprecated in OS X v10.4. Use PBXLockRangeSync or FSLockRange instead.)

OSErr PBLockRangeSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” If you call PBLockRangeSync on a file system that does not implement it—for example, SMB—PBLockRangeSync returns noErr and does nothing.

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, the file reference number of the file owning the range to lock.

ioReqCount

On input, the number of bytes in the range. Set ioReqCount to –1 to lock the maximum number of bytes from the position specified in the ioPosOffset field.

ioPosMode

On input, a constant specifying the base location for the start of the locked range. See “Position Mode Constants” for more information about the constants you can use to specify the base location.

You should not use the fsFromLEOF constant when locking a file range. PBLockRangeSync does not return the start of the locked range; thus, there is no way to determine what range was actually locked when you specify fsFromLEOF.

ioPosOffset

On input, the offset from the base location specified in the ioPosMode field for the start of the locked range.

The PBLockRangeSync function locks a portion of a file that was opened with shared read/write permission. The beginning of the range to be locked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be locked is determined by the beginning of the range and the ioReqCount field. For example, to lock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0.

The PBLockRangeSync function uses the same parameters as both PBReadSync and PBWriteSync; by calling it immediately before PBReadSync, you can use the information in the parameter block for the PBReadSync call.

When you’re finished with the data (typically after a call to PBWriteSync), you can call PBUnlockRangeSync to free that portion of the file for subsequent read and write calls. Closing a file also releases all locked ranges in that file.

Special Considerations

The PBLockRangeSync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a sharable local volume. To check whether file sharing is currently on, check that the bHasPersonalAccessPrivileges bit in the vMAttrib field of the GetVolParmsInfoBuffer returned by the PBHGetVolParmsSync function is set.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBMakeFSSpecAsync

Creates an FSSpec structure for a file or directory. (Deprecated in OS X v10.4. Use PBMakeFSRefUnicodeAsync instead.)

OSErr PBMakeFSSpecAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

If the specified volume is mounted and the specified parent directory exists, but the target file or directory doesn’t exist in that location, PBMakeFSSpecAsync fills in the structure and returns fnfErr instead of noErr. The structure is valid, but it describes a target that doesn’t exist. You can use the structure for another operation, such as creating a file.

PBMakeFSSpecAsync can return a number of different File Manager error codes. When PBMakeFSSpecAsync returns any result other than noErr or fnfErr, all fields of the resulting FSSpec structure are set to 0.

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. When PBMakeFSSpecAsync returns any result other than noErr or fnfErr, all fields of the resulting FSSpec structure are set to 0. See “File Manager Result Codes”.

ioNamePtr

On input, a pointer to a full or partial pathname specifying the file or directory for which to create an FSSpec. If the ioNamePtr field specifies a full pathname, PBMakeFSSpecAsync ignores both the ioVRefNum and ioDirID fields. A partial pathname might identify only the final target, or it might include one or more parent directory names. If ioNamePtr specifies a partial pathname, then ioVRefNum, ioDirID, or both must be valid.

ioVRefNum

On input, a volume specification for the volume containing the file or directory. This field can contain a volume reference number, a drive number, or 0 to specify the default volume.

ioMisc

On input, a pointer to an FSSpec structure. Given a complete specification for a file or directory, the PBMakeFSSpecAsync function fills in this FSSpec structure to identify the file or directory. On output, this field points to the initialized FSSpec. The file system specification structure that you pass in this field should not share storage space with the input pathname; the name field may be initialized to the empty string before the pathname has been processed. For example, ioNamePtr should not refer to the name field of the output file system specification.

ioDirID

On input, a directory ID. This field usually specifies the parent directory ID of the target object. If the directory is sufficiently specified by the ioNamePtr field, the ioDirID field can be set to 0. If the ioNamePtr field contains an empty string, PBMakeFSSpecAsync creates an FSSpec structure for the directory specified by the ioDirID field.

If the specified volume is mounted and the specified parent directory exists, but the target file or directory doesn’t exist in that location, PBMakeFSSpecAsync fills in the structure and returns fnfErr instead of noErr. The structure is valid, but it describes a target that doesn’t exist. You can use the structure for another operation, such as creating a file.

Carbon Porting Notes

Non-Carbon applications can also specify a working directory reference number in the ioVRefNum field. However, because working directories are not supported in Carbon, you cannot specify a working directory reference number if you wish your application to be Carbon-compatible.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBMakeFSSpecSync

Creates an FSSpec structure for a file or directory. (Deprecated in OS X v10.4. Use PBMakeFSRefUnicodeSync instead.)

OSErr PBMakeFSSpecSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” When PBMakeFSSpecSync returns any result other than noErr or fnfErr, all fields of the resulting FSSpec structure are set to 0.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a full or partial pathname specifying the file or directory for which to create an FSSpec. If the ioNamePtr field specifies a full pathname, PBMakeFSSpecSync ignores both the ioVRefNum and ioDirID fields. A partial pathname might identify only the final target, or it might include one or more parent directory names. If ioNamePtr specifies a partial pathname, then ioVRefNum, ioDirID, or both must be valid.

ioVRefNum

On input, a volume specification for the volume containing the file or directory. This field can contain a volume reference number, a drive number, or 0 to specify the default volume.

ioMisc

On input, a pointer to an FSSpec structure. Given a complete specification for a file or directory, the PBMakeFSSpecSync function fills in this FSSpec structure to identify the file or directory. On output, this field points to the initialized FSSpec. The file system specification structure that you pass in this field should not share storage space with the input pathname; the name field may be initialized to the empty string before the pathname has been processed. For example, ioNamePtr should not refer to the name field of the output file system specification.

ioDirID

On input, a directory ID. This field usually specifies the parent directory ID of the target object. If the directory is sufficiently specified by the ioNamePtr field, the ioDirID field can be set to 0. If the ioNamePtr field contains an empty string, PBMakeFSSpecSync creates an FSSpec structure for the directory specified by the ioDirID field.

If the specified volume is mounted and the specified parent directory exists, but the target file or directory doesn’t exist in that location, PBMakeFSSpecSync fills in the structure and returns fnfErr instead of noErr. The structure is valid, but it describes a target that doesn’t exist. You can use the structure for another operation, such as creating a file.

Carbon Porting Notes

Non-Carbon applications can also specify a working directory reference number in the ioVRefNum field. However, because working directories are not supported in Carbon, you cannot specify a working directory reference number if you wish your application to be Carbon-compatible.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetCatInfoAsync

Modifies catalog information for a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoAsync instead.)

OSErr PBSetCatInfoAsync (
   CInfoPBPtr paramBlock
);
Parameters
paramBlock

A pointer to an HFS catalog information parameter block. See CInfoPBRec for a description of the CInfoPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBSetCatInfoAsync function sets information about a file or directory. When used to set information about a file, it works much as PBHSetFInfoAsync does, but lets you set some additional information.

If the object is a file, the relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFlFndrInfo

On input, Finder information for the file.

ioDirID

On input, the parent directory ID of the file.

ioFlCrDat

On input, the date and time of the file’s creation.

ioFlMdDat

On input, the date and time of the file’s last modification.

ioFlBkDat

On input, the date and time of the file’s last backup.

ioFlXFndrInfo

On input, extended Finder information.

If the object is a directory, the relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDrUsrWds

On input, information used by the Finder.

ioDrDirID

On input, the directory ID.

ioDrCrDat

On input, the date and time of the directory’s creation.

ioDrMdDat

On input, the date and time of the directory’s last modification.

ioDrBkDat

On input, the date and time of the directory’s last backup.

ioDrFndrInfo

On input, additional information used by the Finder.

To modify the catalog information for a named fork other than the data and resource fork, or to modify other catalog information maintained on HFS Plus volumes that is not modifiable through PBSetCatInfoAsync, use one of the functions, FSSetCatalogInfo , PBSetCatalogInfoSync , or PBSetCatalogInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetCatInfoSync

Modifies catalog information for a file or directory. (Deprecated in OS X v10.4. Use PBSetCatalogInfoSync instead.)

OSErr PBSetCatInfoSync (
   CInfoPBPtr paramBlock
);
Parameters
paramBlock

A pointer to an HFS catalog information parameter block. See CInfoPBRec for a description of the CInfoPBRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The PBSetCatInfoSync function sets information about a file or directory. When used to set information about a file, it works much as PBHSetFInfoSync does, but lets you set some additional information.

If the object is a file, the relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioFlFndrInfo

On input, Finder information for the file.

ioDirID

On input, the parent directory ID of the file.

ioFlCrDat

On input, the date and time of the file’s creation.

ioFlMdDat

On input, the date and time of the file’s last modification.

ioFlBkDat

On input, the date and time of the file’s last backup.

ioFlXFndrInfo

On input, extended Finder information.

If the object is a directory, the relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

ioDrUsrWds

On input, information used by the Finder.

ioDrDirID

On input, the directory ID.

ioDrCrDat

On input, the date and time of the directory’s creation.

ioDrMdDat

On input, the date and time of the directory’s last modification.

ioDrBkDat

On input, the date and time of the directory’s last backup.

ioDrFndrInfo

On input, additional information used by the Finder.

To modify the catalog information for a named fork other than the data and resource fork, or to modify other catalog information maintained on HFS Plus volumes that is not modifiable through PBSetCatInfoSync, use one of the functions, FSSetCatalogInfo , PBSetCatalogInfoSync , or PBSetCatalogInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetEOFAsync

Sets the logical size of an open file. (Deprecated in OS X v10.4. Use PBSetForkSizeAsync instead.)

OSErr PBSetEOFAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the open file.

ioMisc

On input, the new logical size (the logical end-of-file) of the given file. Because the ioMisc field is of type Ptr, you must coerce the desired value from a long integer to type Ptr. If the value of the ioMisc field is 0, all space occupied by the file on the volume is released. The file still exists, but it contains 0 bytes. Setting a file fork’s end-of-file to 0 is therefore not the same as deleting the file, which removes both file forks at once.

If you attempt to set the logical end-of-file beyond the current physical end-of-file, another allocation block is added to the file if there isn’t enough space on the volume, no change is made and PBSetEOFAsync returns dskFulErr as its function result.

To ensure that your changes to the file are written to disk, call one of the functions, FlushVol , PBFlushVolSync , or PBFlushVolAsync. To set the size of a named fork other than the data and resource forks, or to grow the size of a file beyond 2GB, you must use the FSSetForkSize function, or one of the corresponding parameter block calls, PBSetForkSizeSync and PBSetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetEOFSync

Sets the logical size of an open file. (Deprecated in OS X v10.4. Use PBSetForkSizeSync instead.)

OSErr PBSetEOFSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for the open file.

ioMisc

On input, the new logical size (the logical end-of-file) of the given file. Because the ioMisc field is of type Ptr, you must coerce the desired value from a long integer to type Ptr. If the value of the ioMisc field is 0, all space occupied by the file on the volume is released. The file still exists, but it contains 0 bytes. Setting a file fork’s end-of-file to 0 is therefore not the same as deleting the file, which removes both file forks at once.

If you attempt to set the logical end-of-file beyond the current physical end-of-file, another allocation block is added to the file if there isn’t enough space on the volume, no change is made and PBSetEOFSync returns dskFulErr as its function result.

To ensure that your changes to the file are written to disk, call one of the functions, FlushVol , PBFlushVolSync , or PBFlushVolAsync. To set the size of a named fork other than the data and resource forks, or to grow the size of a file beyond 2GB, you must use the FSSetForkSize function, or one of the corresponding parameter block calls, PBSetForkSizeSync and PBSetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetForeignPrivsAsync

Changes the native access-control information for a file or directory stored on a volume managed by a foreign file system. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBSetForeignPrivsAsync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetForeignPrivsSync

Changes the native access-control information for a file or directory stored on a volume managed by a foreign file system. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBSetForeignPrivsSync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetFPosAsync

Sets the position of the file mark. (Deprecated in OS X v10.4. Use PBSetForkPositionAsync instead.)

OSErr PBSetFPosAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioRefNum

On input, the file reference number for an open file.

ioPosMode

On input, a constant indicating how to position the mark; this field must contain one of the values described in “Position Mode Constants.”

ioPosOffset

On input, the offset from the base location specified by the ioPosMode field for the file mark. If you specify fsAtMark in the ioPosMode field, the mark is left wherever it’s currently positioned and the value in the ioPosOffset field is ignored. If you specify fsFromLEOF, the value in ioPosOffset must be less than or equal to 0. On output, the position at which the mark was actually set.

The PBSetFPosAsync function sets the mark of the specified file to the position specified by the ioPosMode and ioPosOffset fields. If you try to set the mark past the logical end-of-file, PBSetFPosAsync moves the mark to the end-of-file and returns eofErr as its function result.

To set the file mark position for a named fork other than the data and resource forks, or to position the file mark at a point more than 2GB into the file, use the FSSetForkPosition function, or one of the corresponding parameter block calls, PBSetForkPositionSync and PBSetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetFPosSync

Sets the position of the file mark. (Deprecated in OS X v10.4. Use PBSetForkPositionSync instead.)

OSErr PBSetFPosSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, the file reference number for an open file.

ioPosMode

On input, a constant indicating how to position the file mark; this field must contain one of the values described in “Position Mode Constants.”

ioPosOffset

On input, the offset from the base location specified by the ioPosMode field for the file mark. If you specify fsAtMark in the ioPosMode field, the mark is left wherever it’s currently positioned and the value in the ioPosOffset field is ignored. If you specify fsFromLEOF, the value in ioPosOffset must be less than or equal to 0. On output, the position at which the mark was actually set.

The PBSetFPosSync function sets the mark of the specified file to the position specified by the ioPosMode and ioPosOffset fields. If you try to set the mark past the logical end-of-file, PBSetFPosSync moves the mark to the end-of-file and returns eofErr as its function result.

To set the file mark position for a named fork other than the data and resource forks, or to position the file mark at a point more than 2GB into the file, use the FSSetForkPosition function, or one of the corresponding parameter block calls, PBSetForkPositionSync and PBSetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetVInfoAsync

Changes information about a volume. (Deprecated in OS X v10.4. Use PBSetVolumeInfoAsync instead.)

OSErr PBSetVInfoAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HVolumeParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the volume’s name. You can specify a new name for the volume here. You cannot specify the volume by name you must use either the volume reference number or the drive number.

ioVRefNum

On input, a volume reference number or drive number for the volume whose information is to be changed; or 0 for the default volume.

ioVCrDate

On input, the date and time of the volume’s initialization.

ioVLsMod

On input, the date and time of the volume’s last modification.

ioVAtrb

On input, the volume attributes. Only bit 15 of the ioVAtrb field can be changed; setting it locks the volume. See “Volume Information Attribute Constants” for a description of the volume attributes.

ioVBkUp

On input, the date and time of the volume’s last backup.

ioVSeqNum

Used internally.

ioVFndrInfo

On input, Finder information for the volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBSetVInfoSync

Changes information about a volume. (Deprecated in OS X v10.4. Use PBSetVolumeInfoSync instead.)

OSErr PBSetVInfoSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HVolumeParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the volume’s name. You can specify a new name for the volume here. You cannot specify the volume by name you must use either the volume reference number or the drive number.

ioVRefNum

On input, a volume reference number or drive number for the volume whose information is to be changed; or 0 for the default volume.

ioVCrDate

On input, the date and time of the volume’s initialization.

ioVLsMod

On input, the date and time of the volume’s last modification.

ioVAtrb

On input, the volume attributes. Only bit 15 of the ioVAtrb field can be changed; setting it locks the volume. See “Volume Information Attribute Constants” for a description of the volume attributes.

ioVBkUp

On input, the date and time of the volume’s last backup.

ioVSeqNum

Used internally.

ioVFndrInfo

On input, Finder information for the volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBShareAsync

Establishes a local volume or directory as a share point. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBShareAsync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBShareSync

Establishes a local volume or directory as a share point. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBShareSync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBUnlockRangeAsync

Unlocks a portion of a file. (Deprecated in OS X v10.4. Use PBXUnlockRangeAsync instead.)

OSErr PBUnlockRangeAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. If you call PBUnlockRangeAsync on a file system that does not implement it—for example, SMB—PBUnlockRangeAsync returns noErr and does nothing.

ioRefNum

On input, the file reference number of the file owning the range to unlock.

ioReqCount

On input, the number of bytes in the range.

ioPosMode

On input, a constant specifying the base location for the start of the locked range. See “Position Mode Constants” for more information on the constants you can use to indicate the base location.

ioPosOffset

On input, the offset from the base location specified in the ioPosMode field for the start of the locked range.

The PBUnlockRangeAsync function unlocks a portion of a file that you locked with PBLockRangeSync or PBLockRangeAsync. The beginning of the range to be unlocked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be unlocked is determined by the beginning of the range and the ioReqCount field. For example, to unlock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0. The range of bytes to be unlocked must be the exact same range locked by a previous call to PBLockRangeSync or PBLockRangeAsync.

If for some reason you need to unlock a range whose beginning or length is unknown, you can simply close the file. When a file is closed, all locked ranges held by the user are unlocked.

Special Considerations

The PBUnlockRangeAsync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a local volume. To check whether file sharing is currently on, check that the bHasPersonalAccessPrivileges bit in the vMAttrib field of the GetVolParmsInfoBuffer returned by the PBHGetVolParmsSync function is set.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBUnlockRangeSync

Unlocks a portion of a file. (Deprecated in OS X v10.4. Use PBXUnlockRangeSync or FSUnlockRange instead.)

OSErr PBUnlockRangeSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” If you call PBUnlockRangeSync on a file system that does not implement it—for example, SMB—PBUnlockRangeSync returns noErr and does nothing.

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, the file reference number of the file owning the range to unlock.

ioReqCount

On input, the number of bytes in the range.

ioPosMode

On input, a constant specifying the base location for the start of the locked range. See “Position Mode Constants” for more information on the constants you can use to indicate the base location.

ioPosOffset

On input, the offset from the base location specified in the ioPosMode field for the start of the locked range.

The PBUnlockRangeSync function unlocks a portion of a file that you locked with PBLockRangeSync or PBLockRangeAsync. The beginning of the range to be unlocked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be unlocked is determined by the beginning of the range and the ioReqCount field. For example, to unlock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0. The range of bytes to be unlocked must be the exact same range locked by a previous call to PBLockRangeSync or PBLockRangeAsync.

If for some reason you need to unlock a range whose beginning or length is unknown, you can simply close the file. When a file is closed, all locked ranges held by the user are unlocked.

Special Considerations

The PBUnlockRangeSync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a local volume. To check whether file sharing is currently on, check that the bHasPersonalAccessPrivileges bit in the vMAttrib field of the GetVolParmsInfoBuffer returned by the PBHGetVolParmsSync function is set.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBUnmountVol

Unmounts a volume. (Deprecated in OS X v10.4. Use FSEjectVolumeSync or FSUnmountVolumeSync instead.)

OSErr PBUnmountVol (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the VolumeParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the volume.

ioVRefNum

On input, the volume reference number of the volume to unmount, or 0 for the default volume.

This function calls PBFlushVolSync to flush the specified volume, unmounts and ejects the volume, and releases the memory used for the volume. Prior to calling this function, all user files on the volume must be closed. Ejecting a volume results in the unmounting of other volumes on the same device.

The PBUnmountVol function always executes synchronously.

Special Considerations

Don’t unmount the startup volume. Doing so will cause a system crash.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBUnshareAsync

Makes a share point unavailable on the network. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBUnshareAsync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBUnshareSync

Makes a share point unavailable on the network. (Deprecated in OS X v10.4. There is no replacement function.)

OSErr PBUnshareSync (
   HParmBlkPtr paramBlock
);
Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBXGetVolInfoAsync

Returns information about a volume, including size information for volumes up to 2 terabytes. (Deprecated in OS X v10.4. Use FSGetVolumeInfo instead.)

OSErr PBXGetVolInfoAsync (
   XVolumeParamPtr paramBlock
);
Parameters
paramBlock

A pointer to an extended volume parameter block. See XVolumeParam for a description of the XVolumeParam data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the function result.

ioNamePtr

On input, a pointer to a buffer. You should pass a pointer to a Str31 value if you want the volume name returned; otherwise, pass NULL. If you specify a negative number in the ioVolIndex field, this buffer should hold the name of the volume for which to return information. On output, a pointer to the volume’s name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume. If the value in the ioVolIndex field is negative, the File Manager uses the name in the ioNamePtr field, along with the value in the ioVRefNum field, to determine the volume. If the value in ioVolIndex is 0, the File Manager attempts to access the volume using only the value in this field. On output, the volume reference number.

ioXVersion

On input, the version of the extended volume parameter block. Currently, this value is 0.

ioVolIndex

On input, an index used for indexing through all the mounted volumes. If this value is positive, the File Manager uses it to find the volume for which to return information. For instance, if the value of ioVolIndex is 2, the File Manager attempts to access the second mounted volume in the VCB queue. If ioVolIndex is negative, the File Manager uses the values in the ioNamePtr and ioVRefNum fields to access the requested volume. If ioVolIndex is 0, the File Manager uses only the value in the ioVRefNum field.

ioVCrDate

On output, the date and time of the volume’s creation (initialization).

ioVLsMod

On output, the date and time that the volume was last modified.

ioVAtrb

On output, the volume attributes. See “Volume Information Attribute Constants” for a description of these attributes.

ioVNmFls

On output, the number of files in the root directory of the volume. For performance reasons, the Carbon File Manager does not return the number of files in this field; instead, it sets ioVNmFls to 0.To determine the number of files in the root directory of a volume in Carbon, call PBGetCatInfoAsync for the root directory. The number of files in the root directory is returned in the ioDrNmFls field.

ioVBitMap

On output, the first block of the volume bitmap.

ioVAllocPtr

On output, the block where the next new file allocation search should start.

ioVNmAlBlks

On output, the number of allocation blocks on the volume.

ioVAlBlkSiz

On output, the allocation block size for the volume.

ioVClpSiz

On output, the volume’s default clump size.

ioAlBlSt

On output, the first block in the volume block map.

ioVNxtCNID

On output, the next unused catalog node ID.

ioVFrBlk

On output, the number of free (unused) allocation blocks on the volume.

ioVSigWord

On output, the volume signature. For HFS volumes, this is ‘BD’ for HFS Plus volumes, this is ‘H+’.

ioVDrvInfo

On output, the drive number. You can determine whether the given volume is online by inspecting the value of this field. For online volumes, the ioVDrvInfo field contains the drive number of the drive containing the specified volume and hence is always greater than 0. If the value returned in ioVDrvInfo is 0, the volume is either offline or ejected.

ioVDRefNum

On output, the driver reference number. You can determine whether the volume is offline or ejected by inspecting the value of this field. If the volume is offline, the value of ioVDRefNum is the negative of the drive number (which is cleared when the volume is placed offline; hence the ioVDrvInfo field for an offline volume is zero), and is a negative number. If the volume is ejected, the value of ioVDRefNum is the drive number itself, and thus is a positive number. For online volumes, ioVDRefNum contains a driver reference number; these numbers are always less than 0.

ioVFSID

On output, the file system ID for the file system handling this volume.

ioVBkUp

On output, the date and time that the volume was last backed up.

ioVSeqNum

Used internally.

ioVWrCnt

On output, the volume write count.

ioVFilCnt

On output, the number of files on the volume.

ioVDirCnt

On output, the number of directories on the volume.

ioVFndrInfo

On output, Finder information for the volume.

ioVTotalBytes

On output, the total number of bytes on the volume.

ioVFreeBytes

On output, the number of free bytes on the volume.

The PBXGetVolInfoAsync function is similar to the PBHGetVInfoAsync function except that it returns additional volume space information in 64-bit integers and does not modify the information copied from the volume’s volume control block (VCB). Systems that support PBXGetVolInfoAsync will have the gestaltFSSupports2TBVols bit set in the response returned by the gestaltFSAttr Gestalt selector. See Inside OS X: Gestalt Manager Reference for a description of the gestaltFSAttr selector and of the bits that may be returned in the response.

Special Considerations

After an operation that changes the amount of free space on the volume—such as deleting a file—there may be a delay before a call to PBXGetVolInfoAsync returns the updated amount. This is because the File Manager caches and periodically updates file system information, to reduce the number of calls made to retrieve the information from the file system. Currently, the File Manager updates its information every 15 seconds. This primarily affects NFS volumes. DOS, SMB, UFS and WebDAV volumes were also affected by this in previous versions of OS X, but behave correctly in OS X version 10.3 and later.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

PBXGetVolInfoSync

Returns information about a volume, including size information for volumes up to 2 terabytes. (Deprecated in OS X v10.4. Use FSGetVolumeInfo instead.)

OSErr PBXGetVolInfoSync (
   XVolumeParamPtr paramBlock
);
Parameters
paramBlock

A pointer to an extended volume parameter block. See XVolumeParam for a description of the XVolumeParam data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a buffer. You should pass a pointer to a Str31 value if you want the volume name returned; otherwise, pass NULL. If you specify a negative number in the ioVolIndex field, this buffer should hold the name of the volume for which to return information. On output, a pointer to the volume’s name.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume. If the value in the ioVolIndex field is negative, the File Manager uses the name in the ioNamePtr field, along with the value in the ioVRefNum field, to determine the volume. If the value in ioVolIndex is 0, the File Manager attempts to access the volume using only the value in this field. On output, the volume reference number.

ioXVersion

On input, the version of the extended volume parameter block. Currently, this value is 0.

ioVolIndex

On input, an index used for indexing through all the mounted volumes. If this value is positive, the File Manager uses it to find the volume for which to return information. For instance, if the value of ioVolIndex is 2, the File Manager attempts to access the second mounted volume in the VCB queue. If ioVolIndex is negative, the File Manager uses the values in the ioNamePtr and ioVRefNum fields to access the requested volume. If ioVolIndex is 0, the File Manager uses only the value in the ioVRefNum field.

ioVCrDate

On output, the date and time of the volume’s creation (initialization).

ioVLsMod

On output, the date and time that the volume was last modified.

ioVAtrb

On output, the volume attributes. See “Volume Information Attribute Constants” for a description of these attributes.

ioVNmFls

On output, the number of files in the root directory of the volume. For performance reasons, the Carbon File Manager does not return the number of files in this field; instead, it sets ioVNmFls to 0.To determine the number of files in the root directory of a volume in Carbon, call PBGetCatInfoSync for the root directory. The number of files in the root directory is returned in the ioDrNmFls field.

ioVBitMap

On output, the first block of the volume bitmap.

ioVAllocPtr

On output, the block where the next new file allocation search should start.

ioVNmAlBlks

On output, the number of allocation blocks on the volume.

ioVAlBlkSiz

On output, the allocation block size for the volume.

ioVClpSiz

On output, the volume’s default clump size.

ioAlBlSt

On output, the first block in the volume block map.

ioVNxtCNID

On output, the next unused catalog node ID.

ioVFrBlk

On output, the number of free (unused) allocation blocks on the volume.

ioVSigWord

On output, the volume signature. For HFS volumes, this is ‘BD’ for HFS Plus volumes, this is ‘H+’.

ioVDrvInfo

On output, the drive number. You can determine whether the given volume is online by inspecting the value of this field. For online volumes, the ioVDrvInfo field contains the drive number of the drive containing the specified volume and hence is always greater than 0. If the value returned in ioVDrvInfo is 0, the volume is either offline or ejected.

ioVDRefNum

On output, the driver reference number. You can determine whether the volume is offline or ejected by inspecting the value of this field. If the volume is offline, the value of ioVDRefNum is the negative of the drive number (which is cleared when the volume is placed offline; hence the ioVDrvInfo field for an offline volume is zero), and is a negative number. If the volume is ejected, the value of ioVDRefNum is the drive number itself, and thus is a positive number. For online volumes, ioVDRefNum contains a driver reference number; these numbers are always less than 0.

ioVFSID

On output, the file system ID for the file system handling this volume.

ioVBkUp

On output, the date and time that the volume was last backed up.

ioVSeqNum

Used internally.

ioVWrCnt

On output, the volume write count.

ioVFilCnt

On output, the number of files on the volume.

ioVDirCnt

On output, the number of directories on the volume.

ioVFndrInfo

On output, Finder information for the volume.

ioVTotalBytes

On output, the total number of bytes on the volume.

ioVFreeBytes

On output, the number of free bytes on the volume.

The PBXGetVolInfoSync function is similar to the PBHGetVInfoSync function except that it returns additional volume space information in 64-bit integers and does not modify the information copied from the volume’s volume control block (VCB). Systems that support PBXGetVolInfoSync will have the gestaltFSSupports2TBVols bit set in the response returned by the gestaltFSAttr Gestalt selector. See Inside OS X: Gestalt Manager Reference for a description of the gestaltFSAttr selector and of the bits that may be returned in the response.

Special Considerations

After an operation that changes the amount of free space on the volume—such as deleting a file—there may be a delay before a call to PBXGetVolInfoSync returns the updated amount. This is because the File Manager caches and periodically updates file system information, to reduce the number of calls made to retrieve the information from the file system. Currently, the File Manager updates its information every 15 seconds. This primarily affects NFS volumes. DOS, SMB, UFS and WebDAV volumes were also affected by this in previous versions of OS X, but behave correctly in OS X version 10.3 and later.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

SetEOF

Sets the logical size of an open file. (Deprecated in OS X v10.4. Use FSSetForkSize instead.)

OSErr SetEOF (
   FSIORefNum refNum,
   SInt32 logEOF
);
Parameters
refNum

The file reference number of an open file.

logEOF

The new logical size (the logical end-of-file) of the given file. If you set the logEOF parameter to 0, all space occupied by the file on the volume is released. The file still exists, but it contains 0 bytes. Setting a file fork’s end-of-file to 0 is therefore not the same as deleting the file, which removes both file forks at once.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you attempt to set the logical end-of-file beyond the physical end-of-file, the physical end-of-file is set 1 byte beyond the end of the next free allocation block if there isn’t enough space on the volume, no change is made, and SetEOF returns dskFulErr as its function result.

To ensure that your changes to the file are written to disk, call one of the functions, FlushVol , PBFlushVolSync , or PBFlushVolAsync. To set the size of a named fork other than the data and resource forks, or to grow the size of a file beyond 2GB, you must use the FSSetForkSize function, or one of the corresponding parameter block calls, PBSetForkSizeSync and PBSetForkSizeAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

SetFPos

Sets the position of the file mark. (Deprecated in OS X v10.4. Use FSSetForkPosition instead.)

OSErr SetFPos (
   FSIORefNum refNum,
   SInt16 posMode,
   SInt32 posOff
);
Parameters
refNum

The file reference number of an open file.

posMode

A constant specifying how to position the file mark; this parameter must contain one of the values described in “Position Mode Constants.”

posOff

The offset from the base location specified by the posMode parameter for the new file mark position. If you specify fsFromLEOF in the posMode parameter, the value in the posOff parameter must be less than or equal to 0. If you specify fsAtMark, the value in the posOff parameter is ignored.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Because the read and write operations performed by the functions FSRead and FSWrite begin at the current mark, you may want to call SetFPos to reposition the file mark before reading from or writing to the file.

To set the file mark position for a named fork other than the data and resource forks, or to position the file mark at a point more than 2GB into the file, use the FSSetForkPosition function, or one of the corresponding parameter block calls, PBSetForkPositionSync and PBSetForkPositionAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

UnmountVol

Unmounts a volume that isn’t currently being used. (Deprecated in OS X v10.4. Use FSUnmountVolumeSync instead.)

OSErr UnmountVol (
   ConstStr63Param volName,
   FSVolumeRefNum vRefNum
);
Parameters
volName

The name of a mounted volume. This parameter may be NULL.

vRefNum

The volume reference number, drive number, or 0 for the default volume.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

All files on the volume (except those opened by the Operating System) must be closed before you call UnmountVol, which does not eject the volume.

Most applications do not need to use this function, because the user typically ejects (and possibly also unmounts) a volume in the Finder.

Special Considerations

Don’t unmount the startup volume. Doing so will cause a system crash.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
Files.h

Deprecated in OS X v10.5

FlushVol

Writes the contents of the volume buffer and updates information about the volume. (Deprecated in OS X v10.5. Use FSFlushVolume instead.)

OSErr FlushVol (
   ConstStr63Param volName,
   FSVolumeRefNum vRefNum
);
Parameters
volName

The name of the mounted volume to flush.

vRefNum

The volume reference number, drive number, or 0 for the default volume.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

For the specified volume, the FlushVol function writes the contents of the associated volume buffer and descriptive information about the volume. Information which has changed since the last time FlushVol was called is written to the volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

FSpMakeFSRef

Creates an FSRef for a file or directory, given an FSSpec. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr FSpMakeFSRef (
   const FSSpec *source,
   FSRef *newRef
);
Parameters
source

A pointer to the FSSpec for the file or directory. This parameter must point to a valid FSSpec for an existing file or directory; if it does not, the call will return fnfErr. See FSSpec for a description of the FSSpec data type.

newRef

On input, a pointer to an FSRef structure. On return, a pointer to the FSRef for the file or directory specified in the FSSpec pointed to in the source parameter.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

To obtain an FSSpec from an FSRef, use the FSGetCatalogInfo function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCloseAsync

Closes an open file. (Deprecated in OS X v10.5. Use PBCloseForkAsync instead.)

OSErr PBCloseAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number to the file to close.

The PBCloseAsync function writes the contents of the access path buffer specified by the ioRefNum field to the volume and removes the access path.

Special Considerations

Some information stored on the volume won’t be updated until PBFlushVolAsync is called.

Do not call PBCloseAsync with a file reference number of a file that has already been closed. Attempting to close the same file twice may result in loss of data on a volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCloseSync

Closes an open file. (Deprecated in OS X v10.5. Use PBCloseForkSync instead.)

OSErr PBCloseSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant field of the parameter block is:

ioRefNum

On input, a file reference number to the file to close.

The PBCloseSync function writes the contents of the access path buffer specified by the ioRefNum field to the volume and removes the access path.

Special Considerations

Some information stored on the volume won’t be updated until PBFlushVolSync is called.

Do not call PBCloseSync with a file reference number of a file that has already been closed. Attempting to close the same file twice may result in loss of data on a volume.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCreateFileIDRefAsync

Establishes a file ID reference for a file. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBCreateFileIDRefAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDs internally as part of its search algorithms for finding the target of an alias record.

Given a volume reference number, filename, and parent directory ID, the PBCreateFileIDRefAsync function creates a structure to hold the name and parent directory ID of the specified file. The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. PBCreateFileIDRefAsync returns the result code fidExists if a file ID reference already exists for the file.

ioNamePtr

On input, a pointer to the file’s name.

ioVRefNum

On input, a volume reference number for the volume containing the file.

ioSrcDirID

On input, the file’s parent directory ID.

ioFileID

On output, a file ID. If a file ID reference already exists for the file, PBCreateFileIDRefAsync supplies the file ID but returns the result code fidExists.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBCreateFileIDRefSync

Establishes a file ID reference for a file. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBCreateFileIDRefSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”PBCreateFileIDRefSync returns the result code fidExists if a file ID reference already exists for the file.

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDs internally as part of its search algorithms for finding the target of an alias record.

Given a volume reference number, filename, and parent directory ID, the PBCreateFileIDRefSync function creates a structure to hold the name and parent directory ID of the specified file. The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the file’s name.

ioVRefNum

On input, a volume reference number for the volume containing the file.

ioSrcDirID

On input, the file’s parent directory ID.

ioFileID

On output, a file ID. If a file ID reference already exists for the file, PBCreateFileIDRefSync supplies the file ID but returns the result code fidExists.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDeleteFileIDRefAsync

Deletes a file ID reference. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBDeleteFileIDRefAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDs internally as part of its search algorithms for finding the target of an alias record.

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification for the volume containing the file.

ioFileID

On input, the file ID reference to delete. After it has invalidated a file ID reference, the File Manager can no longer resolve that ID reference to a filename and parent directory ID.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBDeleteFileIDRefSync

Deletes a file ID reference. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBDeleteFileIDRefSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the FIDParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDs internally as part of its search algorithms for finding the target of an alias record.

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification for the volume containing the file.

ioFileID

On input, the file ID reference to delete. After it has invalidated a file ID reference, the File Manager can no longer resolve that ID reference to a filename and parent directory ID.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBFlushVolAsync

Writes the contents of the volume buffer and updates information about the volume. (Deprecated in OS X v10.5. Use PBFlushVolumeAsync instead.)

OSErr PBFlushVolAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the VolumeParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the volume to flush.

ioVRefNum

On input, a volume reference number, drive number, or 0 for the default volume.

PBFlushVolAsync flushes all open files on the volume, and then flushes all volume data structures. On the volume specified by ioNamePtr or ioVRefNum, the PBFlushVolAsync function writes descriptive information about the volume, the contents of the associated volume buffer, and all access path buffers for the volume (if they’ve changed since the last time PBFlushVolAsync was called).

The date and time of the last modification to the volume are set when the modification is made, not when the volume is flushed.

To ensure that all changes to a volume are flushed to the volume, use PBFlushVolAsync. You do not, however, need to flush a volume before unmounting it, ejecting it, or putting it offline; this is done automatically.

If changes are made to a file that affect the file’s end-of-file, the file’s name, the file’s Finder information, or the file’s location on the volume, then you must use PBFlushVolAsync, or one of the other two volume flush functions in this section, to ensure that these changes are written to disk.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBFlushVolSync

Writes the contents of the volume buffer and updates information about the volume. (Deprecated in OS X v10.5. Use PBFlushVolumeSync instead.)

OSErr PBFlushVolSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the VolumeParam variant of the basic File Manager parameter block. See ParamBlockRec for a description of the ParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the volume to flush.

ioVRefNum

On input, the volume reference number, drive number, or 0 for the default volume.

PBFlushVolSync flushes all open files on the volume, and then flushes all volume data structures. On the volume specified by ioNamePtr or ioVRefNum, the PBFlushVolSync function writes descriptive information about the volume, the contents of the associated volume buffer, and all access path buffers for the volume (if they’ve changed since the last time PBFlushVolSync was called).

The date and time of the last modification to the volume are set when the modification is made, not when the volume is flushed.

To ensure that all changes to a volume are flushed to the volume, use PBFlushVolSync. You do not, however, need to flush a volume before unmounting it, ejecting it, or putting it offline; this is done automatically.

If changes are made to a file that affect the file’s end-of-file, the file’s name, the file’s Finder information, or the file’s location on the volume, then you must use PBFlushVolSync, or one of the other two volume flush functions in this section, to ensure that these changes are written to disk.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBGetVolMountInfo

Retrieves a record containing all the information needed to mount a volume, except for passwords. (Deprecated in OS X v10.5. Use FSVolumeMount instead.)

OSErr PBGetVolMountInfo (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname

ioVRefNum

On input, a volume specification. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioBuffer

On input, a pointer to a buffer to hold the mounting information. The length of the buffer is specified by the value pointed to by the ioBuffer field in a previous call to PBGetVolMountInfoSize. On output, the mounting information for the specified volume. You can later pass this structure to the PBVolumeMount function to mount the volume. The mounting information for an AppleShare volume is stored as an AFP mounting record. The PBGetVolMountInfo function does not return the user password or volume password in the AFPVolMountInfo structure. Your application should solicit these passwords from the user and fill in the structure before attempting to mount the remote volume.

This function allows your application to record the mounting information for a volume and then to mount the volume later. This programmatic mounting function stores the mounting information in a structure called the AFPVolMountInfo structure.

Special Considerations

This function executes synchronously. You should not call it at interrupt time.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Related Sample Code
Declared In
Files.h

PBGetVolMountInfoSize

Determines how much space to allocate for a volume mounting information structure. (Deprecated in OS X v10.5. Use FSVolumeMount instead.)

OSErr PBGetVolMountInfoSize (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname

ioVRefNum

On input, a volume specification. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioBuffer

On input, a pointer to storage for the size information, which is of type Integer (2 bytes). If PBGetVolMountInfoSize returns noErr, that integer contains the size of the volume mounting information structure on output.

You should call this function before you call PBGetVolMountInfo , to obtain the size of the volume mounting information for which you must allocate storage. Then call PBGetVolMountInfo to retrieve the actual volume mounting information.

Special Considerations

This function executes synchronously. You should not call it at interrupt time.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Related Sample Code
Declared In
Files.h

PBHCopyFileAsync

Duplicates a file and optionally renames it. (Deprecated in OS X v10.5. Use PBFSCopyFileAsync instead.)

OSErr PBHCopyFileAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a CopyParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the source file.

ioVRefNum

On input, the volume reference number or drive number for the volume containing the source file. Pass 0 for the default volume.

ioDstVRefNum

On input, the reference number or drive number of the destination volume. Pass 0 for the default volume.

ioNewName

On input, a pointer to the partial pathname for the destination directory. If ioNewName is NULL, the destination directory is the directory having the ID specified in the ioNewDirID field.

ioCopyName

On input, a pointer to the file’s new name. The string pointed to by this field must be a filename, not a partial pathname. If you do not wish to rename the file, pass NULL in this field.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, the parent directory ID of the destination directory.

ioDirID

On input, the directory ID of the source directory.

This function is especially useful when you want to copy or move files located on a remote volume, because it allows you to forgo transmitting large amounts of data across a network. This function is used internally by the Finder; most applications do not need to use it.

Special Considerations

This is an optional call for AppleShare file servers. Your application should examine the information returned by the PBHGetVolParmsAsync function to see if the volume supports PBHCopyFileAsync. If the bHasCopyFile bit is set in the vMAttrib field of the GetVolParmsInfoBuffer structure, then the volume supports PBHCopyFileAsync.

For AppleShare file servers, the source and destination pathnames must indicate the same file server; however, the parameter block may specify different source and destination volumes on that file server. A useful way to tell if two file server volumes are on the same file server is to call the PBHGetVolParmsAsync function for each volume and compare the server addresses returned. The server opens source files with read/deny write enabled and destination files with write/deny read and write enabled.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHCopyFileSync

Duplicates a file and optionally renames it. (Deprecated in OS X v10.5. Use PBFSCopyFileSync instead.)

OSErr PBHCopyFileSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a CopyParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the source file.

ioVRefNum

On input, the volume reference number or drive number for the volume containing the source file. Pass 0 for the default volume.

ioDstVRefNum

On input, the reference number or drive number of the destination volume. Pass 0 for the default volume.

ioNewName

On input, a pointer to the partial pathname for the destination directory. If ioNewName is NULL, the destination directory is the directory having the ID specified in the ioNewDirID field.

ioCopyName

On input, a pointer to the file’s new name. The string pointed to by this field must be a filename, not a partial pathname. If you do not wish to rename the file, pass NULL in this field.

ioNewDirID

On input, if the ioNewName field is NULL, the directory ID of the destination directory. If ioNewName is not NULL, the parent directory ID of the destination directory.

ioDirID

On input, the directory ID of the source directory.

This function is especially useful when you want to copy or move files located on a remote volume, because it allows you to forgo transmitting large amounts of data across a network. This function is used internally by the Finder; most applications do not need to use it.

Special Considerations

This is an optional call for AppleShare file servers. Your application should examine the information returned by the PBHGetVolParmsSync function to see if the volume supports PBHCopyFileSync. If the bHasCopyFile bit is set in the vMAttrib field of the GetVolParmsInfoBuffer structure, then the volume supports PBHCopyFileSync.

For AppleShare file servers, the source and destination pathnames must indicate the same file server; however, the parameter block may specify different source and destination volumes on that file server. A useful way to tell if two file server volumes are on the same file server is to call the PBHGetVolParmsSync function for each volume and compare the server addresses returned. The server opens source files with read/deny write enabled and destination files with write/deny read and write enabled.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetDirAccessAsync

Returns the access control information for a directory or file. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBHGetDirAccessAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the AccessParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname for the directory or file.

ioVRefNum

On input, a volume specification for the volume containing the directory or file. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioACOwnerID

On output, the user ID for the owner of the directory or file.

ioACGroupID

On output, the primary group ID of the directory or file.

ioACAccess

On output, the access rights for the directory or file. See “File and Folder Access Privilege Constants” for more information on these access rights.

ioDirID

On input, the directory ID.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetDirAccessSync

Returns the access control information for a directory or file. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBHGetDirAccessSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the AccessParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname for the directory or file.

ioVRefNum

On input, a volume specification for the volume containing the directory or file. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioACOwnerID

On output, the user ID for the owner of the directory or file.

ioACGroupID

On output, the primary group ID of the directory or file.

ioACAccess

On output, the access rights for the directory or file. See “File and Folder Access Privilege Constants” for more information on these access rights.

ioDirID

On input, the directory ID.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVolParmsAsync

Returns information about the characteristics of a volume. (Deprecated in OS X v10.5. Use FSGetVolumeParms instead.)

OSErr PBHGetVolParmsAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the volume’s name. You can use a either a name or a volume specification to specify the volume. If you use a volume specification to specify the volume, you should set the ioNamePtr field to NULL.

ioVRefNum

On input, a volume specification. You can use a either a name or a volume specification to specify the volume. A volume specification can be a volume reference number, drive number, or 0 for the default volume.

ioBuffer

On input, a pointer to a GetVolParmsInfoBuffer record; you must allocate this memory to hold the returned attributes. On return, the PBHGetVolParmsAsync function places the attributes information in the buffer. Volumes that implement the HFS Plus APIs must use version 3 (or newer) of the GetVolParmsInfoBuffer structure. If the version of the GetVolParmsInfoBuffer is 2 or less, or the bSupportsHFSPlusAPIs bit is clear, then the volume does not implement the HFS Plus APIs and they are being emulated for that volume by the File Manager.

ioReqCount

On input, the size, in bytes, of the buffer area pointed to in the ioBuffer field.

ioActCount

On output, the size of the data actually returned.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHGetVolParmsSync

Returns information about the characteristics of a volume. (Deprecated in OS X v10.5. Use FSGetVolumeParms instead.)

OSErr PBHGetVolParmsSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the HIOParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the volume’s name. You can use a either a name or a volume specification to specify the volume. If you use a volume specification to specify the volume, you should set the ioNamePtr field to NULL.

ioVRefNum

On input, a volume specification. You can use a either a name or a volume specification to specify the volume. A volume specification can be a volume reference number, drive number, or 0 for the default volume.

ioBuffer

On input, a pointer to a GetVolParmsInfoBuffer record; you must allocate this memory to hold the returned attributes. On return, the PBHGetVolParmsSync function places the attributes information in the buffer. Volumes that implement the HFS Plus APIs must use version 3 (or newer) of the GetVolParmsInfoBuffer structure. If the version of the GetVolParmsInfoBuffer is 2 or less, or the bSupportsHFSPlusAPIs bit is clear, then the volume does not implement the HFS Plus APIs and they are being emulated for that volume by the File Manager.

ioReqCount

On input, the size, in bytes, of the buffer area pointed to in the ioBuffer field.

ioActCount

On output, the size of the data actually returned.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Related Sample Code
Declared In
Files.h

PBHMapIDAsync

Determines the name of a user or group given the user or group ID. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBHMapIDAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the ObjParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification.

ioObjType

On input, the mapping function code its value is 1 if you’re mapping a user ID to a user name or 2 if you’re mapping a group ID to a group name. See “Mapping Code Constants” for more information about the values you can use in this field.

ioObjNamePtr

On output, a pointer to the user or group name; the maximum size of the name is 31 characters (preceded by a length byte).

ioObjID

On input, the user or group ID to be mapped. AppleShare uses the value 0 to signify Any User.

Special Considerations

See the BSD functions getpwnam and getpwuid, which correspond to this function on a conceptual level.

Version Notes

Because user and group IDs are interchangeable under AFP 2.1 and later volumes, you might not need to specify a value in the ioObjType field.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHMapIDSync

Determines the name of a user or group given the user or group ID. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBHMapIDSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the ObjParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification.

ioObjType

On input, the mapping function code its value is 1 if you’re mapping a user ID to a user name or 2 if you’re mapping a group ID to a group name. See “Mapping Code Constants” for more information about the values you can use in this field.

ioObjNamePtr

On output, a pointer to the user or group name; the maximum size of the name is 31 characters (preceded by a length byte).

ioObjID

On input, the user or group ID to be mapped. AppleShare uses the value 0 to signify Any User.

Special Considerations

See the BSD functions getpwnam and getpwuid, which correspond to this function on a conceptual level.

Version Notes

Because user and group IDs are interchangeable under AFP 2.1 and later volumes, you might not need to specify a value in the ioObjType field.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHMapNameAsync

Determines the user ID or group ID from a user or group name. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBHMapNameAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the ObjParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification.

ioObjType

On input, the mapping function code its value is 3 if you’re mapping a user name to a user ID or 4 if you’re mapping a group name to a group ID. See “Mapping Code Constants” for more information on the values you can use in this field.

ioObjNamePtr

On input, a pointer to the user or group name. The maximum size of the name is 31 characters. If NULL is passed, the ID returned is always 0.

ioObjID

On output, the mapped user or group ID.

Special Considerations

See the BSD functions getpwnam and getpwuid, which correspond to this function on a conceptual level.

Version Notes

Because user and group IDs are interchangeable under AFP 2.1 and later volumes, you might need to set the ioObjType field to determine which database (user or group) to search first. If both a user and a group have the same name, this field determines which kind of ID you receive.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHMapNameSync

Determines the user ID or group ID from a user or group name. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBHMapNameSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the ObjParam variant of the HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification.

ioObjType

On input, the mapping function code its value is 3 if you’re mapping a user name to a user ID or 4 if you’re mapping a group name to a group ID. See “Mapping Code Constants” for more information on the values you can use in this field.

ioObjNamePtr

On input, a pointer to the user or group name. The maximum size of the name is 31 characters. If NULL is passed, the ID returned is always 0.

ioObjID

On output, the mapped user or group ID.

Special Considerations

See the BSD functions getpwnam and getpwuid, which correspond to this function on a conceptual level.

Version Notes

Because user and group IDs are interchangeable under AFP 2.1 and later volumes, you might need to set the ioObjType field to determine which database (user or group) to search first. If both a user and a group have the same name, this field determines which kind of ID you receive.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenDenyAsync

Opens a file’s data fork using the access deny modes. (Deprecated in OS X v10.5. Use PBOpenForkAsync with deny modes in the permissions field.)

OSErr PBHOpenDenyAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic HFS parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. The function returns the result code opWrErr if you’ve requested write permission and you have already opened the file for writing in that case, the existing file reference number is returned in ioRefNum. You should not use this reference number unless your application originally opened the file.

ioNamePtr

On input, a pointer to a pathname for the file.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file. Pass 0 to indicate the default volume.

ioRefNum

On output, the file reference number for the file.

ioDenyModes

On input, the type of access you are requesting to the fork. See “File Access Permission Constants” for a description of the types of access that you can request.

ioDirID

On input, the parent directory ID of the file.

You should use the PBHOpenDenyAsync and PBHOpenRFDenyAsync functions (or their synchronous counterparts, PBHOpenDenySync and PBHOpenRFDenySync ) if you want to ensure that you get the access permissions and deny-mode permissions that you request. PBHOpenDenyAsync is not retried in any way. If the file cannot be opened because of a deny conflict, the error afpDenyConflict is returned and the ioRefNum field is set to 0.

You can check that the volume supports AFP deny-mode permissions by checking that the bHasOpenDeny bit is set in the vMAttrib field returned by the PBHGetVolParmsSync or PBHGetVolParmsAsync function. If you don’t want to special case volumes that support AFP deny mode permissions, you can use the File Manager permissions. See “File Access Permission Constants” for a description of how File Manager permissions are translated to AFP deny-mode permissions.

To open a file’s resource fork with access deny permissions, use the PBHOpenRFDenySync or PBHOpenRFDenyAsync function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenDenySync

Opens a file’s data fork using the access deny modes. (Deprecated in OS X v10.5. Use PBOpenForkSync with deny modes in the permissions field.)

OSErr PBHOpenDenySync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the AccessParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” The function returns the result code opWrErr if you’ve requested write permission and you have already opened the file for writing in that case, the existing file reference number is returned in ioRefNum. You should not use this reference number unless your application originally opened the file.

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname for the file.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file. Pass 0 to indicate the default volume.

ioRefNum

On output, the file reference number for the file.

ioDenyModes

On input, the type of access you are requesting to the fork. See “File Access Permission Constants” for a description of the types of access that you can request.

ioDirID

On input, the parent directory ID of the file.

You should use the PBHOpenDenySync and PBHOpenRFDenySync functions (or their asynchronous counterparts, PBHOpenDenyAsync and PBHOpenRFDenyAsync ) if you want to ensure that you get the access permissions and deny-mode permissions that you request. PBHOpenDenySync is not retried in any way. If the file cannot be opened because of a deny conflict, the error afpDenyConflict is returned and the ioRefNum field is set to 0.

You can check that the volume supports AFP deny-mode permissions by checking that the bHasOpenDeny bit is set in the vMAttrib field returned by the PBHGetVolParmsSync or PBHGetVolParmsAsync function. If you don’t want to special case volumes that support AFP deny mode permissions, you can use the File Manager permissions. See “File Access Permission Constants” for a description of how File Manager permissions are translated to AFP deny-mode permissions.

To open a file’s resource fork with access deny permissions, use the PBHOpenRFDenySync or PBHOpenRFDenyAsync function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenRFDenyAsync

Opens a file’s resource fork using the access deny modes. (Deprecated in OS X v10.5. Use PBOpenForkAsync with deny modes in the permissions field.)

OSErr PBHOpenRFDenyAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the AccessParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. The function returns the result code opWrErr if you’ve requested write permission and you have already opened the file for writing in that case, the existing file reference number is returned in ioRefNum. You should not use this reference number unless your application originally opened the file.

ioNamePtr

On input, a pointer to a pathname for the file.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file. Pass 0 to indicate the default volume.

ioRefNum

On output, the file reference number for the file.

ioDenyModes

On input, the type of access you are requesting to the fork. See “File Access Permission Constants” for a description of the types of access that you can request.

ioDirID

On input, the parent directory ID of the file.

You should use the PBHOpenRFDenyAsync and PBHOpenDenyAsync functions (or their synchronous counterparts, PBHOpenRFDenySync and PBHOpenDenySync ) if you want to ensure that you get the access permissions and deny-mode permissions that you request. PBHOpenRFDenyAsync is not retried in any way. If the file cannot be opened because of a deny conflict, the error afpDenyConflict is returned and the ioRefNum field is set to 0.

You can check that the volume supports AFP deny-mode permissions by checking that the bHasOpenDeny bit is set in the vMAttrib field returned by the PBHGetVolParmsSync or PBHGetVolParmsAsync function. If you don’t want to special case volumes that support AFP deny mode permissions, you can use the File Manager permissions. See “File Access Permission Constants” for a description of how File Manager permissions are translated to AFP deny-mode permissions.

To open a file’s data fork with access deny permissions, use the PBHOpenDenySync or PBHOpenDenyAsync function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHOpenRFDenySync

Opens a file’s resource fork using the access deny modes. (Deprecated in OS X v10.5. Use PBOpenForkSync with deny modes in the permissions field.)

OSErr PBHOpenRFDenySync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the AccessParam variant of the basic HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” The function returns the result code opWrErr if you’ve requested write permission and you have already opened the file for writing in that case, the existing file reference number is returned in ioRefNum. You should not use this reference number unless your application originally opened the file.

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname for the file.

ioVRefNum

On input, a volume reference number or drive number for the volume containing the file. Pass 0 to indicate the default volume.

ioRefNum

On output, the file reference number for the file.

ioDenyModes

On input, the type of access you are requesting to the fork. See “File Access Permission Constants” for a description of the types of access that you can request.

ioDirID

On input, the parent directory ID of the file.

You should use the PBHOpenRFDenySync and PBHOpenDenySync functions (or their asynchronous counterparts, PBHOpenRFDenyAsync and PBHOpenDenyAsync ) if you want to ensure that you get the access permissions and deny-mode permissions that you request. PBHOpenRFDenySync is not retried in any way. If the file cannot be opened because of a deny conflict, the error afpDenyConflict is returned and the ioRefNum field is set to 0.

You can check that the volume supports AFP deny-mode permissions by checking that the bHasOpenDeny bit is set in the vMAttrib field returned by the PBHGetVolParmsSync or PBHGetVolParmsAsync function. If you don’t want to special case volumes that support AFP deny mode permissions, you can use the File Manager permissions. See “File Access Permission Constants” for a description of how File Manager permissions are translated to AFP deny-mode permissions.

To open a file’s data fork with access deny permissions, use the PBHOpenDenySync or PBHOpenDenyAsync function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetDirAccessAsync

Changes the access control information for a directory. (Deprecated in OS X v10.5. Use FSSetCatalogInfo instead.)

OSErr PBHSetDirAccessAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to an AccessParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion function. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification for the volume containing the directory. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioACOwnerID

On input, the owner ID.

ioACGroupID

On input, the group ID.

ioACAccess

On input, the directory’s access rights. You cannot set the owner or user rights bits of the ioACAccess field directly; if you try to do this, PBHSetDirAccessAsync returns the result code paramErr. Only the blank access privileges can be set for a directory using this function. See “File and Folder Access Privilege Constants” for more information on directory access privileges.

ioDirID

On input, the directory ID.

To change the owner or group, you should set the ioACOwnerID or ioACGroupID field to the appropriate ID. You must be the owner of the directory to change the owner or group ID. A guest on a server can manipulate the privileges of any directory owned by the guest.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBHSetDirAccessSync

Changes the access control information for a directory. (Deprecated in OS X v10.5. Use FSSetCatalogInfo instead.)

OSErr PBHSetDirAccessSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to an AccessParam variant of an HFS parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname.

ioVRefNum

On input, a volume specification for the volume containing the directory. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioACOwnerID

On input, the owner ID.

ioACGroupID

On input, the group ID.

ioACAccess

On input, the directory’s access rights. You cannot set the owner or user rights bits of the ioACAccess field directly; if you try to do this, PBHSetDirAccessSync returns the result code paramErr. Only the blank access privileges can be set for a directory using this function. See “File and Folder Access Privilege Constants” for more information on directory access privileges.

ioDirID

On input, the directory ID.

To change the owner or group, you should set the ioACOwnerID or ioACGroupID field to the appropriate ID. You must be the owner of the directory to change the owner or group ID. A guest on a server can manipulate the privileges of any directory owned by the guest.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBMakeFSRefAsync

Creates an FSRef for a file or directory, given an FSSpec. (Deprecated in OS X v10.5. Use PBMakeFSRefUnicodeAsync instead.)

void PBMakeFSRefAsync (
   FSRefParam *paramBlock
);
Parameters
paramBlock

A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.

Discussion

For the parameter block based calls, the fields of the source FSSpec are passed as separate parameters (in the ioNamePtr, ioVRefNum, and ioDirID fields). This allows the call to be dispatched to external file systems the same way as other FSp calls are.

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

ioNamePtr

On input, a pointer to the name of the file or directory for which you wish to create an FSRef.

ioVRefNum

On input, a volume specification for the volume containing the file or directory. This can be a volume reference number, a drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the file or directory’s parent directory.

newRef

On input, a pointer to an FSRef structure. On output, this FSRef refers to the specified file or directory.

To obtain an FSSpec from an FSRef, use the PBGetCatalogInfoAsync call.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBMakeFSRefSync

Creates an FSRef for a file or directory, given an FSSpec. (Deprecated in OS X v10.5. Use PBMakeFSRefUnicodeSync instead.)

OSErr PBMakeFSRefSync (
   FSRefParam *paramBlock
);
Parameters
paramBlock

A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

For the parameter block based calls, the fields of the source FSSpec are passed as separate parameters (in the ioNamePtr, ioVRefNum, and ioDirID fields). This allows the call to be dispatched to external file systems the same way as other FSp calls are.

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to the name of the file or directory for which you wish to create an FSRef.

ioVRefNum

On input, a volume specification for the volume containing the file or directory. This can be a volume reference number, a drive number, or 0 for the default volume.

ioDirID

On input, the directory ID of the file or directory’s parent directory.

newRef

On input, a pointer to an FSRef structure. On output, this FSRef refers to the specified file or directory.

To obtain an FSSpec from an FSRef, use the PBGetCatalogInfoSync function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBReadAsync

Reads any number of bytes from an open file. (Deprecated in OS X v10.5. Use PBReadForkAsync instead.)

OSErr PBReadAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for an open file to be read.

ioBuffer

On input, a pointer to a data buffer into which the bytes are read.

ioReqCount

On input, the number of bytes requested. The value that you pass in this field should be greater than zero.

ioActCount

On output, the number of bytes actually read.

ioPosMode

On input, the positioning mode.

ioPosOffset

On input, the positioning offset. On output, the new position of the mark.

This function attempts to read ioReqCount bytes from the open file whose access path is specified in the ioRefNum field and transfer them to the data buffer pointed to by the ioBuffer field. The position of the mark is specified by ioPosMode and ioPosOffset. If your application tries to read past the logical end-of-file, PBReadAsync reads the data, moves the mark to the end-of-file, and returns eofErr as its function result. Otherwise, PBReadAsync moves the file mark to the byte following the last byte read and returns noErr.

You can specify that PBReadAsync read the file data 1 byte at a time until the requested number of bytes have been read or until the end-of-file is reached. To do so, set bit 7 of the ioPosMode field. Similarly, you can specify that PBReadAsync should stop reading data when it reaches an application-defined newline character. To do so, place the ASCII code of that character into the high-order byte of the ioPosMode field; you must also set bit 7 of that field to enable newline mode.

When reading data in newline mode, PBReadAsync returns the newline character as part of the data read and sets ioActCount to the actual number of bytes placed into the buffer (which includes the newline character).

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBReadSync

Reads any number of bytes from an open file. (Deprecated in OS X v10.5. Use PBReadForkSync instead.)

OSErr PBReadSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for an open file to be read.

ioBuffer

On input, a pointer to a data buffer into which the bytes are read.

ioReqCount

On input, the number of bytes requested. The value that you pass in this field should be greater than zero.

ioActCount

On output, the number of bytes actually read.

ioPosMode

On input, the positioning mode.

ioPosOffset

On input, the positioning offset. On output, the new position of the mark.

This function attempts to read ioReqCount bytes from the open file whose access path is specified in the ioRefNum field and transfer them to the data buffer pointed to by the ioBuffer field. The position of the mark is specified by ioPosMode and ioPosOffset. If your application tries to read past the logical end-of-file, PBReadSync reads the data, moves the mark to the end-of-file, and returns eofErr as its function result. Otherwise, PBReadSync moves the file mark to the byte following the last byte read and returns noErr.

You can specify that PBReadSync read the file data 1 byte at a time until the requested number of bytes have been read or until the end-of-file is reached. To do so, set bit 7 of the ioPosMode field. Similarly, you can specify that PBReadSync should stop reading data when it reaches an application-defined newline character. To do so, place the ASCII code of that character into the high-order byte of the ioPosMode field; you must also set bit 7 of that field to enable newline mode.

When reading data in newline mode, PBReadSync returns the newline character as part of the data read and sets ioActCount to the actual number of bytes placed into the buffer (which includes the newline character).

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBResolveFileIDRefAsync

Retrieves the filename and parent directory ID of a file given its file ID. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBResolveFileIDRefAsync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to an FIDParam variant of the HFS parameter block. See HParamBlockRec for more information on the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDS internally as part of its search algorithms for finding the target of an alias record.

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function. A return code of fidNotFound means that the specified file ID reference has become invalid, either because the file was deleted or because the file ID reference was destroyed by PBDeleteFileIDRefSync or PBDeleteFileIDRefAsync.

ioNamePtr

On input, a pointer to a pathname. If the name string is NULL, PBResolveFileIDRefAsync doe s not return the filename, but returns only the parent directory ID of the file in the ioSrcDirID field. If the name string is not NULL but is only a volume name, PBResolveFileIDRefAsync ignores the value in the ioVRefNum field and uses the volume name instead. On output, a pointer to the filename for the file with the given file ID.

ioVRefNum

On input, a volume specification for the volume containing the file. This field can contain a volume reference number, a drive number, or 0 for the default volume.

ioSrcDirID

On output, the file’s parent directory ID.

ioFileID

On input, a file ID for the file to retrieve information about.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBResolveFileIDRefSync

Retrieves the filename and parent directory ID of a file given its file ID. (Deprecated in OS X v10.5. Use FSGetCatalogInfo instead.)

OSErr PBResolveFileIDRefSync (
   HParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to an FIDParam variant of the HFS parameter block. See HParamBlockRec for more information on the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.” A return code of fidNotFound means that the specified file ID reference has become invalid, either because the file was deleted or because the file ID reference was destroyed by PBDeleteFileIDRefSync or PBDeleteFileIDRefAsync.

Discussion

Most applications do not need to use this function. In general, you should track files using alias records, as described in the Alias Manager documentation. The Alias Manager uses file IDs internally as part of its search algorithms for finding the target of an alias record.

The relevant fields of the parameter block are:

ioNamePtr

On input, a pointer to a pathname. If the name string is NULL, PBResolveFileIDRefSync doe s not return the filename, but returns only the parent directory ID of the file in the ioSrcDirID field. If the name string is not NULL but is only a volume name, PBResolveFileIDRefSync ignores the value in the ioVRefNum field and uses the volume name instead. On output, a pointer to the filename of the file with the given file ID.

ioVRefNum

On input, a volume specification for the volume containing the file. This field can contain a volume reference number, drive number, or 0 for the default volume.

ioSrcDirID

On output, the file’s parent directory ID.

ioFileID

On input, a file ID for the file to retrieve information about.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBVolumeMount

Mounts a volume. (Deprecated in OS X v10.5. Use FSVolumeMount instead.)

OSErr PBVolumeMount (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to the IOParam variant of the basic File Manager parameter block. See HParamBlockRec for a description of the HParamBlockRec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioVRefNum

On output, a volume reference number for the mounted volume.

ioBuffer

On input, a pointer to mounting information. You can use the volume mounting information returned by the PBGetVolMountInfo function or you can use a volume mounting information structure filled in by your application. If you’re mounting an AppleShare volume, place the volume’s AFP mounting information structure in the buffer pointed to by the ioBuffer field.

This function allows your application to record the mounting information for a volume and then to mount the volume later.

The PBGetVolMountInfo function does not return the user and volume passwords they’re returned blank. Typically, your application asks the user for any necessary passwords and fills in those fields just before calling PBVolumeMount. If you want to mount a volume with guest status, pass an empty string as the user password.

If you have enough information about the volume, you can fill in the mounting structure yourself and call PBVolumeMount, even if you did not save the mounting information while the volume was mounted. To mount an AFP volume, you must fill in the structure with at least the zone name, server name, user name, user password, and volume password. You can lay out the fields in any order within the data field, as long as you specify the correct offsets.

In general, it is easier to mount remote volumes by creating and then resolving alias records that describe those volumes. The Alias Manager displays the standard user interface for user authentication when resolving alias records for remote volumes. As a result, this function is primarily of interest for applications that need to mount remote volumes with no user interface or with some custom user interface.

Special Considerations

AFP volumes currently ignore the user authentication method passed in the uamType field of the volume mounting information structure whose address is passed in the ioBuffer field of the parameter block. The most secure available method is used by default, except when a user mounts the volume as Guest and uses the kNoUserAuthentication authentication method.

This function executes synchronously. You should not call it at interrupt time.

Version Notes

The File Sharing workstation software introduced in system software version 7.0 does not currently pass the volume password. The AppleShare 3.0 workstation software does, however, pass the volume password.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBWaitIOComplete

Keeps the system idle until either an interrupt occurs or the specified timeout value is reached. (Deprecated in OS X v10.5. There is no replacement function.)

OSErr PBWaitIOComplete (
   ParmBlkPtr paramBlock,
   Duration timeout
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

timeout

The maximum length of time you want the system to be kept idle.

Return Value

A result code. If the timeout value is reached, returns kMPTimeoutErr.

Special Considerations

This function is not implemented in OS X.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBWriteAsync

Writes any number of bytes to an open file. (Deprecated in OS X v10.5. Use PBWriteForkAsync instead.)

OSErr PBWriteAsync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine.

ioResult

On output, the result code of the function.

ioRefNum

On input, a file reference number for the open file to which to write.

ioBuffer

On input, a pointer to a data buffer containing the bytes to write.

ioReqCount

On input, the number of bytes requested.

ioActCount

On output, the number of bytes actually written.

ioPosMode

On input, the positioning mode.

ioPosOffset

On input, the positioning offset. On output, the new position of the mark.

The PBWriteAsync function takes ioReqCount bytes from the buffer pointed to by ioBuffer and attempts to write them to the open file whose access path is specified by ioRefNum. The position of the mark is specified by ioPosMode and ioPosOffset. If the write operation completes successfully, PBWriteAsync moves the file mark to the byte following the last byte written and returns noErr. If you try to write past the logical end-of-file, PBWriteAsync moves the logical end-of-file. If you try to write past the physical end-of-file, PBWriteAsync adds one or more clumps to the file and moves the physical end-of-file accordingly.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

PBWriteSync

Writes any number of bytes to an open file. (Deprecated in OS X v10.5. Use PBWriteForkSync instead.)

OSErr PBWriteSync (
   ParmBlkPtr paramBlock
);
Parameters
paramBlock

A pointer to a basic File Manager parameter block.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The relevant fields of the parameter block are:

ioRefNum

On input, a file reference number for the open file to which to write.

ioBuffer

On input, a pointer to a data buffer containing the bytes to write.

ioReqCount

On input, the number of bytes requested.

ioActCount

On output, the number of bytes actually written.

ioPosMode

On input, the positioning mode.

ioPosOffset

On input, the positioning offset. On output, the new position of the mark.

The PBWriteSync function takes ioReqCount bytes from the buffer pointed to by ioBuffer and attempts to write them to the open file whose access path is specified by ioRefNum. The position of the mark is specified by ioPosMode and ioPosOffset. If the write operation completes successfully, PBWriteSync moves the file mark to the byte following the last byte written and returns noErr. If you try to write past the logical end-of-file, PBWriteSync moves the logical end-of-file. If you try to write past the physical end-of-file, PBWriteSync adds one or more clumps to the file and moves the physical end-of-file accordingly.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.5.
  • Not available to 64-bit applications.
Declared In
Files.h

Deprecated in OS X v10.8

DisposeFNSubscriptionUPP

Deletes a universal procedure pointer (UPP) to your directory change callback function. (Deprecated in OS X v10.8.)

void DisposeFNSubscriptionUPP (
   FNSubscriptionUPP userUPP
);
Parameters
userUPP

The UPP to delete.

Discussion

You should use this function to delete the UPP after the File Manager is finished calling your directory change callback function.

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

DisposeFSVolumeEjectUPP

Deletes a universal procedure pointer (UPP) to your volume ejection callback function. (Deprecated in OS X v10.8.)

void DisposeFSVolumeEjectUPP (
   FSVolumeEjectUPP userUPP
);
Parameters
userUPP

The UPP to delete.

Discussion

You should use this function to delete the UPP after the File Manager is finished calling your volume ejection callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

DisposeFSVolumeMountUPP

Deletes a universal procedure pointer (UPP) to your volume mount callback function. (Deprecated in OS X v10.8.)

void DisposeFSVolumeMountUPP (
   FSVolumeMountUPP userUPP
);
Parameters
userUPP

The UPP to delete.

Discussion

You should use this function to delete the UPP after the File Manager is finished calling your volume mount callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

DisposeFSVolumeUnmountUPP

Deletes a universal procedure pointer (UPP) to your volume unmount callback function. (Deprecated in OS X v10.8.)

void DisposeFSVolumeUnmountUPP (
   FSVolumeUnmountUPP userUPP
);
Parameters
userUPP

The UPP to delete.

Discussion

You should use this function to delete the UPP after the File Manager is finished calling your volume unmount callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

DisposeIOCompletionUPP

Deletes a universal procedure pointer (UPP) to your I/O completion callback function. (Deprecated in OS X v10.8.)

void DisposeIOCompletionUPP (
   IOCompletionUPP userUPP
);
Parameters
userUPP

The UPP to delete.

Discussion

You should use this function to delete the UPP after the File Manager is finished calling your I/O completion callback function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNGetDirectoryForSubscription

Fetches the directory for which this subscription was originally entered. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNGetDirectoryForSubscription (
   FNSubscriptionRef subscription,
   FSRef *ref
);
Parameters
subscription

The subscription previously returned from the functions FNSubscribe or FNSubscribeByPath.

ref

On return, a file system reference to the directory for which this subscription was created.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

There is no path variant because paths are fragile, and the path may have changed. If the caller does not care about this subtlety, she can call FSRefMakePath to get a path from the returned reference.

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNNotify

Broadcasts notification of changes to the specified directory. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNNotify (
   const FSRef *ref,
   FNMessage message,
   OptionBits flags
);
Parameters
ref

A file system reference describing the directory for which to broadcast the notification.

message

An indication of what happened to the target directory.

flags

Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNNotifyAll

Broadcasts notification of changes to the filesystem. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNNotifyAll (
   FNMessage message,
   OptionBits flags
);
Parameters
message

An indication of what happened.

flags

Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function should only be used by installers or programs which make lots of changes and only send one broadcast.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNNotifyByPath

Broadcasts notification of changes to the specified directory. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNNotifyByPath (
   const UInt8 *path,
   FNMessage message,
   OptionBits flags
);
Parameters
path

The path to the directory for which to broadcast the notification.

message

An indication of what happened to the target directory.

flags

Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNSubscribe

Subscribes to change notifications for the specified directory. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNSubscribe (
   const FSRef *directoryRef,
   FNSubscriptionUPP callback,
   void *refcon,
   OptionBits flags,
   FNSubscriptionRef *subscription
);
Parameters
directoryRef

A file system reference describing the directory for which the caller wants notifications.

callback

A pointer to the function to call when a notification arrives.

refcon

A pointer to user state carried with the subscription.

flags

Specify kNilOptions, or one of the options described in “Notification Subscription Options.”

subscription

A subscription token for subsequent query or unsubscription.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNSubscribeByPath

Subscribes to change notifications for the specified directory. (Deprecated in OS X v10.8. Use the File System Events API instead. For more information, see “Using the File System Events API”.)

OSStatus FNSubscribeByPath (
   const UInt8 *directoryPath,
   FNSubscriptionUPP callback,
   void *refcon,
   OptionBits flags,
   FNSubscriptionRef *subscription
);
Parameters
directoryPath

A path to the directory for which the caller wants notifications.

callback

The function to call when a notification arrives.

refcon

A pointer to the user state carried with the subscription.

flags

Specify kNilOptions, or one of the options described in “Notification Subscription Options.”

subscription

A subscription token for subsequent query or unsubscription.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FNUnsubscribe

Releases a subscription which is no longer needed. (Deprecated in OS X v10.8.)

OSStatus FNUnsubscribe (
   FNSubscriptionRef subscription
);
Parameters
subscription

A subscription previously returned from the FNSubscribe orFNSubscribeByPath functions.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSAllocateFork

Allocates space on a volume to an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use fcntl with F_PREALLOCATE instead.)

OSErr FSAllocateFork (
   FSIORefNum forkRefNum,
   FSAllocationFlags flags,
   UInt16 positionMode,
   SInt64 positionOffset,
   UInt64 requestCount,
   UInt64 *actualCount
);
Parameters
forkRefNum

The reference number of the open fork. You can obtain a fork reference number with the FSOpenFork function, or with one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

flags

A constant indicating how the new space should be allocated. See “Allocation Flags” for a description of the constants which you can use in this parameter.

positionMode

A constant specifying the base location for the start of the allocation. See “Position Mode Constants” for more information on the constants which you can use to specify the base location.

positionOffset

The offset from the base location of the start of the allocation.

requestCount

The number of bytes to allocate.

actualCount

On return, a pointer to the number of bytes actually allocated to the file. The value returned in here may be smaller than the number specified in the requestCount parameter if some of the space was already allocated. The value pointed to by the actualCount parameter does not reflect any additional bytes that may have been allocated because space is allocated in terms of fixed units such as allocation blocks, or the use of a clump size to reduce fragmentation.

The actualCount output is optional if you don’t want the number of allocated bytes returned, set actualCount to NULL.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSAllocateFork function attempts to allocate requestCount bytes of physical storage starting at the offset specified by the positionMode and positionOffset parameters. For volume formats that support preallocated space, you can later write to this range of bytes (including extending the size of the fork) without requiring an implicit allocation.

Any extra space allocated but not used will be deallocated when the fork is closed, using FSCloseFork , PBCloseForkSync , or PBCloseForkAsync ; or when the fork is flushed, using FSFlushFork , PBFlushForkSync , or PBFlushForkAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCancelVolumeOperation

Cancels an outstanding asynchronous volume mounting operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSCancelVolumeOperation (
   FSVolumeOperation volumeOp
);
Parameters
volumeOp

The asynchronous volume operation to cancel.

Return Value

A result code. See “File Manager Result Codes.”

Special Considerations

This function currently is only supported for server mounts.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCatalogSearch

Searches for objects traversed by a catalog iterator that match a given set of criteria. (Deprecated in OS X v10.8. Use Spotlight APIs instead; to learn more, see Spotlight Overview.)

OSErr FSCatalogSearch (
   FSIterator iterator,
   const FSSearchParams *searchCriteria,
   ItemCount maximumObjects,
   ItemCount *actualObjects,
   Boolean *containerChanged,
   FSCatalogInfoBitmap whichInfo,
   FSCatalogInfo *catalogInfos,
   FSRef *refs,
   FSSpecPtr specs,
   HFSUniStr255 *names
);
Parameters
iterator

The iterator to use. Objects traversed by this iterator are matched against the criteria specified by the searchCriteria parameter. You can obtain a catalog iterator with the function FSOpenIterator, or with one of the related parameter block calls, PBOpenIteratorSync and PBOpenIteratorAsync. Currently, this iterator must be created with the kFSIterateSubtree option and the container must be the root directory of a volume. See FSIterator for more information on the FSIterator data type.

searchCriteria

A pointer to a structure containing the search criteria.

You can match against the object’s name in Unicode and by the fields in an FSCatalogInfo structure. You may use the same search bits as passed in the ioSearchBits field to the PBCatSearchSync and PBCatSearchAsync functions; they control the corresponding FSCatalogInfo fields. See “Catalog Search Masks” for a description of the search bits.

There are a few new search criteria supported by FSCatalogSearch but not by PBCatSearchSync and PBCatSearchAsync. These new search criteria are indicated by the constants described in “Catalog Search Constants.”

If the searchTime field of this structure is non-zero, it is interpreted as a Time Manager duration; the search may terminate after this duration even if maximumObjects objects have not been returned and the entire catalog has not been scanned. If searchTime is zero, there is no time limit for the search.

If you are searching by any criteria other than name, you must set the searchInfo1 and searchInfo2 fields of the structure in this parameter to point to FSCatalogInfo structures containing the values to match against.

See FSSearchParams for a description of the FSSearchParams data type.

maximumObjects

The maximum number of items to return for this call.

actualObjects

On return, a pointer to the actual number of items found for this call.

containerChanged

On return, a pointer to a Boolean value indicating whether the container’s contents have changed. If true, the container’s contents changed since the previous FSCatalogSearch call. Objects may still be returned even though the container changed. Note that if the container has changed, then the total set of items returned may be incorrect; some items may be returned multiple times, and some items may not be returned at all.

This parameter is optional if you don’t want this information, pass a NULL pointer.

whichInfo

A bitmap specifying the catalog information fields to return for each item. If you don’t wish any catalog information returned, pass the constant kFSCatInfoNone in this parameter. See “Catalog Information Bitmap Constants” for a description of the bits in this parameter.

catalogInfos

A pointer to an array of catalog information structures; one for each found item. On input, the catalogInfos parameter should point to an array of maximumObjects catalog information structures.

This parameter is optional; if you do not wish any catalog information returned, pass NULL here.

See FSCatalogInfo for a description of the FSCatalogInfo data type.

refs

A pointer to an array of FSRef structures; one for each returned item. If you want an FSRef for each item found, set this parameter to point to an array of maximumObjectsFSRef structures. Otherwise, set it to NULL. See FSRef for a description of the FSRef data type.

specs
names

A pointer to an array of filenames; one for each returned item. If you want the Unicode filename for each item found, set this parameter to point to an array of maximumObjectsHFSUniStr255 structures. Otherwise, set it to NULL. See HFSUniStr255 for a description of the HFSUniStr255 data type.

Return Value

A result code. See “File Manager Result Codes.” When the entire volume has been searched, errFSNoMoreItems is returned.

Discussion

A single search may span more than one call to FSCatalogSearch. The call may complete with no error before scanning the entire volume. This typically happens because the time limit ( searchTime) has been reached or maximumObjects items have been returned. If the search is not completed, you can continue the search by making another call to FSCatalogSearch and passing the updated iterator returned by the previous call in the iterator parameter.

Before calling this function, you should determine that it is present, by calling the Gestalt function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCloseFork

Closes an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use close(2) OS X Developer Tools Manual Page instead. To close the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSCloseFork (
   FSIORefNum forkRefNum
);
Parameters
forkRefNum

The reference number of the fork to close. After the call to this function, the reference number in this parameter is invalid.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSCloseFork function causes all data written to the fork to be written to disk, in the same manner as the FSFlushFork function, before it closes the fork.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCloseIterator

Closes a catalog iterator. (Deprecated in OS X v10.8. Use NSDirectoryEnumerator or CFURLEnumerator APIs instead. For more information, see NSDirectoryEnumerator Class Reference and CFURLEnumerator Reference.)

OSErr FSCloseIterator (
   FSIterator iterator
);
Parameters
iterator

The catalog iterator to be closed. FSCloseIterator releases memory and other system resources used by the iterator, making the iterator invalid. See FSIterator for a description of the FSIterator data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function releases memory and other system resources used by the iterator. The iterator becomes invalid.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSCompareFSRefs

Determines whether two FSRef structures refer to the same file or directory. (Deprecated in OS X v10.8. Use NSURL or CFURL APIs instead. To compare two file URLs to see if they have the same file system path or if the paths are linked to same inode on the same file system, use the NSURLFileResourceIdentifierKey or kCFURLFileResourceIdentifierKey properties.)

OSErr FSCompareFSRefs (
   const FSRef *ref1,
   const FSRef *ref2
);
Parameters
ref1

A pointer to the first FSRef to compare. For a description of the FSRef data type, see FSRef.

ref2

A pointer to the second FSRef to compare.

Return Value

A result code. See “File Manager Result Codes.” If the two FSRef structures refer to the same file or directory, then noErr is returned. If they refer to objects on different volumes, then diffVolErr is returned. If they refer to different files or directories on the same volume, then errFSRefsDifferent is returned. This function may return other errors, including nsvErr, fnfErr, dirNFErr, and volOffLinErr.

Discussion

You must use FSCompareFSRefs, or one of the corresponding parameter block functions, PBCompareFSRefsSync and PBCompareFSRefsAsync , to compare FSRef structures. It is not possible to compare the FSRef structures directly since some bytes may be uninitialized, case-insensitive text, or contain hint information.

Some volume formats may be able to tell that two FSRef structures would refer to two different files or directories, without having to actually find those objects. In this case, the volume format may return errFSRefsDifferent even if one or both objects no longer exist. Similarly, if the FSRef structures are for objects on different volumes, the File Manager will return diffVolErr even if one or both volumes are no longer mounted.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCopyDADiskForVolume

Gets a copy of the disk ID for the given volume. (Deprecated in OS X v10.8. Use DADiskCreateFromVolumePath instead.)

OSStatus  FSCopyDADiskForVolume(FSVolumeRefNum vRefNum, DADiskRef *disk);
Parameters
vRefNum

The reference number of the volume that corresponds to the disk.

disk

The DADiskRef of the target volume.

Return Value

Returns a copy of the diskID for the given volume.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCopyDiskIDForVolume

Returns a copy of the disk ID for a volume. (Deprecated in OS X v10.8. Use DADiskCreateFromVolumePath instead.)

OSStatus FSCopyDiskIDForVolume (
   FSVolumeRefNum vRefNum,
   CFStringRef *diskID
);
Parameters
vRefNum

The volume reference number of the target volume.

diskID

A pointer to a Core Foundation string. On return, the string contains the disk ID associated with the target volume. The caller is responsible for releasing the string.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSCopyObjectAsync

Starts an asynchronous file operation to copy a source object to a destination directory. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSCopyObjectAsync (
   FSFileOperationRef fileOp,
   const FSRef *source,
   const FSRef *destDir,
   CFStringRef destName,
   OptionBits flags,
   FSFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this copy operation.

source

A pointer to the source object to copy. The object can be a file or a directory.

destDir

A pointer to the destination directory.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

flags

One or more file operation option flags. See “File Operation Options.”

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you specify a status callback function, status callbacks will occur in one of the run loop and mode combinations with which you scheduled the file operation.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCopyObjectSync

Copies a source object to a destination directory. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSCopyObjectSync (
   const FSRef *source,
   const FSRef *destDir,
   CFStringRef destName,
   FSRef *target,
   OptionBits options
);
Parameters
source

A pointer to the source object to copy. The object can be a file or a directory.

destDir

A pointer to the destination directory.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

target

A pointer to an FSRef variable that, on output, refers to the new object in the destination directory. This parameter is optional; pass NULL if you don’t need to refer to the new object.

options

One or more file operation option flags. See “File Operation Options.”

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function could take a significant amount of time to execute. To avoid blocking your user interface, you should either call this function in a thread other than the main thread or use FSCopyObjectAsync instead.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCopyURLForVolume

Returns a copy of the URL for a volume. (Deprecated in OS X v10.8. To get the URL for a volume, use the NSURLVolumeURLKey (or kCFURLVolumeURLKey) properties instead. To get the URL required to remount a network volume, use the NSURLVolumeURLForRemountingKey (or kCFURLVolumeURLForRemountingKey) properties instead.)

OSStatus FSCopyURLForVolume (
   FSVolumeRefNum vRefNum,
   CFURLRef *url
);
Parameters
vRefNum

The volume reference number of the target volume.

url

A pointer to a CFURLRef variable allocated by the caller. On return, a Core Foundation URL that specifies the location of the target volume. The caller is responsible for releasing the URL.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.3 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSCreateDirectoryUnicode

Creates a new directory (folder) with a Unicode name. (Deprecated in OS X v10.8. At the Foundation layer, use createDirectoryAtURL:withIntermediateDirectories:attributes:error: instead. At the POSIX/BSD layer, use mkdir(2) OS X Developer Tools Manual Page instead.)

OSErr FSCreateDirectoryUnicode (
   const FSRef *parentRef,
   UniCharCount nameLength,
   const UniChar *name,
   FSCatalogInfoBitmap whichInfo,
   const FSCatalogInfo *catalogInfo,
   FSRef *newRef,
   FSSpecPtr newSpec,
   UInt32 *newDirID
);
Parameters
parentRef

A pointer to an FSRef specifying the parent directory where the new directory is to be created. See FSRef for a description of the FSRef data type.

nameLength

The length of the new directory's Unicode name.

name

A pointer to the Unicode name of the new directory.

whichInfo

A bitmap specifying which catalog information fields to set for the new directory. Specify the values for these fields in the catalogInfo parameter.

If you do not wish to set catalog information for the new directory, specify the constant kFSCatInfoNone. See “Catalog Information Bitmap Constants” for a description of the bits defined for this parameter.

catalogInfo

A pointer to the FSCatalogInfo structure which specifies the values for the catalog information fields for the new directory. Specify which fields to set in the whichInfo parameter.

This parameter is optional; specify NULL if you do not wish to set catalog information for the new directory.

See FSCatalogInfo for a description of the FSCatalogInfo data type.

newRef

On return, a pointer to the FSRef for the new directory. This parameter is optional; specify NULL if you do not want the FSRef returned.

newSpec

On return, a pointer to the FSSpec for the new directory. This parameter is optional; specify NULL if you do not want the FSSpec returned. See FSSpec for a description of the FSSpec data type.

newDirID

On return, a pointer to the directory ID of the directory. This parameter is optional; specify NULL if you do not want the directory ID returned.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

You may optionally set catalog information for the new directory using the whichInfo and catalogInfo parameters; this is equivalent to calling FSSetCatalogInfo , or one of the corresponding parameter block functions, PBSetCatalogInfoSync and PBSetCatalogInfoAsync , after creating the directory.

If possible, you should set the textEncodingHint field of the catalog information structure specified in the catalogInfo parameter. This will be used by the volume format when converting the Unicode filename to other encodings.

Special Considerations

If the FSCreateDirectoryUnicode function is present, but is not implemented by a particular volume, the File Manager will emulate this function by making the appropriate call to PBDirCreateSync. However, if the function is not directly supported by the volume, you will not be able to use the long Unicode directory names, or other features added with HFS Plus.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCreateFileAndOpenForkUnicode

Creates a new file and opens the specified fork. (Deprecated in OS X v10.8. At the Foundation layer, use createFileAtPath:contents:attributes: or writeToFile:options:error: instead. At the POSIX/BSD layer, use open(2) OS X Developer Tools Manual Page with O_CREAT and O_EXCL flags instead.)

CodeLine
Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCreateFileUnicode

Creates a new file with a Unicode name. (Deprecated in OS X v10.8. At the Foundation layer, use createFileAtPath:contents:attributes: or writeToFile:options:error: instead. At the POSIX/BSD layer, use open(2) OS X Developer Tools Manual Page with O_CREAT and O_EXCL flags instead.)

OSErr FSCreateFileUnicode (
   const FSRef *parentRef,
   UniCharCount nameLength,
   const UniChar *name,
   FSCatalogInfoBitmap whichInfo,
   const FSCatalogInfo *catalogInfo,
   FSRef *newRef,
   FSSpecPtr newSpec
);
Parameters
parentRef

A pointer to an FSRef for the directory where the file is to be created. See FSRef for a description of the FSRef data type.

nameLength

The length of the file's name.

name

A pointer to the Unicode name for the new file.

whichInfo

A bitmap specifying which catalog information fields to set for the new file. You specify the values for these fields in the catalogInfo parameter. If you do not wish to set catalog information for the new file, pass the constant kFSCatInfoNone. See “Catalog Information Bitmap Constants” for a description of the bits defined for this parameter.

catalogInfo

A pointer to the FSCatalogInfo structure which specifies the values of the new file’s catalog information. Specify which fields to set in the whichInfo parameter.

This parameter is optional; specify NULL if you do not wish to set catalog information for the new file.

newRef

On return, a pointer to the FSRef for the new file. If you do not want the FSRef returned, specify NULL.

newSpec

On return, a pointer to the FSSpec for the new file. If you do not want the FSSpec returned, specify NULL. See FSSpec for a description of the FSSpec data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

You may optionally set catalog information for the new file using the whichInfo and catalogInfo parameters; this is equivalent to calling FSSetCatalogInfo , or one of the corresponding parameter block functions, PBSetCatalogInfoSync and PBSetCatalogInfoAsync , after creating the file.

If possible, you should set the textEncodingHint field of the catalog information structure specified in the catalogInfo parameter. This will be used by the volume format when converting the Unicode filename to other encodings.

Special Considerations

If the FSCreateFileUnicode function is present, but is not implemented by a particular volume, the File Manager will emulate this function by making the appropriate call to PBHCreateSync. However, if the function is not directly supported by the volume, you will not be able to use the long Unicode filenames, or other features added with HFS Plus.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSCreateFork

Creates a named fork for a file or directory. (Deprecated in OS X v10.8. At the POSIX/BSD layer, the data fork is created when you use truncate or write(2) OS X Developer Tools Manual Page to set EOF to a value greater than 0.)

OSErr FSCreateFork (
   const FSRef *ref,
   UniCharCount forkNameLength,
   const UniChar *forkName
);
Parameters
ref

A pointer to an FSRef specifying the file or directory. See FSRef for a description of the FSRef data type.

forkNameLength

The length of the name of the new fork.

forkName

A pointer to the Unicode name of the fork.

Return Value

A result code. See “File Manager Result Codes.” If the named fork already exists, the function returns errFSForkExists. If the fork name is syntactically invalid or otherwise unsupported for the given volume, FSCreateFork returns errFSBadForkName or errFSNameTooLong.

Discussion

A newly created fork has zero length (that is, its logical end-of-file is zero). The data and resource forks of a file are automatically created and deleted as needed. This is done for compatibility with older APIs, and because data and resource forks are often handled specially. If a given fork always exists for a given volume format (such as data and resource forks for HFS and HFS Plus, or data forks for most other volume formats), an attempt to create that fork when a zero-length fork already exists should return noErr; if a non-empty fork already exists then errFSForkExists should be returned.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSCreateVolumeOperation

Returns an FSVolumeOperation which can be used for an asynchronous volume operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSCreateVolumeOperation (
   FSVolumeOperation *volumeOp
);
Parameters
volumeOp

The new FSVolumeOperation.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

When the operation is completed the FSVolumeOperation should be disposed of to free the memory associated with the operation using FSDisposeVolumeOperation.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSDeleteFork

Deletes a named fork from a file or directory. (Deprecated in OS X v10.8. At the POSIX/BSD layer, the data fork is deleted when you set the EOF value to 0 using truncate with a length of 0. The resource fork is deleted by deleting the XATTR_RESOURCEFORK_NAME extended attribute with removexattr.)

OSErr FSDeleteFork (
   const FSRef *ref,
   UniCharCount forkNameLength,
   const UniChar *forkName
);
Parameters
ref

A pointer to an FSRef for the file or directory from which to delete the fork. See FSRef for a description of the FSRef data type.

forkNameLength

The length of the Unicode name of the fork name.

forkName

A pointer to the Unicode name of the fork to delete.

Return Value

A result code. See “File Manager Result Codes.” If the named fork does not exist, the function returns errFSForkNotFound.

Discussion

Any storage allocated to the fork is released. If a given fork always exists for a given volume format (such as data and resource forks for HFS and HFS Plus, or data forks for most other volume formats), this is equivalent to setting the logical size of the fork to zero.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSDeleteObject

Deletes a file or an empty directory. (Deprecated in OS X v10.8. At the Foundation layer, use removeItemAtURL:error: instead. At the POSIX/BSD layer, use rmdir(2) OS X Developer Tools Manual Page for directories, or unlink(2) OS X Developer Tools Manual Page for files, instead.)

OSErr FSDeleteObject (
   const FSRef *ref
);
Parameters
ref

A pointer to an FSRef specifying the file or directory to be deleted. If the object to be deleted is a directory, it must be empty (it must contain no files or folders). See FSRef for a description of the FSRef data type.

Return Value

A result code. See “File Manager Result Codes.” If you attempt to delete a folder for which there is an open catalog iterator, this function succeeds and returns noErr. Iteration, however, will continue to work until the iterator is closed.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSDisposeVolumeOperation

Releases the memory associated with a volume operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSDisposeVolumeOperation (
   FSVolumeOperation volumeOp
);
Parameters
volumeOp

The FSVolumeOperation to release.

Return Value

A result code. See “File Manager Result Codes.” This function will return paramErr if the FSVolumeOperation is in use.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSEjectVolumeAsync

Asynchronously ejects a volume. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSEjectVolumeAsync (
   FSVolumeRefNum vRefNum,
   OptionBits flags,
   FSVolumeOperation volumeOp,
   void *clientData,
   FSVolumeEjectUPP callback,
   CFRunLoopRef runloop,
   CFStringRef runloopMode
);
Parameters
vRefNum

The volume reference number of the volume to eject.

flags

Options for future use.

volumeOp

An FSVolumeOperation returned by FSCreateVolumeOperation.

clientData

A pointer to client data associated with the operation. This parameter can be NULL.

callback

The function to call when eject is complete.

runloop

The runloop to run on.

runloopMode

The mode for the runloop.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function starts the process of ejecting the volume specified by the vRefNum parameter. If a callback function is provided, that function will be called when the eject operation is complete. Once this function returns noErr the status of the operation can be found using FSGetAsyncEjectStatus.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSEjectVolumeSync

Ejects a volume. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSEjectVolumeSync (
   FSVolumeRefNum vRefNum,
   OptionBits flags,
   pid_t *dissenter
);
Parameters
vRefNum

The volume reference number of the volume to eject.

flags

Options for future use.

dissenter

On return, a pointer to the pid of the process which denied the unmount if the eject is denied.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function ejects the volume specified by the vRefNum parameter. If the volume cannot be ejected the pid of the process which denied the unmount will be returned in the dissenter parameter. This function returns after the eject is complete. Ejecting a volume will result in the unmounting of other volumes on the same device.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSExchangeObjects

Swaps the contents of two files. (Deprecated in OS X v10.8. At the Foundation layer, use replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: instead.)

OSErr FSExchangeObjects (
   const FSRef *ref,
   const FSRef *destRef
);
Parameters
ref

A pointer to an FSRef for the first file. See FSRef for a description of the FSRef data type.

destRef

A pointer to an FSRef for the second file.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSExchangeObjects function allows programs to implement a “safe save” operation by creating and writing a complete new file and swapping the contents. An alias, FSSpec, or FSRef that refers to the old file will now access the new data. The corresponding information in in-memory data structures are also exchanged.

Either or both files may have open access paths. After the exchange, the access path will refer to the opposite file’s data (that is, to the same data it originally referred, which is now part of the other file).

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationCancel

Cancels an asynchronous file operation. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSFileOperationCancel (
   FSFileOperationRef fileOp
);
Parameters
fileOp

The file operation to cancel.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function makes the specified file operation ineligible to run on any run loop. You may call this function at any time during the operation. Typically, you would use this function if the user cancels the operation. Note that to release your file operation object, you still need to call CFRelease.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationCopyStatus

Gets a copy of the current status information for an asynchronous file operation. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSFileOperationCopyStatus (
   FSFileOperationRef fileOp,
   FSRef *currentItem,
   FSFileOperationStage *stage,
   OSStatus *error,
   CFDictionaryRef *statusDictionary,
   void **info
);
Parameters
fileOp

The file operation to access.

currentItem

A pointer to an FSRef variable. On output, the variable contains the object currently being moved or copied. If the operation is complete, this parameter refers to the target (the new object corresponding to the source object in the destination directory).

stage

A pointer to a file operation stage variable. On output, the variable contains the current stage of the file operation.

error

A pointer to an error status variable. On output, the variable contains the current error status of the file operation.

statusDictionary

A pointer to a dictionary variable. On output, the variable contains a dictionary with more detailed status information. For information about the contents of the dictionary, see “File Operation Status Dictionary Keys”. You should release the dictionary when you are finished using it.

info

A pointer to a generic pointer. On output, the generic pointer refers to user-defined data associated with this file operation.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationCreate

Creates an object that represents an asynchronous file operation. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

FSFileOperationRef FSFileOperationCreate (
   CFAllocatorRef alloc
);
Parameters
alloc

The allocator to use. Pass NULL for the default allocator.

Return Value

A new FSFileOperation object, or NULL if the object could not be created. When you no longer need the object, you should release it by calling CFRelease.

Discussion

Before passing a file operation object to a function that starts an asynchronous copy or move operation, you should schedule the file operation using the function FSFileOperationScheduleWithRunLoop.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationGetTypeID

Returns the Core Foundation type identifier for the FSFileOperation opaque type. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

CFTypeID FSFileOperationGetTypeID (
   void
);
Return Value

The type identifier for the FSFileOperation opaque type. For information about this type, see FSFileOperationRef.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationScheduleWithRunLoop

Schedules an asynchronous file operation with the specified run loop and mode. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSFileOperationScheduleWithRunLoop (
   FSFileOperationRef fileOp,
   CFRunLoopRef runLoop,
   CFStringRef runLoopMode
);
Parameters
fileOp

The file operation to schedule.

runLoop

The run loop in which to schedule the operation. For information about Core Foundation run loops, see Run Loops.

runLoopMode

The run loop mode in which to schedule the operation. In most cases, you may specify kCFRunLoopCommonModes.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

To run, a file operation must be scheduled with at least one run loop. A file operation can be scheduled with multiple run loop and mode combinations.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileOperationUnscheduleFromRunLoop

Unschedules an asynchronous file operation from the specified run loop and mode. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSFileOperationUnscheduleFromRunLoop (
   FSFileOperationRef fileOp,
   CFRunLoopRef runLoop,
   CFStringRef runLoopMode
);
Parameters
fileOp

The file operation to unschedule.

runLoop

The run loop on which to unschedule the operation.

runLoopMode

The run loop mode in which to unschedule the operation.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecurityCopyAccessControlList

Copies the access control list associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityCopyAccessControlList instead.)

OSStatus  FSFileSecurityCopyAccessControlList(FSFileSecurityRef fileSec, acl_t *accessControlList);
Parameters
fileSec

The FSFileSecurityRef object.

accessControlList

A pointer to an acl_t object.

Return Value

Returns a copy of the acl_t object or errFSPropertyNotValid if there is no associated ACL property.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityCreate

Creates an FSFileSecurity object. (Deprecated in OS X v10.8. Use CFFileSecurityCreate instead.)

FSFileSecurityRef  FSFileSecurityCreate(CFAllocatorRef alloc);
Parameters
alloc

The CFAllocator to use.

Return Value

Returns a new FSFileSecurity object or NULL if the creation failed.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecurityCreateWithFSPermissionInfo

Creates an FSFileSecurity object with the given permission information. (Deprecated in OS X v10.8. Use CFFileSecurity APIs instead (see CFFileSecurity Reference).)

FSFileSecurityRef  FSFileSecurityCreateWithFSPermissionInfo(CFAllocatorRef alloc, const FSPermissionInfo *permissions);
Parameters
alloc

The CFAllocator to use.

permissions

A structure that contains the user and group permission information for an access mode.

Return Value

A reference to the newly created object or NULL if the creation failed.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecurityGetGroup

Gets the group ID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityGetGroup instead.)

OSStatus  FSFileSecurityGetGroup(FSFileSecurityRef fileSec, UInt32 *group);
Parameters
fileSec

The FSFileSecurityRef object.

group

The group ID associated with the FSFileSecurityRef object.

Return Value

Returns the group ID associated with the FSFileSecurityRef object or errFSPropertyNotValid if there is no associated group.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityGetGroupUUID

Gets the group UUID associated with a FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityCopyGroupUUID instead.)

OSStatus  FSFileSecurityGetGroupUUID(FSFileSecurityRef fileSec, CFUUIDBytes *group);
Parameters
fileSec

The FSFileSecurityRef object.

group

A pointer to storage for the group UUID associated with fileSec.

Return Value

Returns the group UUID associated with the given FSFileSecurityRef object or errFSPropertyNotValid if there is no associated group.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityGetMode

Gets the mode ID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityGetMode instead.)

OSStatus  FSFileSecurityGetMode(FSFileSecurityRef fileSec, UInt32 *mode);
Parameters
fileSec

The FSFileSecurityRef object.

mode

The mode ID associated with the FSFileSecurityRef object.

Return Value

Returns the mode ID associated with the FSFileSecurityRef object or errFSPropertyNotValid if there is no associated mode.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityGetOwner

Gets the owner ID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityGetOwner instead.)

OSStatus  FSFileSecurityGetOwner(FSFileSecurityRef fileSec, UInt32 *owner);
Parameters
fileSec

The FSFileSecurityRef object.

owner

The owner ID associated with the FSFileSecurityRef object.

Return Value

Returns the owner ID associated with the FSFileSecurityRef object or errFSPropertyNotValid if there is no associated owner.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityGetOwnerUUID

Gets the owner UUID associated with a FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityCopyOwnerUUID instead.)

OSStatus  FSFileSecurityGetOwnerUUID(FSFileSecurityRef fileSec, CFUUIDBytes *owner);
Parameters
fileSec

The FSFileSecurityRef object.

owner

A pointer to storage for the owner UUID associated with fileSec.

Return Value

Returns the owner UUID associated with the given FSFileSecurityRef object or errFSPropertyNotValid if there is no associated owner.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSFileSecurityGetTypeID

Gets the type of the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecurityGetTypeID instead.)

CFTypeID  FSFileSecurityGetTypeID(void);
Return Value

Returns the CFTypeID for the given FSFileSecurityRef object.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecurityRefCreateCopy

Creates a copy of an FSFileSecurity object. (Deprecated in OS X v10.8. Use CFFileSecurityCreateCopy instead.)

FSFileSecurityRef  FSFileSecurityRefCreateCopy(CFAllocatorRef alloc, FSFileSecurityRef fileSec);
Parameters
alloc

The CFAllocator to use.

fileSec

The FSFileSecurity object to copy.

Return Value

Returns a new FSFileSecurity or NULL if the creation failed.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetAccessControlList

Sets the access control list (ACL) associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetAccessControlList instead.)

OSStatus  FSFileSecuritySetAccessControlList(FSFileSecurityRef fileSec, acl_t accessControlList);
Parameters
fileSec

The FSFileSecurityRef object.

accessControlList

The access control list to set or kFSFileSecurityRemoveACL to request removal of an ACL from the given FSFileSecurityRef object, or NULL to unset the property.

Return Value

Returns success if the ACL was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetGroup

Sets the group ID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetGroup instead.)

OSStatus  FSFileSecuritySetGroup(FSFileSecurityRef fileSec, UInt32 group);
Parameters
fileSec

The FSFileSecurityRef object.

group

The group UUID to set.

Return Value

Returns success if the group UUID was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetGroupUUID

Sets the group UUID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetGroupUUID instead.)

OSStatus  FSFileSecuritySetGroupUUID(FSFileSecurityRef fileSec, const CFUUIDBytes *group);
Parameters
fileSec

The FSFileSecurityRef object.

group

The group UUID to set.

Return Value

Returns success if the group UUID was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetMode

Sets the mode associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetMode instead.)

OSStatus  FSFileSecuritySetMode(FSFileSecurityRef fileSec, UInt16 mode);
Parameters
fileSec

The FSFileSecurityRef object.

mode

The file mode associated with the FSFileSecurityRef object.

Return Value

Returns success if the mode was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetOwner

Sets the owner ID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetOwner instead.)

OSStatus  FSFileSecuritySetOwner(FSFileSecurityRef fileSec, UInt32 owner);
Parameters
fileSec

The FSFileSecurityRef object.

owner

The owner UUID to set.

Return Value

Returns success if the owner UUID was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFileSecuritySetOwnerUUID

Sets the owner UUID associated with the given FSFileSecurityRef object. (Deprecated in OS X v10.8. Use CFFileSecuritySetOwnerUUID instead.)

OSStatus  FSFileSecuritySetOwnerUUID(FSFileSecurityRef fileSec, const CFUUIDBytes *owner);
Parameters
fileSec

The FSFileSecurityRef object.

owner

The owner UUID to set.

Return Value

Returns success if the owner UUID was set.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFlushFork

Causes all data written to an open fork to be written to disk. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use fsync instead. To flush the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSFlushFork (
   FSIORefNum forkRefNum
);
Parameters
forkRefNum

The reference number of the fork to flush.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

The FSFlushFork function causes the actual fork contents to be written to disk, as well as any other volume structures needed to access the fork. On HFS and HFS Plus, this includes the catalog, extents, and attribute B-trees; the volume bitmap; and the volume header and alternate volume header (the MDB and alternate MDB on HFS volumes), as needed.

On volumes that do not support FSFlushFork directly, the entire volume is flushed to be sure all volume structures associated with the fork are written to disk.

You do not, need to use FSFlushFork to flush a file fork before it is closed; the file is automatically flushed when it is closed and all cache blocks associated with it are removed from the cache.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSFlushVolume

For the specified volume, writes all open and modified files in the current process to permanent storage. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use sync_volume_np(3) instead.)

OSStatus FSFlushVolume (
   FSVolumeRefNum vRefNum
);
Parameters
vRefNum

The volume reference number of the volume to flush.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetAsyncEjectStatus

Returns the current status of an asynchronous eject operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSGetAsyncEjectStatus (
   FSVolumeOperation volumeOp,
   FSEjectStatus *status,
   OSStatus *volumeOpStatus,
   FSVolumeRefNum *volumeRefNum,
   pid_t *dissenter,
   void **clientData
);
Parameters
volumeOp

The asynchronous volume operation to get status about.

status

On return, a pointer to the status of the operation.

volumeOpStatus

If the status parameter is kAsyncEjectComplete then this contains the result code (OSStatus) for the operation on return.

volumeRefNum

On return, the volume reference number of the volume being ejected.

dissenter

On return, a pointer to the pid of the process which denied the unmount if the eject is denied.

clientData

On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.

Return Value

A result code. See “File Manager Result Codes.” A return value of noErr signifies that the status parameter has been filled with valid information.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetAsyncMountStatus

Returns the current status of an asynchronous mount operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSGetAsyncMountStatus (
   FSVolumeOperation volumeOp,
   FSMountStatus *status,
   OSStatus *volumeOpStatus,
   FSVolumeRefNum *mountedVolumeRefNum,
   void **clientData
);
Parameters
volumeOp

The asynchronous volume operation to get status about.

status

On return, a pointer to the status of the operation.

volumeOpStatus

If the status is kAsyncMountComplete then this parameter contains the result code for the operation on return.

mountedVolumeRefNum

If the status is kAsyncMountComplete and the volumeOpStatus parameter is noErr then this is the volume reference number for the newly mounted volume, on return.

clientData

On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

A return value of noErr signifies that the status parameter has been filled with valid information. If the status is kAsyncMountComplete then the rest of data returned is valid. If the status is anything else then the volumeOpStatus and mountedVolumeRefNum parameters are invalid, but the clientData parameter is valid.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetAsyncUnmountStatus

Returns the current status of an asynchronous unmount operation. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSGetAsyncUnmountStatus (
   FSVolumeOperation volumeOp,
   FSUnmountStatus *status,
   OSStatus *volumeOpStatus,
   FSVolumeRefNum *volumeRefNum,
   pid_t *dissenter,
   void **clientData
);
Parameters
volumeOp

The asynchronous volume operation to get status about.

status

On return, a pointer to the status of the operation.

volumeOpStatus

If the status is kAsyncUnmountComplete then this parameter contains a pointer to the result code (OSStatus) for the operation on return.

volumeRefNum

On return, a pointer to the volume reference number of the volume being unmounted.

dissenter

On return, a pointer to the pid of the process which denied the unmount if the unmount is denied.

clientData

On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.

Return Value

A result code. See “File Manager Result Codes.” A return value of noErr signifies that the status parameter has been filled with valid information.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetCatalogInfo

Returns catalog information about a file or directory. You can use this function to map an FSRef to an FSSpec. (Deprecated in OS X v10.8. At the Foundation layer, use getResourceValue:forKey:error: or resourceValuesForKeys:error: instead. At the Core Foundation layer, use CFURLCopyResourcePropertyForKey or CFURLCopyResourcePropertiesForKeys instead.)

OSErr FSGetCatalogInfo (
   const FSRef *ref,
   FSCatalogInfoBitmap whichInfo,
   FSCatalogInfo *catalogInfo,
   HFSUniStr255 *outName,
   FSSpecPtr fsSpec,
   FSRef *parentRef
);
Parameters
ref

A pointer to an FSRef specifying the file or directory for which to retrieve information. See FSRef for a description of the FSRef data type.

whichInfo

A bitmap specifying the catalog information fields to return. If you don’t want any catalog information, set whichInfo to the constant kFSCatInfoNone. See “Catalog Information Bitmap Constants” for a description of the bits in this parameter.

catalogInfo

On return, a pointer to a catalog information structure containing the information about the file or directory. Only the information specified in the whichInfo parameter is returned. If you don’t want any catalog information, pass NULL here. See FSCatalogInfo for a description of the FSCatalogInfo data type.

outName

On return, a pointer to the Unicode name of the file or directory is returned here. This parameter is optional; if you do not wish the name returned, pass NULL here. See HFSUniStr255 for a description of the HFSUniStr255 data type.

fsSpec

On return, a pointer to the FSSpec for the file or directory. This parameter is optional; if you do not wish the FSSpec returned, pass NULL here. See FSSpec for a description of the FSSpec data type.

parentRef

On return, a pointer to the FSRef for the object's parent directory. This parameter is optional; if you do not wish the parent directory returned, pass NULL here.

If the object specified in the ref parameter is a volume’s root directory, then the FSRef returned here will not be a valid FSRef, since the root directory has no parent object.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetCatalogInfoBulk

Returns information about one or more objects from a catalog iterator. This function can return information about multiple objects in a single call. (Deprecated in OS X v10.8. Use NSDirectoryEnumerator or CFURLEnumerator APIs instead. For more information, see NSDirectoryEnumerator Class Reference and CFURLEnumerator Reference.)

OSErr FSGetCatalogInfoBulk (
   FSIterator iterator,
   ItemCount maximumObjects,
   ItemCount *actualObjects,
   Boolean *containerChanged,
   FSCatalogInfoBitmap whichInfo,
   FSCatalogInfo *catalogInfos,
   FSRef *refs,
   FSSpecPtr specs,
   HFSUniStr255 *names
);
Parameters
iterator

The iterator to use. You can obtain a catalog iterator with the function FSOpenIterator, or with one of the related parameter block calls, PBOpenIteratorSync and PBOpenIteratorAsync. Currently, the iterator must be created with the kFSIterateFlat option. See FSIterator for a description of the FSIterator data type.

maximumObjects

The maximum number of items to return for this call.

actualObjects

On return, a pointer to the actual number of items found for this call.

containerChanged

On return, a pointer to a value indicating whether or not the container’s contents have changed since the previous FSGetCatalogInfoBulk call. If true, the contents have changed. Objects may still be returned, even though the container has changed. If so, note that if the container has changed, then the total set of items returned may be incorrect: some items may be returned multiple times, and some items may not be returned at all.

This parameter is optional if you don’t want this information returned, pass a NULL pointer.

In OS X version 10.2 and later, this parameter is always set to false. To find out whether the container has changed since the last call to FSGetCatalogInfoBulk, check the modification date of the container.

whichInfo

A bitmap specifying the catalog information fields to return for each item. If you don’t wish any catalog information returned, pass the constant kFSCatInfoNone in this parameter. For a description of the bits in this parameter, see “Catalog Information Bitmap Constants.”

catalogInfos

A pointer to an array of catalog information structures; one for each returned item. On input, the catalogInfos parameter should point to an array of maximumObjects catalog information structures.

This parameter is optional; if you do not wish any catalog information returned, pass NULL here.

refs

A pointer to an array of FSRef structures; one for each returned item. On input, this parameter should to point to an array of maximumObjectsFSRef structures.

This parameter is optional; if you do not wish any FSRef structures returned, pass NULL here.

specs

A pointer to an array of FSSpec structures; one for each returned item. On input, this parameter should to point to an array of maximumObjectsFSSpec structures.

This parameter is optional; if you do not wish any FSSpec structures returned, pass NULL here.

names

A pointer to an array of names; one for each returned item. If you want the Unicode name for each item found, set this parameter to point to an array of maximumObjectsHFSUniStr255 structures. Otherwise, set it to NULL.

Return Value

A result code. See “File Manager Result Codes.” When all of the iterator’s objects have been returned, the call will return errFSNoMoreItems.

Discussion

The FSGetCatalogInfoBulk call may complete and return noErr with fewer than maximumObjects items returned. This may be due to various reasons related to the internal implementation. In this case, you may continue to make FSGetCatalogInfoBulk calls using the same iterator.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetDataForkName

Returns a Unicode string constant for the name of the data fork. (Deprecated in OS X v10.8.)

OSErr FSGetDataForkName (
   HFSUniStr255 *dataForkName
);
Parameters
dataForkName

On input, a pointer to an HFSUniStr255 structure. On return, this structure contains the Unicode name of the data fork. Currently, this is the empty string. See HFSUniStr255 for a description of the HFSUniStr255 data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

There is no parameter block-based form of this call since it is not dispatched to individual volume formats, and does not require any I/O.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetForkCBInfo

Returns information about a specified open fork, or about all open forks. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use fstat(2) OS X Developer Tools Manual Page and lseek(2) OS X Developer Tools Manual Page instead.)

OSErr FSGetForkCBInfo (
   FSIORefNum desiredRefNum,
   FSVolumeRefNum volume,
   short *iterator,
   FSIORefNum *actualRefNum,
   FSForkInfo *forkInfo,
   FSRef *ref,
   HFSUniStr255 *outForkName
);
Parameters
desiredRefNum

If you want information on a specific fork, set this parameter to that fork’s reference number, and pass NULL in the iterator parameter. If you pass a non-zero value in this parameter, the function attempts to get information on the fork specified by that reference number.

Pass zero in this parameter to iterate over all open forks. You can limit this iteration to a specific volume with the volume parameter.

volume

The volume to search, when iterating over multiple forks. To iterate over all open forks on a single volume, specify the volume reference number in this parameter. To iterate over all open forks on all volumes, set this parameter to the constant kFSInvalidVolumeRefNum.

This parameter is ignored if you specify a fork reference number in the desiredRefNum parameter. Set desiredRefNum to zero if you wish to iterate over multiple forks.

See FSVolumeRefNum for a description of the FSVolumeRefNum data type.

iterator

A pointer to an iterator. If the desiredRefNum parameter is 0, the iterator maintains state between calls to FSGetForkCBInfo. Set the iterator parameter to 0 before you begin iterating, on the first call to FSGetForkCBInfo. On return, the iterator will be updated; pass this updated iterator in the iterator parameter of the next call to FSIterateForks to continue iterating.

actualRefNum

On return, a pointer to the reference number of the open fork. This parameter is optional if you do not wish to retrieve the fork’s reference number, pass NULL.

forkInfo

On return, a pointer to an FSForkInfo structure containing information about the open fork. This parameter is optional; if you do not wish this information returned, set forkInfo to NULL. See FSForkInfo for a description of the FSForkInfo data type.

On OS X, the value returned by FSGetForkCBInfo in the physicalEOF field of the FSForkInfo structure may differ from the physical file length reported by FSGetCatalogInfo, PBGetCatInfo, and related functions. When a write causes a file to grow in size, the physical length reported by FSGetCatalogInfo and similar calls increases by the clump size, which is a multiple of the allocation block size. However, the physical length returned by FSGetForkCBInfo changes according to the allocation block size and the file lengths returned by the respective functions get out of sync.

ref

On return, a pointer to the FSRef for the file or directory that contains the fork. This parameter is optional; if you do not wish to retrieve the FSRef, set ref to NULL. See FSRef for a description of the FSRef data type.

outForkName

On return, a pointer to the name of the fork. This parameter is optional; if you do not wish the name returned, set outForkName to NULL. See HFSUniStr255 for a description of the HFSUniStr255 data type.

Return Value

A result code. See “File Manager Result Codes.” If you are iterating over multiple forks, the function returns errFSNoMoreItems if there are no more open forks to return.

Discussion

Carbon applications are no longer guaranteed access to the FCB table. Instead, applications should use FSGetForkCBInfo, or one of the related parameter block functions, PBGetForkCBInfoSync and PBGetForkCBInfoAsync , to access information about a fork control block.

Special Considerations

Returning the fork information in the forkInfo parameter generally does not require a disk access; returning the information in the ref or forkName parameters may cause disk access for some volume formats.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetForkPosition

Returns the current position of an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use lseek with SEEK_CUR and an offset of 0. To get the position of the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSGetForkPosition (
   FSIORefNum forkRefNum,
   SInt64 *position
);
Parameters
forkRefNum

The reference number of a fork previously opened by the FSOpenFork function or one of its corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

position

On return, a pointer to the current position of the fork. The returned fork position is relative to the start of the fork (that is, it is an absolute offset in bytes).

Return Value

A result code. See “File Manager Result Codes.”

Special Considerations

Before calling the FSGetForkPosition function, call the Gestalt function with the gestaltFSAttr selector to determine if FSGetForkPosition is available. If the function is available, but is not directly supported by a volume, the File Manager will automatically call PBGetFPosSync; however, you will not be able to determine the fork position of a named fork other than the data or resource fork, or of a fork larger than 2 GB.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetForkSize

Returns the size of an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use lseek instead. To get the size of the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSGetForkSize (
   FSIORefNum forkRefNum,
   SInt64 *forkSize
);
Parameters
forkRefNum

The reference number of the open fork. You can obtain this fork reference number with the FSOpenFork function, or one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

forkSize

On return, a pointer to the logical size (the logical end-of-file) of the fork, in bytes. The size returned is the total number of bytes that can be read from the fork; the amount of space actually allocated on the volume (the physical size) will probably be larger.

Return Value

A result code. See “File Manager Result Codes.”

Special Considerations

To determine whether the FSGetForkSize function is present, call the Gestalt function. If FSGetForkSize is present, but is not directly supported by a volume, the File Manager will call PBGetEOFSync; however, you will not be able to determine the size of a fork other than the data or resource fork, or of a fork larger than 2 GB.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetResourceForkName

Returns a Unicode string constant for the name of the resource fork. (Deprecated in OS X v10.8.)

OSErr FSGetResourceForkName (
   HFSUniStr255 *resourceForkName
);
Parameters
resourceForkName

On input, a pointer to an HFSUniStr255 structure. On return, this structure contains the Unicode name of the resource fork. Currently, this is “RESOURCE_FORK”. See HFSUniStr255 for a description of the HFSUniStr255 data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

There is no parameter block-based form of this call since it is not dispatched to individual volume formats, and does not require any I/O.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetTemporaryDirectoryForReplaceObject

Gets the preferred directory for use as a temporary directory. (Deprecated in OS X v10.8. Use replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: instead.)

OSStatus  FSGetTemporaryDirectoryForReplaceObject(const FSRef *originalObject, FSRef *temporaryDirectory, OptionBits flags);
Parameters
originalObject

The object to be replaced.

temporaryDirectory

The preferred temporary directory.

flags

A set of options that specify nondefault behavior.

Return Value

Returns an appropriate temporary directory.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetVolumeForDADisk

Gets the volume associated with the given disk. (Deprecated in OS X v10.8. To get the volume URL, use DADiskCopyDescription with kDADiskDescriptionVolumePathKey instead.)

OSStatus  FSGetVolumeForDADisk(DADiskRef disk, FSVolumeRefNum *vRefNum);
Parameters
disk

The DADiskRef of the target volume.

vRefNum

The reference number of the volume that corresponds to the disk.

Return Value

Returns a reference number that identifies the volume.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetVolumeForDiskID

Gets the volume associated with the given disk. (Deprecated in OS X v10.8. To get the volume, use DADiskCreateFromBSDName, then DADiskCopyDescription with kDADiskDescriptionVolumePathKey instead.)

OSStatus  FSGetVolumeForDiskID(CFStringRef diskID, FSVolumeRefNum *vRefNum);
Parameters
diskID

The disk ID associated with the target volume.

vRefNum

The reference number of the volume that corresponds to the disk ID.

Return Value

Returns a reference number that identifies the volume.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetVolumeInfo

Returns information about a volume. (Deprecated in OS X v10.8. At the Foundation layer, use getResourceValue:forKey:error: or resourceValuesForKeys:error: instead. At the Core Foundation layer, use CFURLCopyResourcePropertyForKey or CFURLCopyResourcePropertiesForKeys instead. To enumerate volumes, use mountedVolumeURLsIncludingResourceValuesForKeys:options: or the CFURLEnumeratorRef API instead.)

OSErr FSGetVolumeInfo (
   FSVolumeRefNum volume,
   ItemCount volumeIndex,
   FSVolumeRefNum *actualVolume,
   FSVolumeInfoBitmap whichInfo,
   FSVolumeInfo *info,
   HFSUniStr255 *volumeName,
   FSRef *rootDirectory
);
Parameters
volume

If you wish to obtain information on a particular volume, pass that volume’s reference number here. If you wish to index through the list of mounted volumes, pass the constant kFSInvalidVolumeRefNum in this parameter. See FSVolumeRefNum for a description of the FSVolumeRefNum data type.

volumeIndex

The index of the desired volume, or 0 to use the volume reference number in the volume parameter.

actualVolume

On return, a pointer to the volume reference number of the volume. This is useful when indexing over all mounted volumes. If you don’t want this information (if, for instance, you supplied a particular volume reference number in the volume) parameter, set actualVolume to NULL.

whichInfo

A bitmap specifying which volume information fields to get and return in the info parameter. If you don’t want information about the volume returned in the info parameter, set whichInfo to kFSVolInfoNone. See “Volume Information Bitmap Constants” for a description of the bits in this parameter.

info

On return, a pointer to the volume information. If you don’t want this output, set this parameter to NULL. See FSVolumeInfo for a description of the FSVolumeInfo data type.

volumeName

On return, a pointer to the Unicode name of the volume. If you do not wish the name returned, pass NULL. See HFSUniStr255 for a description of the HFSUniStr255 data type.

rootDirectory

On return, a pointer to the FSRef for the volume’s root directory. If you do not wish the root directory returned, pass NULL. See FSRef for a description of the FSRef data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

You can specify a particular volume or index through the list of mounted volumes. To get information on a particular volume, pass the volume reference number of the desired volume in the volume parameter and set the volumeIndex parameter to zero. To index through the list of mounted volumes, pass kFSInvalidVolumeRefNum in the volume parameter and set volumeIndex to the index, starting at 1 with the first call to FSGetVolumeInfo.

When indexing through the list of mounted volumes, you may encounter an error with a particular volume. The terminating error code for full traversal of this list is nsvErr. In order to completely traverse the entire list, you may have to bump the index count when encountering other errors (for example, ioErr).

To get information about the root directory of a volume, use the FSGetCatalogInfo function, or one of the corresponding parameter block calls, PBGetCatalogInfoSync and PBGetCatalogInfoAsync.

Special Considerations

After an operation that changes the amount of free space on the volume—such as deleting a file—there may be a delay before a call to FSGetVolumeInfo returns the updated amount. This is because the File Manager caches and periodically updates file system information, to reduce the number of calls made to retrieve the information from the file system. Currently, the File Manager updates its information every 15 seconds. This primarily affects NFS volumes. DOS, SMB, UFS and WebDAV volumes were also affected by this in previous versions of OS X, but behave correctly in OS X version 10.3 and later.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSGetVolumeMountInfo

Retrieves the mounting information associated with the specified volume. (Deprecated in OS X v10.8. Use the NSURL or CFURL bookmark APIs instead; to learn more, see NSURL Class Reference and CFURL Reference.)

OSStatus FSGetVolumeMountInfo (
   FSVolumeRefNum volume,
   BytePtr buffer,
   ByteCount bufferSize,
   ByteCount *actualSize
);
Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetVolumeMountInfoSize

Determines the size of the mounting information associated with the specified volume. (Deprecated in OS X v10.8. Use the NSURL or CFURL bookmark APIs instead; to learn more, see NSURL Class Reference and CFURL Reference.)

OSStatus FSGetVolumeMountInfoSize (
   FSVolumeRefNum volume,
   ByteCount *size
);
Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSGetVolumeParms

Retrieves information about the characteristics of a volume. (Deprecated in OS X v10.8. At the Foundation layer, use getResourceValue:forKey:error: or resourceValuesForKeys:error: instead. At the Core Foundation layer, use CFURLCopyResourcePropertyForKey or CFURLCopyResourcePropertiesForKeys instead.)

OSStatus FSGetVolumeParms (
   FSVolumeRefNum volume,
   GetVolParmsInfoBuffer *buffer,
   ByteCount bufferSize
);
Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSIsFSRefValid

Returns whether the given reference refers to a valid file system object. (Deprecated in OS X v10.8. At the Foundation layer, use checkResourceIsReachableAndReturnError: instead; at the Core Foundation layer, use CFURLResourceIsReachable instead.)

Boolean  FSIsFSRefValid(const FSRef * ref);
Parameters
ref

The file system reference.

Return Value

Returns TRUE if the given file system reference refers to a valid file system object; otherwise, FALSE.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSIterateForks

Determines the name and size of every named fork belonging to a file or directory. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use getxattr, listxattr, removexattr, or setxattr to access the resource fork.)

OSErr FSIterateForks (
   const FSRef *ref,
   CatPositionRec *forkIterator,
   HFSUniStr255 *forkName,
   SInt64 *forkSize,
   UInt64 *forkPhysicalSize
);
Parameters
ref

A pointer to an FSRef specifying the file or directory to iterate. See FSRef for a description of the FSRef data type.

forkIterator

A pointer to a structure which maintains state between calls to FSIterateForks. Before the first call, set the initialize field of the structure to 0. The fork iterator will be updated after the call completes; the updated iterator should be passed into the next call. See CatPositionRec for a description of the CatPositionRec data type.

forkName

On return, a pointer to the Unicode name of the fork. This parameter is optional; if you do not wish the name returned, pass a NULL pointer. See HFSUniStr255 for a description of the HFSUniStr255 data type.

forkSize

On return, a pointer to the logical size of the fork, in bytes. This parameter is optional; if you do not wish to retrieve the logical fork size, pass a NULL pointer.

forkPhysicalSize

On return, a pointer to the physical size of the fork (that is, to the amount of space allocated on disk), in bytes. This parameter is optional; if you do not wish to retrieve the physical fork size, pass a NULL pointer.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Since information is returned about one fork at a time, several calls may be required to iterate through all the forks. There is no guarantee about the order in which forks are returned; the order may vary between iterations.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSLockRange

Locks a range of bytes of the specified fork. (Deprecated in OS X v10.8.)

OSStatus FSLockRange (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset,
   UInt64 requestCount,
   UInt64 *rangeStart
);
Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMakeFSRefUnicode

Constructs an FSRef for a file or directory, given a parent directory and a Unicode name. (Deprecated in OS X v10.8. Use NSURL or CFURL APIs instead. To track the behavior of file-system items by ID, create file reference URLs using fileReferenceURL or CFURLCreateFileReferenceURL.)

OSErr FSMakeFSRefUnicode (
   const FSRef *parentRef,
   UniCharCount nameLength,
   const UniChar *name,
   TextEncoding textEncodingHint,
   FSRef *newRef
);
Parameters
parentRef

A pointer to the FSRef of the parent directory of the file or directory for which to create a new FSRef. See FSRef for a description of the FSRef data type.

nameLength

The length of the file or directory name.

name

A pointer to the Unicode name for the file or directory. The name must be a leaf name; partial or full pathnames are not allowed. If you have a partial or full pathname in Unicode, you will have to parse it yourself and make multiple calls to FSMakeFSRefUnicode.

textEncodingHint

The suggested text encoding to use when converting the Unicode name of the file or directory to some other encoding. If you pass the constant kTextEncodingUnknown, the File Manager will use a default value.

newRef

On return, if the function returns a result of noErr, a pointer to the new FSRef.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSMountLocalVolumeAsync

Mounts a volume asynchronously. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSMountLocalVolumeAsync (
   CFStringRef diskID,
   CFURLRef mountDir,
   FSVolumeOperation volumeOp,
   void *clientData,
   OptionBits flags,
   FSVolumeMountUPP callback,
   CFRunLoopRef runloop,
   CFStringRef runloopMode
);
Parameters
diskID

The disk to mount.

mountDir

Pass in NULL ; currently only NULL is supported.

volumeOp

An FSVolumeOperation returned by FSCreateVolumeOperation

clientData

A pointer to client data associated with the operation. This parameter can be NULL.

flags

Options for future use.

callback

The function to call when mount is complete. This parameter can be NULL.

runloop

The runloop to run on.

runloopMode

The mode for the runloop.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function starts the process to mount the disk specified by the diskID parameter at the location specified by the mountDir parameter. If mountDir is NULL, the default location is used. If a callback function is provided, that function will be called when the mount operation is complete. Once this function returns noErr the status of the operation can be found using the FSGetAsyncMountStatus function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMountLocalVolumeSync

Mounts a volume. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSMountLocalVolumeSync (
   CFStringRef diskID,
   CFURLRef mountDir,
   FSVolumeRefNum *mountedVolumeRefNum,
   OptionBits flags
);
Parameters
diskID

The disk to mount.

mountDir

Pass in NULL; currently only NULL is supported.

mountedVolumeRefNum

On return, a pointer to the volume reference number of the newly mounted volume.

flags

Options for future use.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function mounts the disk specified by the diskID parameter at the location specified by the mountDir parameter. If mountDir is NULL, the default location is used. This function returns after the mount is complete.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMountServerVolumeAsync

Mounts a server volume asynchronously. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSMountServerVolumeAsync (
   CFURLRef url,
   CFURLRef mountDir,
   CFStringRef user,
   CFStringRef password,
   FSVolumeOperation volumeOp,
   void *clientData,
   OptionBits flags,
   FSVolumeMountUPP callback,
   CFRunLoopRef runloop,
   CFStringRef runloopMode
);
Parameters
url

The server to mount.

mountDir

The directory to mount the server to. If this parameter is NULL, the default location is used.

user

A string to pass as the user for authentication. This parameter can be NULL.

password

A string to pass as the password for authenticated log in. This parameter can be NULL.

volumeOp

An FSVolumeOperation returned by the FSCreateVolumeOperation function.

clientData

A pointer to client data associated with the operation. This parameter can be NULL.

flags

Options for future use.

callback

A function to call when the mount is complete. This parameter can be NULL.

runloop

The runloop to run on.

runloopMode

The mode for the runloop.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function will start the process to mount the server specified by the url parameter at the location specified by the mountDir parameter. If mountDir is NULL, the default location is used. An optional user and password can be passed in for authentication. If no user or password is provided then the underlying file system will handle authentication if required. If a callback function is provided, that function will be called when the mount operation is complete. Once this function returns noErr the status of the operation can be found using the FSGetAsyncMountStatus function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMountServerVolumeSync

Mounts a server volume. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSMountServerVolumeSync (
   CFURLRef url,
   CFURLRef mountDir,
   CFStringRef user,
   CFStringRef password,
   FSVolumeRefNum *mountedVolumeRefNum,
   OptionBits flags
);
Parameters
url

The server to mount.

mountDir

The directory to mount the server to. If this parameter is NULL, the default location is used.

user

A string to pass as the user for authentication.

password

A string to pass as the password for authenticated log in.

mountedVolumeRefNum

On return, a pointer to the volume reference number of the newly mounted volume.

flags

Options for future use.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function will mount the server specified by the url parameter at the location specified by the mountDir parameter. If mountDir is NULL, the default location is used. An optional user and password can be passed in for authentication. If no user or password is provided then the underlying file system will handle authentication if required. This function returns after the mount is complete.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMoveObject

Moves a file or directory into a different directory. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSErr FSMoveObject (
   const FSRef *ref,
   const FSRef *destDirectory,
   FSRef *newRef
);
Parameters
ref

A pointer to an FSRef specifying the file or directory to move. See FSRef for a description of the FSRef data type.

destDirectory

A pointer to an FSRef specifying the directory into which the file or directory indicated by the ref parameter will be moved.

newRef

On return, a pointer to the new FSRef for the file or directory in its new location. This parameter is optional; if you do not wish the FSRef returned, pass NULL.

Return Value

A result code. See “File Manager Result Codes.” If the destDirectory parameter specifies a non-existent object, dirNFErr is returned; if it refers to a file, errFSNotAFolder is returned. If the directory specified in the destDirectory parameter is on a different volume than the file or directory indicated in the ref parameter, diffVolErr is returned.

Discussion

Moving an object may change its FSRef. If you want to continue to refer to the object, you should pass a non- NULL pointer in the newRef parameter and use the FSRef returned there to refer to the object after the move. The original FSRef passed in the ref parameter may or may not be usable after the move. The newRef parameter may point to the same storage as the destDirectory or ref parameters.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMoveObjectAsync

Starts an asynchronous file operation to move a source object to a destination directory. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSStatus FSMoveObjectAsync (
   FSFileOperationRef fileOp,
   const FSRef *source,
   const FSRef *destDir,
   CFStringRef destName,
   OptionBits flags,
   FSFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this move operation.

source

A pointer to the source object to move. The object can be a file or a directory.

destDir

A pointer to the destination directory. If the destination directory is not on the same volume as the source object, the source object is copied and then deleted.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

flags

One or more file operation option flags. See “File Operation Options.” If you specify the kFSFileOperationDoNotMoveAcrossVolumes flag and the destination directory is not on the same volume as the source object, this function does nothing and returns an error.

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you specify a status callback function, status callbacks will occur in one of the run loop and mode combinations with which you scheduled the file operation.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMoveObjectSync

Moves a source object to a destination directory. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSStatus FSMoveObjectSync (
   const FSRef *source,
   const FSRef *destDir,
   CFStringRef destName,
   FSRef *target,
   OptionBits options
);
Parameters
source

A pointer to the source object to move. The object can be a file or a directory. On output, the source object is no longer valid; if you want to refer to the moved object, you should use the FSRef variable passed back in the target parameter.

destDir

A pointer to the destination directory. If the destination directory is not on the same volume as the source object, the source object is copied and then deleted.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

target

A pointer to an FSRef variable that, on output, refers to the new object in the destination directory. This parameter is optional; pass NULL if you don’t need to refer to the new object.

options

One or more file operation option flags. See “File Operation Options.” If you specify the kFSFileOperationDoNotMoveAcrossVolumes flag and the destination directory is not on the same volume as the source object, this function does nothing and returns an error.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the destination directory is on the same volume as the source object, this is a fast operation. If the move is across volumes, this function could take a significant amount of time to execute; you should either call it in a thread other than the main thread or use FSMoveObjectAsync instead.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMoveObjectToTrashAsync

Starts an asynchronous file operation to move a source object to the Trash. (Deprecated in OS X v10.8. At the Foundation layer, use trashItemAtURL:resultingItemURL:error: instead.)

OSStatus FSMoveObjectToTrashAsync (
   FSFileOperationRef fileOp,
   const FSRef *source,
   OptionBits flags,
   FSFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this move operation. For more information, see the function FSFileOperationCreate.

source

A pointer to the source object to move. The object can be a file or a directory.

flags

One or more file operation option flags. See “File Operation Options.”

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. This data is passed to the function you specify in the callback parameter. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function starts an asynchronous file operation to move the object specified by the source parameter to the Trash. If the source volume does not support a trash folder, the operation will fail and return an error to the status callback specified in the callback parameter. (This is the same circumstance that triggers the delete immediately behavior in the Finder.)

Status callbacks occur on one of the runloop and mode combinations on which the operation was scheduled. Upon successful completion of the operation, the last currentItem parameter (passed to the last status callback or retrieved by calling FSFileOperationCopyStatus) is the object in the Trash.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSMoveObjectToTrashSync

Moves a source object to the Trash. (Deprecated in OS X v10.8. At the Foundation layer, use trashItemAtURL:resultingItemURL:error: instead.)

OSStatus FSMoveObjectToTrashSync (
   const FSRef *source,
   FSRef *target,
   OptionBits options
);
Parameters
source

A pointer to the source object to move. The object can be a file or a directory. On output, the source object is no longer valid; if you want to refer to the moved object, you should use the value passed back in the target parameter.

target

A pointer to the target object that, on output, resides in a trash folder. This parameter is optional; pass NULL if you don’t need to refer to this object.

options

One or more file operation option flags. See “File Operation Options.”

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function moves a file or directory to the Trash, adjusting the object’s name if necessary. The appropriate trash folder is chosen based on the source volume and the current user. If the source volume does not support a trash folder, this function does nothing and returns an error. (This is the same circumstance that triggers the delete immediately behavior in the Finder.)

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSOpenFork

Opens any fork of a file or directory for streaming access. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use open(2) OS X Developer Tools Manual Page and flock instead. To open a data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSOpenFork (
   const FSRef *ref,
   UniCharCount forkNameLength,
   const UniChar *forkName,
   SInt8 permissions,
   FSIORefNum *forkRefNum
);
Parameters
ref

A pointer to an FSRef specifying the file or directory owning the fork to open. See FSRef for a description of the FSRef data type.

forkNameLength

The length of the fork name in Unicode characters.

forkName

A pointer to the Unicode name of the fork to open. You can obtain the string constants for the data fork and resource fork names using the FSGetDataForkName and FSGetResourceForkName functions. All volume formats should support data and resource forks; other named forks may be supported by some volume formats.

permissions

A constant indicating the type of access which you wish to have to the fork via the returned fork reference. This parameter is the same as the permission parameter passed to the FSpOpenDF and FSpOpenRF functions. For a description of the types of access which you can request, see “File Access Permission Constants.”

forkRefNum

On return, a pointer to the fork reference number for accessing the open fork.

Return Value

A result code. See “File Manager Result Codes.” On some file systems, FSOpenFork will return the error eofErr if you try to open the resource fork of a file for which no resource fork exists with read-only access.

Discussion

When you use this function to open a file on a local volume and pass in a permissions value of fsCurPerm, fsWrPerm, or fsRdWrPerm , OS X does not guarantee exclusive file access. Before making any assumptions about the underlying file access, you should always check to see whether the Supports Exclusive Locks feature is available. If this feature is not available, your application cannot know whether another application has access to the same file. For more information, see ADC Technical Note TN2037.

To access named forks or forks larger than 2GB, you must use the FSOpenFork function or one of the corresponding parameter block calls: PBOpenForkSync and PBOpenForkAsync. To determine if the FSOpenFork function is present, call the Gestalt function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSOpenIterator

Creates a catalog iterator that can be used to iterate over the contents of a directory or volume. (Deprecated in OS X v10.8. Use NSDirectoryEnumerator or CFURLEnumerator APIs instead. For more information, see NSDirectoryEnumerator Class Reference and CFURLEnumerator Reference.)

OSErr FSOpenIterator (
   const FSRef *container,
   FSIteratorFlags iteratorFlags,
   FSIterator *iterator
);
Parameters
container

A pointer to an FSRef for the directory to iterate. The set of items to iterate over can either be the objects directly contained in the directory, or all items directly or indirectly contained in the directory (in which case, the specified directory is the root of the subtree to iterate). See FSRef for a description of the FSRef data type.

iteratorFlags

A set of flags which controls whether the iterator iterates over subtrees or just the immediate children of the container. See “Iterator Flags” for a description of the flags defined for this parameter.

Iteration over subtrees which do not originate at the root directory of a volume are not currently supported, and passing the kFSIterateSubtree flag in this parameter returns errFSBadIteratorFlags. To determine whether subtree iterators are supported, check that the bSupportsSubtreeIterators bit returned by PBHGetVolParmsSync or PBHGetVolParmsAsync is set.

iterator

On return, a pointer to the new FSIterator. You can pass this iterator to the FSGetCatalogInfoBulk or FSCatalogSearch functions and their parameter block-based counterparts.

The iterator is automatically initialized so that the next use of the iterator returns the first item. The order that items are returned in is volume format dependent and may be different for two different iterators created with the same container and flags.

See FSIterator for a description of the FSIterator data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Catalog iterators must be closed when you are done using them, whether or not you have iterated over all the items. Iterators are automatically closed upon process termination, just like open files. However, you should use the FSCloseIterator function, or one of the related parameter block functions, PBCloseIteratorSync and PBCloseIteratorAsync , to close an iterator to free up any system resources allocated to the iterator.

Before calling this function, you should check that it is present, by calling the Gestalt function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSPathCopyObjectAsync

Starts an asynchronous file operation to copy a source object to a destination directory using pathnames. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtPath:toPath:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSPathCopyObjectAsync (
   FSFileOperationRef fileOp,
   const char *sourcePath,
   const char *destDirPath,
   CFStringRef destName,
   OptionBits flags,
   FSPathFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this copy operation.

sourcePath

The UTF-8 pathname of the source object to copy. The object can be a file or a directory.

destDirPath

The UTF-8 pathname of the destination directory.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

flags

One or more file operation option flags. See “File Operation Options.”

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you specify a status callback function, status callbacks will occur in one of the run loop and mode combinations with which you scheduled the file operation.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathCopyObjectSync

Copies a source object to a destination directory using pathnames. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtPath:toPath:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSPathCopyObjectSync (
   const char *sourcePath,
   const char *destDirPath,
   CFStringRef destName,
   char **targetPath,
   OptionBits options
);
Parameters
sourcePath

The UTF-8 pathname of the source object to copy. The object can be a file or a directory.

destDirPath

The UTF-8 pathname of the destination directory.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

targetPath

A pointer to a char* variable that, on output, refers to the UTF-8 pathname of the new object in the destination directory. If the operation fails, the pathname is set to NULL. When you no longer need the pathname, you should free it. This parameter is optional; pass NULL if you don’t need the pathname.

options

One or more file operation option flags. See “File Operation Options.”

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function could take a significant amount of time to execute. To avoid blocking your user interface, you should either call this function in a thread other than the main thread or use FSPathCopyObjectAsync instead.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathFileOperationCopyStatus

Gets a copy of the current status information for an asynchronous file operation that uses pathnames. (Deprecated in OS X v10.8. At the Foundation layer, use copyItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use copyfile(3) OS X Developer Tools Manual Page instead.)

OSStatus FSPathFileOperationCopyStatus (
   FSFileOperationRef fileOp,
   char **currentItem,
   FSFileOperationStage *stage,
   OSStatus *error,
   CFDictionaryRef *statusDictionary,
   void **info
);
Parameters
fileOp

The file operation to access.

currentItem

A pointer to a char* variable. On output, the variable refers to the UTF-8 pathname of the object currently being moved or copied. If the operation is complete, this parameter refers to the target (the new object corresponding to the source object in the destination directory). You should free the pathname when you are finished using it.

stage

A pointer to a file operation stage variable. On output, the variable contains the current stage of the file operation.

error

A pointer to an error status variable. On output, the variable contains the current error status of the file operation.

statusDictionary

A pointer to a dictionary variable. On output, the variable contains a dictionary with more detailed status information. For information about the contents of the dictionary, see “File Operation Status Dictionary Keys”. You should release the dictionary when you are finished using it.

info

A pointer to a generic pointer. On output, the generic pointer refers to user-defined data associated with this file operation.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathGetTemporaryDirectoryForReplaceObject

Gets the path to the preferred directory for use as a temporary directory. (Deprecated in OS X v10.8.)

OSStatus  FSPathGetTemporaryDirectoryForReplaceObject(const char *originalObjectPath, char *temporaryDirectoryPath, UInt32 maxPathSize, OptionBits flags);
Parameters
originalObjectPath

The path to the object to be replaced.

temporaryDirectoryPath

The path to the preferred temporary directory.

maxPathSize

The size of the buffer pointed to by temporaryDirectoryPath.

flags

A set of options that specify nondefault behavior.

Return Value

Returns the path to an appropriate temporary directory.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathMakeRef

Converts a POSIX-style pathname into an FSRef structure. (Deprecated in OS X v10.8.)

OSStatus FSPathMakeRef (
   const UInt8 *path,
   FSRef *ref,
   Boolean *isDirectory
);
Parameters
path

A UTF-8 C string that contains the pathname to convert.

ref

A pointer to an FSRef structure allocated by the caller. On output, the FSRef structure refers to the object whose location is specified by the path parameter.

isDirectory

A pointer to a Boolean variable allocated by the caller. On output, true indicates the object is a directory. This parameter is optional and may be NULL.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathMakeRefWithOptions

Converts a POSIX-style pathname into an FSRef structure with options. (Deprecated in OS X v10.8.)

OSStatus FSPathMakeRefWithOptions (
   const UInt8 *path,
   OptionBits options,
   FSRef *ref,
   Boolean *isDirectory
);
Parameters
path

A UTF-8 C string that contains the pathname to convert.

options

One or more conversion flags. See “Path Conversion Options.”

ref

A pointer to an FSRef structure allocated by the caller. On output, the FSRef structure refers to the object whose location is specified by the path parameter. If the object is a symbolic link, the options parameter determines whether the FSRef structure refers to the link itself or to the linked object.

isDirectory

A pointer to a Boolean variable allocated by the caller. On output, true indicates the object is a directory. This parameter is optional and may be NULL.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSPathMoveObjectAsync

Starts an asynchronous file operation to move a source object to a destination directory using pathnames. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtPath:toPath:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSStatus FSPathMoveObjectAsync (
   FSFileOperationRef fileOp,
   const char *sourcePath,
   const char *destDirPath,
   CFStringRef destName,
   OptionBits flags,
   FSPathFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this move operation.

sourcePath

The UTF-8 pathname of the source object to move. The object can be a file or a directory.

destDirPath

The UTF-8 pathname of the destination directory. If the destination directory is not on the same volume as the source object, the source object is copied and then deleted.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

flags

One or more file operation option flags. See “File Operation Options.” If you specify the kFSFileOperationDoNotMoveAcrossVolumes flag and the destination directory is not on the same volume as the source object, this function does nothing and returns an error.

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If you specify a status callback function, status callbacks will occur in one of the run loop and mode combinations with which you scheduled the file operation.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathMoveObjectSync

Moves a source object to a destination directory using pathnames. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtPath:toPath:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSStatus FSPathMoveObjectSync (
   const char *sourcePath,
   const char *destDirPath,
   CFStringRef destName,
   char **targetPath,
   OptionBits options
);
Parameters
sourcePath

The UTF-8 pathname of the source object to move. The object can be a file or a directory.

destDirPath

The UTF-8 pathname of the destination directory. If the destination directory is not on the same volume as the source object, the source object is copied and then deleted.

destName

The name for the new object in the destination directory. Pass NULL to use the name of the source object.

targetPath

A pointer to a char* variable that, on output, refers to the UTF-8 pathname of the new object in the destination directory. When you no longer need the pathname, you should free it. If the operation fails, the pathname is set to NULL. This parameter is optional; pass NULL if you don’t need the pathname.

options

One or more file operation option flags. See “File Operation Options.” If you specify the kFSFileOperationDoNotMoveAcrossVolumes flag and the destination directory is not on the same volume as the source object, this function does nothing and returns an error.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

If the destination directory is on the same volume as the source object, this is a fast operation. If the move is across volumes, this function could take a significant amount of time to execute; you should call it in a thread other than the main thread or use FSPathMoveObjectAsync instead.

Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathMoveObjectToTrashAsync

Starts an asynchronous file operation to move a source object, specified using a pathname, to the Trash. (Deprecated in OS X v10.8. At the Foundation layer, use trashItemAtURL:resultingItemURL:error: instead.)

OSStatus FSPathMoveObjectToTrashAsync (
   FSFileOperationRef fileOp,
   const char *sourcePath,
   OptionBits flags,
   FSPathFileOperationStatusProcPtr callback,
   CFTimeInterval statusChangeInterval,
   FSFileOperationClientContext *clientContext
);
Parameters
fileOp

The file operation object you created for this move operation. For more information, see the function FSFileOperationCreate.

sourcePath

The UTF-8 pathname of the source object to move. The object can be a file or a directory.

flags

One or more file operation option flags. See “File Operation Options.”

callback

A callback function to receive status updates as the file operation proceeds. For more information, see “File Operation Callbacks.” This parameter is optional; pass NULL if you don’t need to supply a status callback.

statusChangeInterval

The minimum time in seconds between callbacks within a single stage of an operation.

clientContext

User-defined data to associate with this operation. This data is passed to the function you specify in the callback parameter. For more information, see FSFileOperationClientContext. This parameter is optional; pass NULL if you don’t need to supply a client context.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function starts an asynchronous file operation to move the object specified by the sourcePath parameter to the Trash. If the source volume does not support a trash folder, the operation will fail and return an error to the status callback specified in the callback parameter. (This is the same circumstance that triggers the delete immediately behavior in the Finder.)

Status callbacks occur on one of the runloop and mode combinations on which the operation was scheduled. Upon successful completion of the operation, the last currentItem parameter (passed to the last status callback or retrieved by calling FSFileOperationCopyStatus) is the object in the Trash.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathMoveObjectToTrashSync

Moves a source object, specified using a pathname, to the Trash. (Deprecated in OS X v10.8. At the Foundation layer, use trashItemAtURL:resultingItemURL:error: instead.)

OSStatus FSPathMoveObjectToTrashSync (
   const char *sourcePath,
   char **targetPath,
   OptionBits options
);
Parameters
sourcePath

The UTF-8 pathname of the source object to move. The object can be a file or a directory.

targetPath

A pointer to a char* variable that, on output, refers to the UTF-8 pathname of the target object in the Trash. When you no longer need the pathname, you should free it. If the operation fails, the pathname is set to NULL. This parameter is optional; pass NULL if you don’t need the pathname.

options

One or more file operation option flags. See “File Operation Options.”

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function moves a file or directory to the Trash, adjusting the object’s name if necessary. The appropriate trash folder is chosen based on the source volume and the current user. If the source volume does not support a trash folder, this function does nothing and returns an error. (This is the same circumstance that triggers the delete immediately behavior in the Finder.)

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSPathReplaceObject

Replaces the original object with the replacement object, in the original object’s parent directory. (Deprecated in OS X v10.8. Use replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: instead.)

OSStatus  FSPathReplaceObject(const char *originalObjectPath, const char *replacementObjectPath, CFStringRef newName, CFStringRef temporaryName, const char *temporaryDirectoryPath, OptionBits flags);
Parameters
originalObjectPath

The path of the object to be replaced.

replacementObjectPath

The path of the object with which to replace the original object.

newName

The new name for the result object.

temporaryName

The name of a temporary object (if the operation requires one).

temporaryDirectoryPath

The path to the directory of the temporary object (if it is needed).

flags

A set of options that specify nondefault behavior.

resultObject

An FSRef that refers to the result object.

Return Value

Returns an FSRef for the result object.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSReadFork

Reads data from an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use read(2) OS X Developer Tools Manual Page instead. To control caching use fcntl with F_NOCACHE. To read the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSReadFork (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset,
   ByteCount requestCount,
   void *buffer,
   ByteCount *actualCount
);
Parameters
forkRefNum

The reference number of the fork to read from. You should have previously opened this fork using the FSOpenFork call, or one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

positionMode

A constant specifying the base location within the fork for the start of the read. See “Position Mode Constants” for a description of the constants which you can use to specify the base location.

The caller can also use this parameter to hint to the File Manager whether the data being read should or should not be cached. Caching reads appropriately can be important in ensuring that your program access files efficiently.

If you add the forceReadMask constant to the value you pass in this parameter, this tells the File Manager to force the data to be read directly from the disk. This is different from adding the noCacheMask constant since forceReadMask tells the File Manager to flush the appropriate part of the cache first, then ignore any data already in the cache. However, data that is read may be placed in the cache for future reads. The forceReadMask constant is also passed to the device driver, indicating that the driver should avoid reading from any device caches.

See “Cache Constants” for further description of the constants that you can use to indicate your preference for caching the read.

positionOffset

The offset from the base location for the start of the read.

requestCount

The number of bytes to read.

buffer

A pointer to the buffer where the data will be returned.

actualCount

On return, a pointer to the number of bytes actually read. The value pointed to by the actualCount parameter should be equal to the value in the requestCount parameter unless there was an error during the read operation.

This parameter is optional; if you don’t want this information returned, set actualCount to NULL.

Return Value

A result code. See “File Manager Result Codes.” If there are fewer than requestCount bytes from the specified position to the logical end-of-file, then all of those bytes are read, and eofErr is returned.

Discussion

FSReadFork reads data starting at the position specified by the positionMode and positionOffset parameters. The function reads up to requestCount bytes into the buffer pointed to by the buffer parameter and sets the fork’s current position to the byte immediately after the last byte read (that is, the initial position plus actualCount).

To verify that data previously written has been correctly transferred to disk, read it back in using the forceReadMask constant in the positionMode parameter and compare it with the data you previously wrote.

When reading data from a fork, it is important to pay attention to that way that your program accesses the fork, because this can have a significant performance impact. For best results, you should use an I/O size of at least 4KB and block align your read requests. In OS X, you should align your requests to 4KB boundaries.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSRefMakePath

Converts an FSRef structure into a POSIX-style pathname. (Deprecated in OS X v10.8.)

OSStatus FSRefMakePath (
   const FSRef *ref,
   UInt8 *path,
   UInt32 maxPathSize
);
Parameters
ref

A pointer to the FSRef structure to convert.

path

A pointer to a character buffer allocated by the caller. On output, the buffer contains a UTF-8 C string that specifies the absolute path to the object referred to by the ref parameter. The File Manager uses the maxPathSize parameter to make sure it does not overrun the buffer.

maxPathSize

The maximum number of bytes to copy into the buffer.

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSRenameUnicode

Renames a file or folder. (Deprecated in OS X v10.8. At the Foundation layer, use moveItemAtURL:toURL:error: instead. At the POSIX/BSD layer, use rename(2) OS X Developer Tools Manual Page instead.)

OSErr FSRenameUnicode (
   const FSRef *ref,
   UniCharCount nameLength,
   const UniChar *name,
   TextEncoding textEncodingHint,
   FSRef *newRef
);
Parameters
ref

A pointer to an FSRef for the file or directory to rename. See FSRef for a description of the FSRef data type.

nameLength

The length of the new name in Unicode characters.

name

A pointer to the new Unicode name of the file or directory.

textEncodingHint

The suggested text encoding to use when converting the Unicode name of the file or directory to some other encoding. If you pass the constant kTextEncodingUnknown, the File Manager will use a default value.

newRef

On return, a pointer to the new FSRef for the file or directory. This parameter is optional; if you do not wish the FSRef returned, pass NULL.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

Because renaming an object may change its FSRef, you should pass a non- NULL pointer in the newRef parameter and use the FSRef returned there to access the object after the renaming, if you wish to continue to refer to the object. The FSRef passed in the ref parameter may or may not be usable after the object is renamed. The FSRef returned in the newRef parameter may point to the same storage as the FSRef passed in ref.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSReplaceObject

Replaces the original object with the replacement object, in the original object’s parent directory. (Deprecated in OS X v10.8. Use replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: instead.)

OSStatus  FSReplaceObject(const FSRef *originalObject, const FSRef *replacementObject, CFStringRef newName, CFStringRef temporaryName, const FSRef *temporaryDirectory, OptionBits flags, FSRef *resultObject);
Parameters
originalObject

The object to be replaced.

replacementObject

The object with which to replace the original object.

newName

The new name for the result object.

temporaryName

The name of a temporary object (if the operation requires one).

temporaryDirectory

The location of the temporary object (if it is needed).

flags

A set of options that specify nondefault behavior.

resultObject

An FSRef that refers to the result object.

Return Value

Returns an FSRef for the result object.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSSetCatalogInfo

Sets catalog information about a file or directory. (Deprecated in OS X v10.8. At the Foundation layer, use setResourceValue:forKey:error: or setResourceValues:error: instead. At the Core Foundation layer, use CFURLSetResourcePropertyForKey or CFURLSetResourcePropertiesForKeys instead.)

OSErr FSSetCatalogInfo (
   const FSRef *ref,
   FSCatalogInfoBitmap whichInfo,
   const FSCatalogInfo *catalogInfo
);
Parameters
ref

A pointer to an FSRef specifying the file or directory whose information is to be changed. See FSRef for a description of the FSRef data type.

whichInfo

A bitmap specifying which catalog information fields to set. Only some of the catalog information fields may be set. These fields are given by the constant kFSCatInfoSettableInfo; no other bits may be set in the whichInfo parameter. See “Catalog Information Bitmap Constants” for a description of the bits in this parameter.

To set the user ID (UID) and group ID (GID), specify the kFSCatInfoSetOwnership flag in this parameter. The File Manager attempts to set the user and group ID to the values specified in the permissions field of the catalog information structure. If FSSetCatalogInfo cannot set the user and group IDs, it returns an error.

catalogInfo

A pointer to the structure containing the new catalog information. Only some of the catalog information fields may be set. The fields which may be set are:

  • createDate

  • contentModDate

  • attributeModDate

  • accessDate

  • backupDate

  • permissions

  • finderInfo

  • extFinderInfo

  • textEncodingHint

Return Value

A result code. See “File Manager Result Codes.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSSetForkPosition

Sets the current position of an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use lseek instead. To set the position of the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSSetForkPosition (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset
);
Parameters
forkRefNum

The reference number of a fork previously opened by the FSOpenFork, PBOpenForkSync, or PBOpenForkAsync function.

positionMode

A constant specifying the base location within the fork for the new position. If this parameter is equal to fsAtMark, then the positionOffset parameter is ignored. See “Position Mode Constants” for a description of the constants you can use to specify the base location.

positionOffset

The offset of the new position from the base location specified in the positionMode parameter.

Return Value

A result code. See “File Manager Result Codes.” This function returns the result code posErr if you attempt to set the current position of the fork to an offset before the start of the file.

Special Considerations

To determine if the FSSetForkPosition function is present, call the Gestalt function with the gestaltFSAttr selector. If the FSSetForkPosition function is present, but the volume does not directly support it, the File Manager will automatically call the PBSetFPosSync function. However, if the volume does not directly support the FSSetForkPosition function, you can only set the file position for the data and resource forks, and you cannot grow these files beyond 2GB.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSSetForkSize

Changes the size of an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use ftruncate instead. To change the size of the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSSetForkSize (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset
);
Parameters
forkRefNum

The reference number of the open fork. You can obtain this fork reference number with the FSOpenFork function, or one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

positionMode

A constant indicating the base location within the fork for the new size. See “Position Mode Constants” for more information about the constants you can use to specify the base location.

positionOffset

The offset of the new size from the base location specified in the positionMode parameter.

Return Value

A result code. See “File Manager Result Codes.” If there is not enough space on the volume to extend the fork, then dskFulErr is returned and the fork’s size is unchanged.

Discussion

The FSSetForkSize function sets the logical end-of-file to the position indicated by the positionMode and positionOffset parameters. The fork’s new size may be less than, equal to, or greater than the fork’s current size. If the fork’s new size is greater than the fork’s current size, then the additional bytes, between the old and new size, will have an undetermined value.

If the fork’s current position is larger than the fork’s new size, then the current position will be set to the new fork size the current position will be equal to the logical end-of-file.

Special Considerations

You do not need to check that the volume supports the FSSetForkSize function. If a volume does not support the FSSetForkSize function, but the FSSetForkSize function is present, the File Manager automatically calls the PBSetEOFSync function and translates between the calls appropriately.

Note, however, that if the volume does not support the FSSetForkSize function, you can only access the data and resource forks, and you cannot grow the fork beyond 2GB. To check that the FSSetForkSize function is present, call the Gestalt function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

FSSetVolumeInfo

Sets information about a volume. (Deprecated in OS X v10.8. At the Foundation layer, use setResourceValue:forKey:error: or setResourceValues:error: instead. At the Core Foundation layer, use CFURLSetResourcePropertyForKey or CFURLSetResourcePropertiesForKeys instead.)

OSErr FSSetVolumeInfo (
   FSVolumeRefNum volume,
   FSVolumeInfoBitmap whichInfo,
   const FSVolumeInfo *info
);
Parameters
volume

The volume reference number of the volume whose information is to be changed. See FSVolumeRefNum for a description of the FSVolumeRefNum data type.

whichInfo

A bitmap specifying which information to set. Only some of the volume information fields may be set. The settable fields are given by the constant kFSVolInfoSettableInfo; no other bits may be set in whichInfo. The fields which may be set are the backupDate, finderInfo, and flags fields. See “Volume Information Bitmap Constants” for a description of the bits in this parameter.

info

A pointer to the new volume information. See FSVolumeInfo for a description of the FSVolumeInfo data type.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

To set information about the root directory of a volume, use the FSSetCatalogInfo function, or one of the corresponding parameter block calls, PBSetCatalogInfoSync and PBSetCatalogInfoAsync.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSUnlinkObject

Unlinks an existing file or deletes an existing directory. (Deprecated in OS X v10.8. At the Foundation layer, use removeItemAtURL:error: instead. At the POSIX/BSD layer, use unlink instead.)

OSErr  FSUnlinkObject(const FSRef * ref);
Parameters
ref

The object to unlink or delete.

Return Value

A result code indicating the success or failure of the operation.

Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSUnlockRange

Unlocks a range of bytes of the specified fork. (Deprecated in OS X v10.8.)

OSStatus FSUnlockRange (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset,
   UInt64 requestCount,
   UInt64 *rangeStart
);
Availability
  • Available in OS X v10.4 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSUnmountVolumeAsync

Unmounts a volume asynchronously. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSUnmountVolumeAsync (
   FSVolumeRefNum vRefNum,
   OptionBits flags,
   FSVolumeOperation volumeOp,
   void *clientData,
   FSVolumeUnmountUPP callback,
   CFRunLoopRef runloop,
   CFStringRef runloopMode
);
Parameters
vRefNum

The volume reference number of the volume to unmount.

flags

Options for future use.

volumeOp

An FSVolumeOperation returned by the FSCreateVolumeOperation function.

clientData

A pointer to client data associated with the operation.

callback

The function to call when the unmount is complete.

runloop

The runloop to run on.

runloopMode

The mode for the runloop.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function starts the process of unmounting the volume specified by the vRefNum parameter. If a callback function is provided, that function will be called when the unmount operation is complete. Once this function returns noErr the status of the operation can be found using the FSGetAsyncUnmountStatus function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSUnmountVolumeSync

Unmounts a volume. (Deprecated in OS X v10.8. To mount local volumes and to eject and unmount all volumes, use Disk Arbitration API instead (for more information, see Disk Arbitration Framework Reference). To mount a network volume, use NetFSMountURLAsync instead (to cancel a pending mount request, use NetFSMountURLCancel). For more information, see NetFS.h in /System/Library/Frameworks/NetFS.framework/Headers.)

OSStatus FSUnmountVolumeSync (
   FSVolumeRefNum vRefNum,
   OptionBits flags,
   pid_t *dissenter
);
Parameters
vRefNum

The volume reference number of the volume to unmount.

flags

Options for future use.

dissenter

On return, a pointer to the pid of the process which denied the unmount if the unmount is denied.

Return Value

A result code. See “File Manager Result Codes.”

Discussion

This function unmounts the volume specified by the vRefNum parameter. If the volume cannot be unmounted the pid of the process which denied the unmount will be returned in the dissenter parameter. This function returns after the unmount is complete.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSVolumeMount

Mounts a volume using the specified mounting information. (Deprecated in OS X v10.8. Use the NSURL or CFURL bookmark APIs instead; to learn more, see NSURL Class Reference and CFURL Reference.)

OSStatus FSVolumeMount (
   BytePtr buffer,
   FSVolumeRefNum *mountedVolume
);
Availability
  • Available in OS X v10.5 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

FSWriteFork

Writes data to an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use write(2) OS X Developer Tools Manual Page instead. To control caching, use fcntl with F_NOCACHE. To write data to the data fork at the Foundation layer, use NSFileHandle APIs instead.)

OSErr FSWriteFork (
   FSIORefNum forkRefNum,
   UInt16 positionMode,
   SInt64 positionOffset,
   ByteCount requestCount,
   const void *buffer,
   ByteCount *actualCount
);
Parameters
forkRefNum

The reference number of the fork to which to write. You should have previously opened the fork using the FSOpenFork function, or one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

positionMode

A constant specifying the base location within the fork for the start of the write. See “Position Mode Constants” for a description of the constants which you can use to specify the base location.

The caller can also use this parameter to hint to the File Manager whether the data being written should or should not be cached. See “Cache Constants” for further description of the constants that you can use to indicate your preference for caching.

positionOffset

The offset from the base location for the start of the write.

requestCount

The number of bytes to write.

buffer

A pointer to a buffer containing the data to write.

actualCount

On return, a pointer to the number of bytes actually written. The value pointed to by the actualCount parameter will be equal to the value in the requestCount parameter unless there was an error during the write operation.

This parameter is optional; if you don’t want this information, set actualCount to NULL.

Return Value

A result code. See “File Manager Result Codes.” If there is not enough space on the volume to write requestCount bytes, then dskFulErr is returned.

Discussion

FSWriteFork writes data starting at the position specified by the positionMode and positionOffset parameters. The function attempts to write requestCount bytes from the buffer pointed at by the buffer parameter and sets the fork’s current position to the byte immediately after the last byte written (that is, the initial position plus actualCount).

When writing data to a fork, it is important to pay attention to that way that your program accesses the fork, because this can have a significant performance impact. For best results, you should use an I/O size of at least 4KB and block align your write requests. In OS X, you should align your requests to 4KB boundaries.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Related Sample Code
Declared In
Files.h

InvokeFNSubscriptionUPP

Calls your directory change callback function. (Deprecated in OS X v10.8.)

void InvokeFNSubscriptionUPP (
   FNMessage message,
   OptionBits flags,
   void *refcon,
   FNSubscriptionRef subscription,
   FNSubscriptionUPP userUPP
);
Discussion

The File Manager calls this function to invoke the directory change function which you have provided for use after an asynchronous call has been completed. You should not need to use this function yourself. For more information on directory change functions, see FNSubscriptionProcPtr.

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

InvokeFSVolumeEjectUPP

Calls your volume ejection callback function. (Deprecated in OS X v10.8.)

void InvokeFSVolumeEjectUPP (
   FSVolumeOperation volumeOp,
   void *clientData,
   OSStatus err,
   FSVolumeRefNum volumeRefNum,
   pid_t dissenter,
   FSVolumeEjectUPP userUPP
);
Discussion

The File Manager calls this function to invoke the volume ejection function which you have provided for use after an asynchronous call has been completed. You should not need to use this function yourself. For more information on change notification functions, see FSVolumeEjectProcPtr.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

InvokeFSVolumeMountUPP

Calls your volume mount callback function. (Deprecated in OS X v10.8.)

void InvokeFSVolumeMountUPP (
   FSVolumeOperation volumeOp,
   void *clientData,
   OSStatus err,
   FSVolumeRefNum mountedVolumeRefNum,
   FSVolumeMountUPP userUPP
);
Discussion

The File Manager calls this function to invoke the volume mount function which you have provided for use after an asynchronous call has been completed. You should not need to use this function yourself. For more information on change notification functions, see FSVolumeMountProcPtr.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

InvokeFSVolumeUnmountUPP

Calls your volume unmount callback function. (Deprecated in OS X v10.8.)

void InvokeFSVolumeUnmountUPP (
   FSVolumeOperation volumeOp,
   void *clientData,
   OSStatus err,
   FSVolumeRefNum volumeRefNum,
   pid_t dissenter,
   FSVolumeUnmountUPP userUPP
);
Discussion

The File Manager calls this function to invoke the volume unmount function which you have provided for use after an asynchronous call has been completed. You should not need to use this function yourself. For more information on change notification functions, see FSVolumeUnmountProcPtr.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

InvokeIOCompletionUPP

Calls your I/O completion callback function. (Deprecated in OS X v10.8.)

void InvokeIOCompletionUPP (
   ParmBlkPtr paramBlock,
   IOCompletionUPP userUPP
);
Discussion

The File Manager calls this function to invoke the I/O completion function which you have provided for use after an asynchronous call has been completed. You should not need to use this function yourself. For more information on I/O completion functions, see IOCompletionProcPtr.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

NewFNSubscriptionUPP

Creates a new universal procedure pointer (UPP) to your directory change callback function. (Deprecated in OS X v10.8.)

FNSubscriptionUPP NewFNSubscriptionUPP (
   FNSubscriptionProcPtr userRoutine
);
Parameters
userRoutine

A pointer to a directory change callback function. For more information, see FNSubscriptionProcPtr.

Return Value

A UPP to your directory change callback function.

Availability
  • Available in OS X v10.1 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

NewFSVolumeEjectUPP

Creates a new universal procedure pointer (UPP) to your volume ejection callback function. (Deprecated in OS X v10.8.)

FSVolumeEjectUPP NewFSVolumeEjectUPP (
   FSVolumeEjectProcPtr userRoutine
);
Parameters
userRoutine

A pointer to a volume ejection callback function. For more information, see FSVolumeEjectProcPtr.

Return Value

A UPP to your volume ejection callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

NewFSVolumeMountUPP

Creates a new universal procedure pointer (UPP) to your volume mount callback function. (Deprecated in OS X v10.8.)

FSVolumeMountUPP NewFSVolumeMountUPP (
   FSVolumeMountProcPtr userRoutine
);
Parameters
userRoutine

A pointer to a volume mount callback function. For more information, see FSVolumeEjectProcPtr.

Return Value

A UPP to your volume mount callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

NewFSVolumeUnmountUPP

Creates a new universal procedure pointer (UPP) to your volume unmount callback function. (Deprecated in OS X v10.8.)

FSVolumeUnmountUPP NewFSVolumeUnmountUPP (
   FSVolumeUnmountProcPtr userRoutine
);
Parameters
userRoutine

A pointer to a volume unmount callback function. For more information, see FSVolumeUnmountProcPtr.

Return Value

A UPP to your volume unmount callback function.

Availability
  • Available in OS X v10.2 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

NewIOCompletionUPP

Creates a new universal procedure pointer (UPP) to your I/O completion callback function. (Deprecated in OS X v10.8.)

IOCompletionUPP NewIOCompletionUPP (
   IOCompletionProcPtr userRoutine
);
Parameters
userRoutine

A pointer to your I/O completion callback function. For more information, see IOCompletionProcPtr.

Return Value

A UPP to your I/O completion callback function.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.8.
Declared In
Files.h

PBAllocateForkAsync

Allocates space on a volume to an open fork. (Deprecated in OS X v10.8. At the POSIX/BSD layer, use fcntl(2) OS X Developer Tools Manual Page with F_PREALLOCATE instead.)

void PBAllocateForkAsync (
   FSForkIOParam *paramBlock
);
Parameters
paramBlock

A pointer to a fork I/O parameter block. See FSForkIOParam for a description of the FSForkIOParam data type.

Discussion

The relevant fields of the parameter block are:

ioCompletion

On input, a pointer to a completion routine. For more information on completion routines, see IOCompletionProcPtr.

ioResult

On output, the result code of the function.

forkRefNum

On input, the reference number of the open fork. You can obtain a fork reference number with the FSOpenFork function, or with one of the corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.

allocationFlags

On input, a constant indicating how the new space should be allocated. See “Allocation Flags” for a description of the constants which you can use in this field.

positionMode

On input, a constant specifying the base location within the fork for the start of the allocation. See “Position Mode Constants” for more information on the constants which you can use to specify the base location.

positionOffset

On input, the offset from the base location of the start of the allocation.

allocationAmount

On input, the number of bytes to allocate. On output, the number of bytes actually allocated to the file. The number of bytes allocated may be smaller than the requested amount if some of the space was already allocated. The value returned in this field does not reflect any additional bytes that may have been allocated because space is allocated in terms of fixed units such as allocation blocks, or the use of a clump size to reduce fragmentation.

The PBAllocateForkAsync function attempts to allocate the number of requested bytes of physical storage starting at the offset specified by the positionMode and positionOffset fields. For volume formats that support preallocated space, you can later write to this range of bytes (including extending the size of the fork) without re