| Framework | CoreServices/CoreServices.h |
| Declared in | Files.h HFSVolumes.h |
The File Manager is a core service in Mac OS X that manages the organization, reading, and writing of data located on physical data storage devices such as disk drives. The File Manager provides an abstraction layer that hides lower-level implementation details such as different file systems and volume formats. If you want your application to have the same view of the file system seen in the Mac OS X user interface, the File Manager is an appropriate tool. For example, the File Manager is often used in application frameworks such as Carbon and Cocoa to implement file-related operations.
The File Manager API provides a large number of functions for performing various operations on files, directories, and volumes. The requirements of your application will dictate which of these functions you need to use. Many applications simply need to open files, read and write the data in those files, and then close the files. Other applications might provide more capabilities, such as the ability to copy or move a file to another directory. A few programs, such as the Mac OS X Finder, perform more extensive file operations and hence need to use some of the advanced functions provided by the File Manager.
A number of deprecated functions in the File Manager were inherited from earlier versions of Mac OS and have been carried along to facilitate porting legacy applications to Mac OS X. You should avoid using these deprecated functions. In particular, you should avoid any function or data structure that uses the FSSpec data type. This reference document clearly marks every deprecated function and, in most cases, provides a recommended replacement.
FSGetCatalogInfo
PBGetCatalogInfoSync
PBGetCatalogInfoAsync
FSSetCatalogInfo
PBSetCatalogInfoSync
PBSetCatalogInfoAsync
FSpGetFInfo Deprecated in Mac OS X v10.4
FSpSetFInfo Deprecated in Mac OS X v10.4
HGetFInfo Deprecated in Mac OS X v10.4
HSetFInfo Deprecated in Mac OS X v10.4
PBGetCatInfoAsync Deprecated in Mac OS X v10.4
PBGetCatInfoSync Deprecated in Mac OS X v10.4
PBHGetFInfoAsync Deprecated in Mac OS X v10.4
PBHGetFInfoSync Deprecated in Mac OS X v10.4
PBHSetFInfoAsync Deprecated in Mac OS X v10.4
PBHSetFInfoSync Deprecated in Mac OS X v10.4
PBSetCatInfoAsync Deprecated in Mac OS X v10.4
PBSetCatInfoSync Deprecated in Mac OS X v10.4
PBDTAddAPPLAsync Deprecated in Mac OS X v10.4
PBDTAddAPPLSync Deprecated in Mac OS X v10.4
PBDTAddIconAsync Deprecated in Mac OS X v10.4
PBDTAddIconSync Deprecated in Mac OS X v10.4
PBDTCloseDown Deprecated in Mac OS X v10.4
PBDTDeleteAsync Deprecated in Mac OS X v10.4
PBDTDeleteSync Deprecated in Mac OS X v10.4
PBDTFlushAsync Deprecated in Mac OS X v10.4
PBDTFlushSync Deprecated in Mac OS X v10.4
PBDTGetAPPLAsync Deprecated in Mac OS X v10.4
PBDTGetAPPLSync Deprecated in Mac OS X v10.4
PBDTGetCommentAsync Deprecated in Mac OS X v10.4
PBDTGetCommentSync Deprecated in Mac OS X v10.4
PBDTGetIconAsync Deprecated in Mac OS X v10.4
PBDTGetIconInfoAsync Deprecated in Mac OS X v10.4
PBDTGetIconInfoSync Deprecated in Mac OS X v10.4
PBDTGetIconSync Deprecated in Mac OS X v10.4
PBDTGetInfoAsync Deprecated in Mac OS X v10.4
PBDTGetInfoSync Deprecated in Mac OS X v10.4
PBDTGetPath Deprecated in Mac OS X v10.4
PBDTOpenInform Deprecated in Mac OS X v10.4
PBDTRemoveAPPLAsync Deprecated in Mac OS X v10.4
PBDTRemoveAPPLSync Deprecated in Mac OS X v10.4
PBDTRemoveCommentAsync Deprecated in Mac OS X v10.4
PBDTRemoveCommentSync Deprecated in Mac OS X v10.4
PBDTResetAsync Deprecated in Mac OS X v10.4
PBDTResetSync Deprecated in Mac OS X v10.4
PBDTSetCommentAsync Deprecated in Mac OS X v10.4
PBDTSetCommentSync Deprecated in Mac OS X v10.4
FSAllocateFork
PBAllocateForkSync
PBAllocateForkAsync
Allocate Deprecated in Mac OS X v10.4
AllocContig Deprecated in Mac OS X v10.4
PBAllocateAsync Deprecated in Mac OS X v10.4
PBAllocateSync Deprecated in Mac OS X v10.4
PBAllocContigAsync Deprecated in Mac OS X v10.4
PBAllocContigSync Deprecated in Mac OS X v10.4
FSCloseFork
PBCloseForkSync
PBCloseForkAsync
PBCloseAsync Deprecated in Mac OS X v10.5
PBCloseSync Deprecated in Mac OS X v10.5
FSClose Deprecated in Mac OS X v10.4
PBHGetDirAccessAsync Deprecated in Mac OS X v10.5
PBHGetDirAccessSync Deprecated in Mac OS X v10.5
PBHSetDirAccessAsync Deprecated in Mac OS X v10.5
PBHSetDirAccessSync Deprecated in Mac OS X v10.5
PBHMapIDAsync Deprecated in Mac OS X v10.5
PBHMapIDSync Deprecated in Mac OS X v10.5
PBHMapNameAsync Deprecated in Mac OS X v10.5
PBHMapNameSync Deprecated in Mac OS X v10.5
PBHGetLogInInfoAsync Deprecated in Mac OS X v10.4
PBFSCopyFileSync
PBFSCopyFileAsync
PBHCopyFileAsync Deprecated in Mac OS X v10.5
PBHCopyFileSync Deprecated in Mac OS X v10.5
PBHMoveRenameAsync Deprecated in Mac OS X v10.4
PBHMoveRenameSync Deprecated in Mac OS X v10.4
FSFileOperationCreate
FSFileOperationCancel
FSFileOperationGetTypeID
FSFileOperationScheduleWithRunLoop
FSFileOperationUnscheduleFromRunLoop
FSCopyObjectAsync
FSMoveObjectAsync
FSMoveObjectToTrashAsync
FSPathCopyObjectAsync
FSPathMoveObjectAsync
FSPathMoveObjectToTrashAsync
FSFileOperationCopyStatus
FSPathFileOperationCopyStatus
FSCopyObjectSync
FSMoveObjectSync
FSMoveObjectToTrashSync
FSPathCopyObjectSync
FSPathMoveObjectSync
FSPathMoveObjectToTrashSync
FSMakeFSRefUnicode
PBMakeFSRefUnicodeSync
PBMakeFSRefUnicodeAsync
FSpMakeFSRef Deprecated in Mac OS X v10.5
PBMakeFSRefAsync Deprecated in Mac OS X v10.5
PBMakeFSRefSync Deprecated in Mac OS X v10.5
PBCreateFileIDRefAsync Deprecated in Mac OS X v10.5
PBCreateFileIDRefSync Deprecated in Mac OS X v10.5
PBDeleteFileIDRefAsync Deprecated in Mac OS X v10.5
PBDeleteFileIDRefSync Deprecated in Mac OS X v10.5
FSCreateDirectoryUnicode
PBCreateDirectoryUnicodeSync
PBCreateDirectoryUnicodeAsync
DirCreate Deprecated in Mac OS X v10.4
FSpDirCreate Deprecated in Mac OS X v10.4
PBDirCreateAsync Deprecated in Mac OS X v10.4
PBDirCreateSync Deprecated in Mac OS X v10.4
FSMakeFSSpec Deprecated in Mac OS X v10.4
PBMakeFSSpecAsync Deprecated in Mac OS X v10.4
PBMakeFSSpecSync Deprecated in Mac OS X v10.4
FSCreateFileUnicode
PBCreateFileUnicodeSync
PBCreateFileUnicodeAsync
FSpCreate Deprecated in Mac OS X v10.4
HCreate Deprecated in Mac OS X v10.4
PBHCreateAsync Deprecated in Mac OS X v10.4
PBHCreateSync Deprecated in Mac OS X v10.4
NewIOCompletionUPP
NewFNSubscriptionUPP
NewFSVolumeEjectUPP
NewFSVolumeMountUPP
NewFSVolumeUnmountUPP
InvokeIOCompletionUPP
InvokeFNSubscriptionUPP
InvokeFSVolumeEjectUPP
InvokeFSVolumeMountUPP
InvokeFSVolumeUnmountUPP
DisposeIOCompletionUPP
DisposeFNSubscriptionUPP
DisposeFSVolumeEjectUPP
DisposeFSVolumeMountUPP
DisposeFSVolumeUnmountUPP
FSDeleteObject
PBDeleteObjectSync
PBDeleteObjectAsync
FSpDelete Deprecated in Mac OS X v10.4
HDelete Deprecated in Mac OS X v10.4
PBHDeleteAsync Deprecated in Mac OS X v10.4
PBHDeleteSync Deprecated in Mac OS X v10.4
FSExchangeObjects
PBExchangeObjectsSync
PBExchangeObjectsAsync
FSpExchangeFiles Deprecated in Mac OS X v10.4
PBExchangeFilesAsync Deprecated in Mac OS X v10.4
PBExchangeFilesSync Deprecated in Mac OS X v10.4
FSGetVolumeInfo
PBGetVolumeInfoSync
PBGetVolumeInfoAsync
FSSetVolumeInfo
PBSetVolumeInfoSync
PBSetVolumeInfoAsync
FSCopyDiskIDForVolume
FSCopyURLForVolume
GetVRefNum Deprecated in Mac OS X v10.4
PBHGetVInfoAsync Deprecated in Mac OS X v10.4
PBHGetVInfoSync Deprecated in Mac OS X v10.4
PBSetVInfoAsync Deprecated in Mac OS X v10.4
PBSetVInfoSync Deprecated in Mac OS X v10.4
PBXGetVolInfoAsync Deprecated in Mac OS X v10.4
PBXGetVolInfoSync Deprecated in Mac OS X v10.4
FSGetVolumeParms
PBHGetVolParmsAsync Deprecated in Mac OS X v10.5
PBHGetVolParmsSync Deprecated in Mac OS X v10.5
FSLockRange
PBXLockRangeSync
PBXLockRangeAsync
FSUnlockRange
PBXUnlockRangeSync
PBXUnlockRangeAsync
PBLockRangeAsync Deprecated in Mac OS X v10.4
PBLockRangeSync Deprecated in Mac OS X v10.4
PBUnlockRangeAsync Deprecated in Mac OS X v10.4
PBUnlockRangeSync Deprecated in Mac OS X v10.4
FSpRstFLock Deprecated in Mac OS X v10.4
FSpSetFLock Deprecated in Mac OS X v10.4
HRstFLock Deprecated in Mac OS X v10.4
HSetFLock Deprecated in Mac OS X v10.4
PBHRstFLockAsync Deprecated in Mac OS X v10.4
PBHRstFLockSync Deprecated in Mac OS X v10.4
PBHSetFLockAsync Deprecated in Mac OS X v10.4
PBHSetFLockSync Deprecated in Mac OS X v10.4
FSGetForkSize
PBGetForkSizeSync
PBGetForkSizeAsync
FSSetForkSize
PBSetForkSizeSync
PBSetForkSizeAsync
GetEOF Deprecated in Mac OS X v10.4
PBGetEOFAsync Deprecated in Mac OS X v10.4
PBGetEOFSync Deprecated in Mac OS X v10.4
PBSetEOFAsync Deprecated in Mac OS X v10.4
PBSetEOFSync Deprecated in Mac OS X v10.4
SetEOF Deprecated in Mac OS X v10.4
FSGetForkPosition
PBGetForkPositionSync
PBGetForkPositionAsync
FSSetForkPosition
PBSetForkPositionSync
PBSetForkPositionAsync
GetFPos Deprecated in Mac OS X v10.4
PBGetFPosAsync Deprecated in Mac OS X v10.4
PBGetFPosSync Deprecated in Mac OS X v10.4
PBSetFPosAsync Deprecated in Mac OS X v10.4
PBSetFPosSync Deprecated in Mac OS X v10.4
SetFPos Deprecated in Mac OS X v10.4
HGetVol Deprecated in Mac OS X v10.4
HSetVol Deprecated in Mac OS X v10.4
PBHGetVolAsync Deprecated in Mac OS X v10.4
PBHGetVolSync Deprecated in Mac OS X v10.4
PBHSetVolAsync Deprecated in Mac OS X v10.4
PBHSetVolSync Deprecated in Mac OS X v10.4
FSMountLocalVolumeSync
FSMountServerVolumeSync
FSUnmountVolumeSync
FSEjectVolumeSync
FSCreateVolumeOperation
FSCancelVolumeOperation
FSDisposeVolumeOperation
FSMountLocalVolumeAsync
FSMountServerVolumeAsync
FSUnmountVolumeAsync
FSEjectVolumeAsync
FSGetAsyncMountStatus
FSGetAsyncUnmountStatus
FSGetAsyncEjectStatus
PBUnmountVol Deprecated in Mac OS X v10.4
UnmountVol Deprecated in Mac OS X v10.4
FSGetVolumeMountInfoSize
FSGetVolumeMountInfo
FSVolumeMount
PBGetVolMountInfo Deprecated in Mac OS X v10.5
PBGetVolMountInfoSize Deprecated in Mac OS X v10.5
PBVolumeMount Deprecated in Mac OS X v10.5
FSMoveObject
PBMoveObjectSync
PBMoveObjectAsync
FSRenameUnicode
PBRenameUnicodeSync
PBRenameUnicodeAsync
CatMove Deprecated in Mac OS X v10.4
FSpCatMove Deprecated in Mac OS X v10.4
FSpRename Deprecated in Mac OS X v10.4
HRename Deprecated in Mac OS X v10.4
PBCatMoveAsync Deprecated in Mac OS X v10.4
PBCatMoveSync Deprecated in Mac OS X v10.4
PBHRenameAsync Deprecated in Mac OS X v10.4
PBHRenameSync Deprecated in Mac OS X v10.4
PBGetFCBInfoAsync Deprecated in Mac OS X v10.4
PBGetFCBInfoSync Deprecated in Mac OS X v10.4
FSOpenFork
PBOpenForkSync
PBOpenForkAsync
FSpOpenDF Deprecated in Mac OS X v10.4
FSpOpenRF Deprecated in Mac OS X v10.4
HOpen Deprecated in Mac OS X v10.4
HOpenDF Deprecated in Mac OS X v10.4
HOpenRF Deprecated in Mac OS X v10.4
PBHOpenAsync Deprecated in Mac OS X v10.4
PBHOpenDFAsync Deprecated in Mac OS X v10.4
PBHOpenDFSync Deprecated in Mac OS X v10.4
PBHOpenRFAsync Deprecated in Mac OS X v10.4
PBHOpenRFSync Deprecated in Mac OS X v10.4
PBHOpenSync Deprecated in Mac OS X v10.4
PBHOpenDenyAsync Deprecated in Mac OS X v10.5
PBHOpenDenySync Deprecated in Mac OS X v10.5
PBHOpenRFDenyAsync Deprecated in Mac OS X v10.5
PBHOpenRFDenySync Deprecated in Mac OS X v10.5
FSReadFork
PBReadForkSync
PBReadForkAsync
FSWriteFork
PBWriteForkSync
PBWriteForkAsync
PBReadAsync Deprecated in Mac OS X v10.5
PBReadSync Deprecated in Mac OS X v10.5
PBWriteAsync Deprecated in Mac OS X v10.5
PBWriteSync Deprecated in Mac OS X v10.5
FSRead Deprecated in Mac OS X v10.4
FSWrite Deprecated in Mac OS X v10.4
PBResolveFileIDRefAsync Deprecated in Mac OS X v10.5
PBResolveFileIDRefSync Deprecated in Mac OS X v10.5
PBCatSearchAsync Deprecated in Mac OS X v10.4
PBCatSearchSync Deprecated in Mac OS X v10.4
FSOpenIterator
PBOpenIteratorSync
PBOpenIteratorAsync
FSCatalogSearch
PBCatalogSearchSync
PBCatalogSearchAsync
FSCloseIterator
PBCloseIteratorSync
PBCloseIteratorAsync
FSFlushFork
PBFlushForkSync
PBFlushForkAsync
PBFlushFileAsync Deprecated in Mac OS X v10.4
PBFlushFileSync Deprecated in Mac OS X v10.4
FSFlushVolume
PBFlushVolumeSync
PBFlushVolumeAsync
FlushVol Deprecated in Mac OS X v10.5
PBFlushVolAsync Deprecated in Mac OS X v10.5
PBFlushVolSync Deprecated in Mac OS X v10.5
FNNotify
FNNotifyAll
FNNotifyByPath
FNSubscribe
FNSubscribeByPath
FNUnsubscribe
FNGetDirectoryForSubscription
This section lists functions that are not recommended and you should no longer use.
PBWaitIOComplete Deprecated in Mac OS X v10.5
PBGetForeignPrivsAsync Deprecated in Mac OS X v10.4
PBGetForeignPrivsSync Deprecated in Mac OS X v10.4
PBGetUGEntryAsync Deprecated in Mac OS X v10.4
PBGetUGEntrySync Deprecated in Mac OS X v10.4
PBGetXCatInfoAsync Deprecated in Mac OS X v10.4
PBGetXCatInfoSync Deprecated in Mac OS X v10.4
PBHGetLogInInfoSync Deprecated in Mac OS X v10.4
PBSetForeignPrivsAsync Deprecated in Mac OS X v10.4
PBSetForeignPrivsSync Deprecated in Mac OS X v10.4
PBShareAsync Deprecated in Mac OS X v10.4
PBShareSync Deprecated in Mac OS X v10.4
PBUnshareAsync Deprecated in Mac OS X v10.4
PBUnshareSync Deprecated in Mac OS X v10.4
Deletes a universal procedure pointer (UPP) to your directory change callback function.
void DisposeFNSubscriptionUPP ( FNSubscriptionUPP userUPP );
The UPP to delete.
You should use this function to delete the UPP after the File Manager is finished calling your directory change callback function.
Files.h
Deletes a universal procedure pointer (UPP) to your volume ejection callback function.
void DisposeFSVolumeEjectUPP ( FSVolumeEjectUPP userUPP );
The UPP to delete.
You should use this function to delete the UPP after the File Manager is finished calling your volume ejection callback function.
Files.h
Deletes a universal procedure pointer (UPP) to your volume mount callback function.
void DisposeFSVolumeMountUPP ( FSVolumeMountUPP userUPP );
The UPP to delete.
You should use this function to delete the UPP after the File Manager is finished calling your volume mount callback function.
Files.h
Deletes a universal procedure pointer (UPP) to your volume unmount callback function.
void DisposeFSVolumeUnmountUPP ( FSVolumeUnmountUPP userUPP );
The UPP to delete.
You should use this function to delete the UPP after the File Manager is finished calling your volume unmount callback function.
Files.h
Deletes a universal procedure pointer (UPP) to your I/O completion callback function.
void DisposeIOCompletionUPP ( IOCompletionUPP userUPP );
The UPP to delete.
You should use this function to delete the UPP after the File Manager is finished calling your I/O completion callback function.
Files.h
Fetches the directory for which this subscription was originally entered.
OSStatus FNGetDirectoryForSubscription ( FNSubscriptionRef subscription, FSRef *ref );
The subscription previously returned from the functions FNSubscribe or FNSubscribeByPath.
On return, a file system reference to the directory for which this subscription was created.
A result code. See “File Manager Result Codes.”
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.
Files.h
Broadcasts notification of changes to the specified directory.
OSStatus FNNotify ( const FSRef *ref, FNMessage message, OptionBits flags );
A file system reference describing the directory for which to broadcast the notification.
An indication of what happened to the target directory.
Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.
A result code. See “File Manager Result Codes.”
Files.h
Broadcasts notification of changes to the filesystem.
OSStatus FNNotifyAll ( FNMessage message, OptionBits flags );
An indication of what happened.
Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.
A result code. See “File Manager Result Codes.”
This function should only be used by installers or programs which make lots of changes and only send one broadcast.
Files.h
Broadcasts notification of changes to the specified directory.
OSStatus FNNotifyByPath ( const UInt8 *path, FNMessage message, OptionBits flags );
The path to the directory for which to broadcast the notification.
An indication of what happened to the target directory.
Options regarding the delivery of the notification. Specify kNilOptions for the default behavior.
A result code. See “File Manager Result Codes.”
Files.h
Subscribes to change notifications for the specified directory.
OSStatus FNSubscribe ( const FSRef *directoryRef, FNSubscriptionUPP callback, void *refcon, OptionBits flags, FNSubscriptionRef *subscription );
A file system reference describing the directory for which the caller wants notifications.
A pointer to the function to call when a notification arrives.
A pointer to user state carried with the subscription.
Specify kNilOptions, or one of the options described in “Notification Subscription Options.”
A subscription token for subsequent query or unsubscription.
A result code. See “File Manager Result Codes.”
Files.h
Subscribes to change notifications for the specified directory.
OSStatus FNSubscribeByPath ( const UInt8 *directoryPath, FNSubscriptionUPP callback, void *refcon, OptionBits flags, FNSubscriptionRef *subscription );
A path to the directory for which the caller wants notifications.
The function to call when a notification arrives.
A pointer to the user state carried with the subscription.
Specify kNilOptions, or one of the options described in “Notification Subscription Options.”
A subscription token for subsequent query or unsubscription.
A result code. See “File Manager Result Codes.”
Files.h
Releases a subscription which is no longer needed.
OSStatus FNUnsubscribe ( FNSubscriptionRef subscription );
A subscription previously returned from the FNSubscribe orFNSubscribeByPath functions.
A result code. See “File Manager Result Codes.”
Files.h
Allocates space on a volume to an open fork.
OSErr FSAllocateFork ( FSIORefNum forkRefNum, FSAllocationFlags flags, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount, UInt64 *actualCount );
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.
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.
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.
The offset from the base location of the start of the allocation.
The number of bytes to allocate.
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.
A result code. See “File Manager Result Codes.”
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.
Files.h
Cancels an outstanding asynchronous volume mounting operation.
OSStatus FSCancelVolumeOperation ( FSVolumeOperation volumeOp );
The asynchronous volume operation to cancel.
A result code. See “File Manager Result Codes.”
This function currently is only supported for server mounts.
Files.h
Searches for objects traversed by a catalog iterator that match a given set of criteria.
OSErr FSCatalogSearch ( FSIterator iterator, const FSSearchParams *searchCriteria, ItemCount maximumObjects, ItemCount *actualObjects, Boolean *containerChanged, FSCatalogInfoBitmap whichInfo, FSCatalogInfo *catalogInfos, FSRef *refs, FSSpecPtr specs, HFSUniStr255 *names );
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.
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.
The maximum number of items to return for this call.
On return, a pointer to the actual number of items found for this call.
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.
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.
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.
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.
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.
A result code. See “File Manager Result Codes.” When the entire volume has been searched, errFSNoMoreItems is returned.
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.
Files.hCloses an open fork.
OSErr FSCloseFork ( FSIORefNum forkRefNum );
The reference number of the fork to close. After the call to this function, the reference number in this parameter is invalid.
A result code. See “File Manager Result Codes.”
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.
Files.h
Closes a catalog iterator.
OSErr FSCloseIterator ( FSIterator 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.
A result code. See “File Manager Result Codes.”
This function releases memory and other system resources used by the iterator. The iterator becomes invalid.
Files.h
Determines whether two FSRef structures refer to the same file or directory.
OSErr FSCompareFSRefs ( const FSRef *ref1, const FSRef *ref2 );
A pointer to the first FSRef to compare. For a description of the FSRef data type, see FSRef.
A pointer to the second FSRef to compare.
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.
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.
Files.hReturns a copy of the disk ID for a volume.
OSStatus FSCopyDiskIDForVolume ( FSVolumeRefNum vRefNum, CFStringRef *diskID );
The volume reference number of the target volume.
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.
A result code. See “File Manager Result Codes.”
Files.hStarts an asynchronous file operation to copy a source object to a destination directory.
OSStatus FSCopyObjectAsync ( FSFileOperationRef fileOp, const FSRef *source, const FSRef *destDir, CFStringRef destName, OptionBits flags, FSFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this copy operation.
A pointer to the source object to copy. The object can be a file or a directory.
A pointer to the destination directory.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
One or more file operation option flags. See “File Operation Options.”
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hCopies a source object to a destination directory.
OSStatus FSCopyObjectSync ( const FSRef *source, const FSRef *destDir, CFStringRef destName, FSRef *target, OptionBits options );
A pointer to the source object to copy. The object can be a file or a directory.
A pointer to the destination directory.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
One or more file operation option flags. See “File Operation Options.”
A result code. See “File Manager Result Codes.”
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.
Files.hReturns a copy of the URL for a volume.
OSStatus FSCopyURLForVolume ( FSVolumeRefNum vRefNum, CFURLRef *url );
The volume reference number of the target volume.
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.
A result code. See “File Manager Result Codes.”
Files.h
Creates a new directory (folder) with a Unicode name.
OSErr FSCreateDirectoryUnicode ( const FSRef *parentRef, UniCharCount nameLength, const UniChar *name, FSCatalogInfoBitmap whichInfo, const FSCatalogInfo *catalogInfo, FSRef *newRef, FSSpecPtr newSpec, UInt32 *newDirID );
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.
The length of the new directory's Unicode name.
A pointer to the Unicode name of the new directory.
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.
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.
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.
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.
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.
A result code. See “File Manager Result Codes.”
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.
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.
Files.h
Creates a new file with a Unicode name.
OSErr FSCreateFileUnicode ( const FSRef *parentRef, UniCharCount nameLength, const UniChar *name, FSCatalogInfoBitmap whichInfo, const FSCatalogInfo *catalogInfo, FSRef *newRef, FSSpecPtr newSpec );
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.
The length of the file's name.
A pointer to the Unicode name for the new file.
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.
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.
On return, a pointer to the FSRef for the new file. If you do not want the FSRef returned, specify NULL.
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.
A result code. See “File Manager Result Codes.”
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.
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.
Files.h
Creates a named fork for a file or directory.
OSErr FSCreateFork ( const FSRef *ref, UniCharCount forkNameLength, const UniChar *forkName );
A pointer to an FSRef specifying the file or directory. See FSRef for a description of the FSRef data type.
The length of the name of the new fork.
A pointer to the Unicode name of the fork.
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.
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.
Files.h
Returns an FSVolumeOperation which can be used for an asynchronous volume operation.
OSStatus FSCreateVolumeOperation ( FSVolumeOperation *volumeOp );
The new FSVolumeOperation.
A result code. See “File Manager Result Codes.”
When the operation is completed the FSVolumeOperation should be disposed of to free the memory associated with the operation using FSDisposeVolumeOperation.
Files.h
Deletes a named fork from a file or directory.
OSErr FSDeleteFork ( const FSRef *ref, UniCharCount forkNameLength, const UniChar *forkName );
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.
The length of the Unicode name of the fork name.
A pointer to the Unicode name of the fork to delete.
A result code. See “File Manager Result Codes.” If the named fork does not exist, the function returns errFSForkNotFound.
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.
Files.h
Deletes a file or an empty directory.
OSErr FSDeleteObject ( const FSRef *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.
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.
Files.h
Releases the memory associated with a volume operation.
OSStatus FSDisposeVolumeOperation ( FSVolumeOperation volumeOp );
The FSVolumeOperation to release.
A result code. See “File Manager Result Codes.” This function will return paramErr if the FSVolumeOperation is in use.
Files.h
Asynchronously ejects a volume.
OSStatus FSEjectVolumeAsync ( FSVolumeRefNum vRefNum, OptionBits flags, FSVolumeOperation volumeOp, void *clientData, FSVolumeEjectUPP callback, CFRunLoopRef runloop, CFStringRef runloopMode );
The volume reference number of the volume to eject.
Options for future use.
An FSVolumeOperation returned by FSCreateVolumeOperation.
A pointer to client data associated with the operation. This parameter can be NULL.
The function to call when eject is complete.
The runloop to run on.
The mode for the runloop.
A result code. See “File Manager Result Codes.”
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.
Files.h
Ejects a volume.
OSStatus FSEjectVolumeSync ( FSVolumeRefNum vRefNum, OptionBits flags, pid_t *dissenter );
The volume reference number of the volume to eject.
Options for future use.
On return, a pointer to the pid of the process which denied the unmount if the eject is denied.
A result code. See “File Manager Result Codes.”
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.
Files.h
Swaps the contents of two files.
OSErr FSExchangeObjects ( const FSRef *ref, const FSRef *destRef );
A pointer to an FSRef for the first file. See FSRef for a description of the FSRef data type.
A pointer to an FSRef for the second file.
A result code. See “File Manager Result Codes.”
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).
Files.hCancels an asynchronous file operation.
OSStatus FSFileOperationCancel ( FSFileOperationRef fileOp );
The file operation to cancel.
A result code. See “File Manager Result Codes.”
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.
Files.hGets a copy of the current status information for an asynchronous file operation.
OSStatus FSFileOperationCopyStatus ( FSFileOperationRef fileOp, FSRef *currentItem, FSFileOperationStage *stage, OSStatus *error, CFDictionaryRef *statusDictionary, void **info );
The file operation to access.
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).
A pointer to a file operation stage variable. On output, the variable contains the current stage of the file operation.
A pointer to an error status variable. On output, the variable contains the current error status of the file operation.
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.
A pointer to a generic pointer. On output, the generic pointer refers to user-defined data associated with this file operation.
A result code. See “File Manager Result Codes.”
Files.hCreates an object that represents an asynchronous file operation.
FSFileOperationRef FSFileOperationCreate ( CFAllocatorRef alloc );
The allocator to use. Pass NULL for the default allocator.
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.
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.
Files.hReturns the Core Foundation type identifier for the FSFileOperation opaque type.
CFTypeID FSFileOperationGetTypeID ( void );
The type identifier for the FSFileOperation opaque type. For information about this type, see FSFileOperationRef.
Files.hSchedules an asynchronous file operation with the specified run loop and mode.
OSStatus FSFileOperationScheduleWithRunLoop ( FSFileOperationRef fileOp, CFRunLoopRef runLoop, CFStringRef runLoopMode );
The file operation to schedule.
The run loop in which to schedule the operation. For information about Core Foundation run loops, see Run Loops.
The run loop mode in which to schedule the operation. In most cases, you may specify kCFRunLoopCommonModes.
A result code. See “File Manager Result Codes.”
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.
Files.hUnschedules an asynchronous file operation from the specified run loop and mode.
OSStatus FSFileOperationUnscheduleFromRunLoop ( FSFileOperationRef fileOp, CFRunLoopRef runLoop, CFStringRef runLoopMode );
The file operation to unschedule.
The run loop on which to unschedule the operation.
The run loop mode in which to unschedule the operation.
A result code. See “File Manager Result Codes.”
Files.h
Causes all data written to an open fork to be written to disk.
OSErr FSFlushFork ( FSIORefNum forkRefNum );
The reference number of the fork to flush.
A result code. See “File Manager Result Codes.”
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.
Files.hFor the specified volume, writes all open and modified files in the current process to permanent storage.
OSStatus FSFlushVolume ( FSVolumeRefNum vRefNum );
The volume reference number of the volume to flush.
A result code. See “File Manager Result Codes.”
Files.h
Returns the current status of an asynchronous eject operation.
OSStatus FSGetAsyncEjectStatus ( FSVolumeOperation volumeOp, FSEjectStatus *status, OSStatus *volumeOpStatus, FSVolumeRefNum *volumeRefNum, pid_t *dissenter, void **clientData );
The asynchronous volume operation to get status about.
On return, a pointer to the status of the operation.
If the status parameter is kAsyncEjectComplete then this contains the result code (OSStatus) for the operation on return.
On return, the volume reference number of the volume being ejected.
On return, a pointer to the pid of the process which denied the unmount if the eject is denied.
On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.
A result code. See “File Manager Result Codes.” A return value of noErr signifies that the status parameter has been filled with valid information.
Files.h
Returns the current status of an asynchronous mount operation.
OSStatus FSGetAsyncMountStatus ( FSVolumeOperation volumeOp, FSMountStatus *status, OSStatus *volumeOpStatus, FSVolumeRefNum *mountedVolumeRefNum, void **clientData );
The asynchronous volume operation to get status about.
On return, a pointer to the status of the operation.
If the status is kAsyncMountComplete then this parameter contains the result code for the operation on return.
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.
On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.
A result code. See “File Manager Result Codes.”
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.
Files.h
Returns the current status of an asynchronous unmount operation.
OSStatus FSGetAsyncUnmountStatus ( FSVolumeOperation volumeOp, FSUnmountStatus *status, OSStatus *volumeOpStatus, FSVolumeRefNum *volumeRefNum, pid_t *dissenter, void **clientData );
The asynchronous volume operation to get status about.
On return, a pointer to the status of the operation.
If the status is kAsyncUnmountComplete then this parameter contains a pointer to the result code (OSStatus) for the operation on return.
On return, a pointer to the volume reference number of the volume being unmounted.
On return, a pointer to the pid of the process which denied the unmount if the unmount is denied.
On return, a pointer to client data associated with the original FSMountServerVolumeAsync operation.
A result code. See “File Manager Result Codes.” A return value of noErr signifies that the status parameter has been filled with valid information.
Files.h
Returns catalog information about a file or directory. You can use this function to map an FSRef to an FSSpec.
OSErr FSGetCatalogInfo ( const FSRef *ref, FSCatalogInfoBitmap whichInfo, FSCatalogInfo *catalogInfo, HFSUniStr255 *outName, FSSpecPtr fsSpec, FSRef *parentRef );
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.
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.
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.
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.
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.
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.
A result code. See “File Manager Result Codes.”
Files.h
Returns information about one or more objects from a catalog iterator. This function can return information about multiple objects in a single call.
OSErr FSGetCatalogInfoBulk ( FSIterator iterator, ItemCount maximumObjects, ItemCount *actualObjects, Boolean *containerChanged, FSCatalogInfoBitmap whichInfo, FSCatalogInfo *catalogInfos, FSRef *refs, FSSpecPtr specs, HFSUniStr255 *names );
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.
The maximum number of items to return for this call.
On return, a pointer to the actual number of items found for this call.
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 Mac 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.
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.”
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.
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.
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.
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.
A result code. See “File Manager Result Codes.” When all of the iterator’s objects have been returned, the call will return errFSNoMoreItems.
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.
Files.h
Returns a Unicode string constant for the name of the data fork.
OSErr FSGetDataForkName ( HFSUniStr255 *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.
A result code. See “File Manager Result Codes.”
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.
Files.h
Returns information about a specified open fork, or about all open forks.
OSErr FSGetForkCBInfo ( FSIORefNum desiredRefNum, FSVolumeRefNum volume, short *iterator, FSIORefNum *actualRefNum, FSForkInfo *forkInfo, FSRef *ref, HFSUniStr255 *outForkName );
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Files.h
Returns the current position of an open fork.
OSErr FSGetForkPosition ( FSIORefNum forkRefNum, SInt64 *position );
The reference number of a fork previously opened by the FSOpenFork function or one of its corresponding parameter block calls, PBOpenForkSync and PBOpenForkAsync.
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).
A result code. See “File Manager Result Codes.”
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.
Files.h
Returns the size of an open fork.
OSErr FSGetForkSize ( FSIORefNum forkRefNum, SInt64 *forkSize );
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.h
Returns a Unicode string constant for the name of the resource fork.
OSErr FSGetResourceForkName ( HFSUniStr255 *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.
A result code. See “File Manager Result Codes.”
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.
Files.h
Returns information about a volume.
OSErr FSGetVolumeInfo ( FSVolumeRefNum volume, ItemCount volumeIndex, FSVolumeRefNum *actualVolume, FSVolumeInfoBitmap whichInfo, FSVolumeInfo *info, HFSUniStr255 *volumeName, FSRef *rootDirectory );
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.
The index of the desired volume, or 0 to use the volume reference number in the volume parameter.
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.
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.
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.
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.
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.
A result code. See “File Manager Result Codes.”
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.
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 Mac OS X, but behave correctly in Mac OS X version 10.3 and later.
Files.hRetrieves the mounting information associated with the specified volume.
OSStatus FSGetVolumeMountInfo ( FSVolumeRefNum volume, BytePtr buffer, ByteCount bufferSize, ByteCount *actualSize );
Files.hDetermines the size of the mounting information associated with the specified volume.
OSStatus FSGetVolumeMountInfoSize ( FSVolumeRefNum volume, ByteCount *size );
Files.hRetrieves information about the characteristics of a volume.
OSStatus FSGetVolumeParms ( FSVolumeRefNum volume, GetVolParmsInfoBuffer *buffer, ByteCount bufferSize );
Files.h
Determines the name and size of every named fork belonging to a file or directory.
OSErr FSIterateForks ( const FSRef *ref, CatPositionRec *forkIterator, HFSUniStr255 *forkName, SInt64 *forkSize, UInt64 *forkPhysicalSize );
A pointer to an FSRef specifying the file or directory to iterate. See FSRef for a description of the FSRef data type.
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.
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.
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hLocks a range of bytes of the specified fork.
OSStatus FSLockRange ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount, UInt64 *rangeStart );
Files.h
Constructs an FSRef for a file or directory, given a parent directory and a Unicode name.
OSErr FSMakeFSRefUnicode ( const FSRef *parentRef, UniCharCount nameLength, const UniChar *name, TextEncoding textEncodingHint, FSRef *newRef );
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.
The length of the file or directory 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.
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.
On return, if the function returns a result of noErr, a pointer to the new FSRef.
A result code. See “File Manager Result Codes.”
Files.h
Mounts a volume asynchronously.
OSStatus FSMountLocalVolumeAsync ( CFStringRef diskID, CFURLRef mountDir, FSVolumeOperation volumeOp, void *clientData, OptionBits flags, FSVolumeMountUPP callback, CFRunLoopRef runloop, CFStringRef runloopMode );
The disk to mount.
Pass in NULL ; currently only NULL is supported.
An FSVolumeOperation returned by FSCreateVolumeOperation
A pointer to client data associated with the operation. This parameter can be NULL.
Options for future use.
The function to call when mount is complete. This parameter can be NULL.
The runloop to run on.
The mode for the runloop.
A result code. See “File Manager Result Codes.”
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.
Files.h
Mounts a volume.
OSStatus FSMountLocalVolumeSync ( CFStringRef diskID, CFURLRef mountDir, FSVolumeRefNum *mountedVolumeRefNum, OptionBits flags );
The disk to mount.
Pass in NULL; currently only NULL is supported.
On return, a pointer to the volume reference number of the newly mounted volume.
Options for future use.
A result code. See “File Manager Result Codes.”
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.
Files.h
Mounts a server volume asynchronously.
OSStatus FSMountServerVolumeAsync ( CFURLRef url, CFURLRef mountDir, CFStringRef user, CFStringRef password, FSVolumeOperation volumeOp, void *clientData, OptionBits flags, FSVolumeMountUPP callback, CFRunLoopRef runloop, CFStringRef runloopMode );
The server to mount.
The directory to mount the server to. If this parameter is NULL, the default location is used.
A string to pass as the user for authentication. This parameter can be NULL.
A string to pass as the password for authenticated log in. This parameter can be NULL.
An FSVolumeOperation returned by the FSCreateVolumeOperation function.
A pointer to client data associated with the operation. This parameter can be NULL.
Options for future use.
A function to call when the mount is complete. This parameter can be NULL.
The runloop to run on.
The mode for the runloop.
A result code. See “File Manager Result Codes.”
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.
Files.h
Mounts a server volume.
OSStatus FSMountServerVolumeSync ( CFURLRef url, CFURLRef mountDir, CFStringRef user, CFStringRef password, FSVolumeRefNum *mountedVolumeRefNum, OptionBits flags );
The server to mount.
The directory to mount the server to. If this parameter is NULL, the default location is used.
A string to pass as the user for authentication.
A string to pass as the password for authenticated log in.
On return, a pointer to the volume reference number of the newly mounted volume.
Options for future use.
A result code. See “File Manager Result Codes.”
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.
Files.h
Moves a file or directory into a different directory.
OSErr FSMoveObject ( const FSRef *ref, const FSRef *destDirectory, FSRef *newRef );
A pointer to an FSRef specifying the file or directory to move. See FSRef for a description of the FSRef data type.
A pointer to an FSRef specifying the directory into which the file or directory indicated by the ref parameter will be moved.
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.
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.
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.
Files.hStarts an asynchronous file operation to move a source object to a destination directory.
OSStatus FSMoveObjectAsync ( FSFileOperationRef fileOp, const FSRef *source, const FSRef *destDir, CFStringRef destName, OptionBits flags, FSFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this move operation.
A pointer to the source object to move. The object can be a file or a directory.
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.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hMoves a source object to a destination directory.
OSStatus FSMoveObjectSync ( const FSRef *source, const FSRef *destDir, CFStringRef destName, FSRef *target, OptionBits options );
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.
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.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hStarts an asynchronous file operation to move a source object to the Trash.
OSStatus FSMoveObjectToTrashAsync ( FSFileOperationRef fileOp, const FSRef *source, OptionBits flags, FSFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this move operation. For more information, see the function FSFileOperationCreate.
A pointer to the source object to move. The object can be a file or a directory.
One or more file operation option flags. See “File Operation Options.”
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hMoves a source object to the Trash.
OSStatus FSMoveObjectToTrashSync ( const FSRef *source, FSRef *target, OptionBits options );
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.
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.
One or more file operation option flags. See “File Operation Options.”
A result code. See “File Manager Result Codes.”
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.)
Files.h
Opens any fork of a file or directory for streaming access.
OSErr FSOpenFork ( const FSRef *ref, UniCharCount forkNameLength, const UniChar *forkName, SInt8 permissions, FSIORefNum *forkRefNum );
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.
The length of the fork name in Unicode characters.
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.
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.”
On return, a pointer to the fork reference number for accessing the open fork.
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.
When you use this function to open a file on a local volume and pass in a permissions value of fsCurPerm, fsWrPerm, or fsRdWrPerm , Mac 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.
Files.h
Creates a catalog iterator that can be used to iterate over the contents of a directory or volume.
OSErr FSOpenIterator ( const FSRef *container, FSIteratorFlags iteratorFlags, FSIterator *iterator );
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.
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hStarts an asynchronous file operation to copy a source object to a destination directory using pathnames.
OSStatus FSPathCopyObjectAsync ( FSFileOperationRef fileOp, const char *sourcePath, const char *destDirPath, CFStringRef destName, OptionBits flags, FSPathFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this copy operation.
The UTF-8 pathname of the source object to copy. The object can be a file or a directory.
The UTF-8 pathname of the destination directory.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
One or more file operation option flags. See “File Operation Options.”
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hCopies a source object to a destination directory using pathnames.
OSStatus FSPathCopyObjectSync ( const char *sourcePath, const char *destDirPath, CFStringRef destName, char **targetPath, OptionBits options );
The UTF-8 pathname of the source object to copy. The object can be a file or a directory.
The UTF-8 pathname of the destination directory.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
One or more file operation option flags. See “File Operation Options.”
A result code. See “File Manager Result Codes.”
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.
Files.hGets a copy of the current status information for an asynchronous file operation that uses pathnames.
OSStatus FSPathFileOperationCopyStatus ( FSFileOperationRef fileOp, char **currentItem, FSFileOperationStage *stage, OSStatus *error, CFDictionaryRef *statusDictionary, void **info );
The file operation to access.
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.
A pointer to a file operation stage variable. On output, the variable contains the current stage of the file operation.
A pointer to an error status variable. On output, the variable contains the current error status of the file operation.
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.
A pointer to a generic pointer. On output, the generic pointer refers to user-defined data associated with this file operation.
A result code. See “File Manager Result Codes.”
Files.hConverts a POSIX-style pathname into an FSRef structure.
OSStatus FSPathMakeRef ( const UInt8 *path, FSRef *ref, Boolean *isDirectory );
A UTF-8 C string that contains the pathname to convert.
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.
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.
A result code. See “File Manager Result Codes.”
Files.h
Converts a POSIX-style pathname into an FSRef structure with options.
OSStatus FSPathMakeRefWithOptions ( const UInt8 *path, OptionBits options, FSRef *ref, Boolean *isDirectory );
A UTF-8 C string that contains the pathname to convert.
One or more conversion flags. See “Path Conversion Options.”
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.
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.
A result code. See “File Manager Result Codes.”
Files.hStarts an asynchronous file operation to move a source object to a destination directory using pathnames.
OSStatus FSPathMoveObjectAsync ( FSFileOperationRef fileOp, const char *sourcePath, const char *destDirPath, CFStringRef destName, OptionBits flags, FSPathFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this move operation.
The UTF-8 pathname of the source object to move. The object can be a file or a directory.
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.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hMoves a source object to a destination directory using pathnames.
OSStatus FSPathMoveObjectSync ( const char *sourcePath, const char *destDirPath, CFStringRef destName, char **targetPath, OptionBits options );
The UTF-8 pathname of the source object to move. The object can be a file or a directory.
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.
The name for the new object in the destination directory. Pass NULL to use the name of the source object.
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hStarts an asynchronous file operation to move a source object, specified using a pathname, to the Trash.
OSStatus FSPathMoveObjectToTrashAsync ( FSFileOperationRef fileOp, const char *sourcePath, OptionBits flags, FSPathFileOperationStatusProcPtr callback, CFTimeInterval statusChangeInterval, FSFileOperationClientContext *clientContext );
The file operation object you created for this move operation. For more information, see the function FSFileOperationCreate.
The UTF-8 pathname of the source object to move. The object can be a file or a directory.
One or more file operation option flags. See “File Operation Options.”
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.
The minimum time in seconds between callbacks within a single stage of an operation.
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.
A result code. See “File Manager Result Codes.”
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.
Files.hMoves a source object, specified using a pathname, to the Trash.
OSStatus FSPathMoveObjectToTrashSync ( const char *sourcePath, char **targetPath, OptionBits options );
The UTF-8 pathname of the source object to move. The object can be a file or a directory.
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.
One or more file operation option flags. See “File Operation Options.”
A result code. See “File Manager Result Codes.”
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.)
Files.hReads data from an open fork.
OSErr FSReadFork ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset, ByteCount requestCount, void *buffer, ByteCount *actualCount );
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.
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.
The offset from the base location for the start of the read.
The number of bytes to read.
A pointer to the buffer where the data will be returned.
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.
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.
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 Mac OS X, you should align your requests to 4KB boundaries.
Files.h
Converts an FSRef structure into a POSIX-style pathname.
OSStatus FSRefMakePath ( const FSRef *ref, UInt8 *path, UInt32 maxPathSize );
A pointer to the FSRef structure to convert.
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.
The maximum number of bytes to copy into the buffer.
A result code. See “File Manager Result Codes.”
Files.h
Renames a file or folder.
OSErr FSRenameUnicode ( const FSRef *ref, UniCharCount nameLength, const UniChar *name, TextEncoding textEncodingHint, FSRef *newRef );
A pointer to an FSRef for the file or directory to rename. See FSRef for a description of the FSRef data type.
The length of the new name in Unicode characters.
A pointer to the new Unicode name of the file or directory.
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.
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.
A result code. See “File Manager Result Codes.”
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.
Files.h
Sets catalog information about a file or directory.
OSErr FSSetCatalogInfo ( const FSRef *ref, FSCatalogInfoBitmap whichInfo, const FSCatalogInfo *catalogInfo );
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.
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.
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
A result code. See “File Manager Result Codes.”
Files.h
Sets the current position of an open fork.
OSErr FSSetForkPosition ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset );
The reference number of a fork previously opened by the FSOpenFork, PBOpenForkSync, or PBOpenForkAsync function.
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.
The offset of the new position from the base location specified in the positionMode parameter.
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.
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.
Files.h
Changes the size of an open fork.
OSErr FSSetForkSize ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset );
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.
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.
The offset of the new size from the base location specified in the positionMode parameter.
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.
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.
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.
Files.h
Sets information about a volume.
OSErr FSSetVolumeInfo ( FSVolumeRefNum volume, FSVolumeInfoBitmap whichInfo, const FSVolumeInfo *info );
The volume reference number of the volume whose information is to be changed. See FSVolumeRefNum for a description of the FSVolumeRefNum data type.
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.
A pointer to the new volume information. See FSVolumeInfo for a description of the FSVolumeInfo data type.
A result code. See “File Manager Result Codes.”
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.
Files.hUnlocks a range of bytes of the specified fork.
OSStatus FSUnlockRange ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount, UInt64 *rangeStart );
Files.h
Unmounts a volume asynchronously.
OSStatus FSUnmountVolumeAsync ( FSVolumeRefNum vRefNum, OptionBits flags, FSVolumeOperation volumeOp, void *clientData, FSVolumeUnmountUPP callback, CFRunLoopRef runloop, CFStringRef runloopMode );
The volume reference number of the volume to unmount.
Options for future use.
An FSVolumeOperation returned by the FSCreateVolumeOperation function.
A pointer to client data associated with the operation.
The function to call when the unmount is complete.
The runloop to run on.
The mode for the runloop.
A result code. See “File Manager Result Codes.”
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.
Files.h
Unmounts a volume.
OSStatus FSUnmountVolumeSync ( FSVolumeRefNum vRefNum, OptionBits flags, pid_t *dissenter );
The volume reference number of the volume to unmount.
Options for future use.
On return, a pointer to the pid of the process which denied the unmount if the unmount is denied.
A result code. See “File Manager Result Codes.”
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.
Files.hMounts a volume using the specified mounting information.
OSStatus FSVolumeMount ( BytePtr buffer, FSVolumeRefNum *mountedVolume );
Files.hWrites data to an open fork.
OSErr FSWriteFork ( FSIORefNum forkRefNum, UInt16 positionMode, SInt64 positionOffset, ByteCount requestCount, const void *buffer, ByteCount *actualCount );
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.
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.
The offset from the base location for the start of the write.
The number of bytes to write.
A pointer to a buffer containing the data to write.
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.
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.
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 Mac OS X, you should align your requests to 4KB boundaries.
Files.h
Calls your directory change callback function.
void InvokeFNSubscriptionUPP ( FNMessage message, OptionBits flags, void *refcon, FNSubscriptionRef subscription, FNSubscriptionUPP userUPP );
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.
Files.h
Calls your volume ejection callback function.
void InvokeFSVolumeEjectUPP ( FSVolumeOperation volumeOp, void *clientData, OSStatus err, FSVolumeRefNum volumeRefNum, pid_t dissenter, FSVolumeEjectUPP userUPP );
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.
Files.h
Calls your volume mount callback function.
void InvokeFSVolumeMountUPP ( FSVolumeOperation volumeOp, void *clientData, OSStatus err, FSVolumeRefNum mountedVolumeRefNum, FSVolumeMountUPP userUPP );
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.
Files.h
Calls your volume unmount callback function.
void InvokeFSVolumeUnmountUPP ( FSVolumeOperation volumeOp, void *clientData, OSStatus err, FSVolumeRefNum volumeRefNum, pid_t dissenter, FSVolumeUnmountUPP userUPP );
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.
Files.h
Calls your I/O completion callback function.
void InvokeIOCompletionUPP ( ParmBlkPtr paramBlock, IOCompletionUPP userUPP );
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.
Files.h
Creates a new universal procedure pointer (UPP) to your directory change callback function.
FNSubscriptionUPP NewFNSubscriptionUPP ( FNSubscriptionProcPtr userRoutine );
A pointer to a directory change callback function. For more information, see FNSubscriptionProcPtr.
A UPP to your directory change callback function.
Files.h
Creates a new universal procedure pointer (UPP) to your volume ejection callback function.
FSVolumeEjectUPP NewFSVolumeEjectUPP ( FSVolumeEjectProcPtr userRoutine );
A pointer to a volume ejection callback function. For more information, see FSVolumeEjectProcPtr.
A UPP to your volume ejection callback function.
Files.h
Creates a new universal procedure pointer (UPP) to your volume mount callback function.
FSVolumeMountUPP NewFSVolumeMountUPP ( FSVolumeMountProcPtr userRoutine );
A pointer to a volume mount callback function. For more information, see FSVolumeEjectProcPtr.
A UPP to your volume mount callback function.
Files.h
Creates a new universal procedure pointer (UPP) to your volume unmount callback function.
FSVolumeUnmountUPP NewFSVolumeUnmountUPP ( FSVolumeUnmountProcPtr userRoutine );
A pointer to a volume unmount callback function. For more information, see FSVolumeUnmountProcPtr.
A UPP to your volume unmount callback function.
Files.h
Creates a new universal procedure pointer (UPP) to your I/O completion callback function.
IOCompletionUPP NewIOCompletionUPP ( IOCompletionProcPtr userRoutine );
A pointer to your I/O completion callback function. For more information, see IOCompletionProcPtr.
A UPP to your I/O completion callback function.
Files.h
Allocates space on a volume to an open fork.
void PBAllocateForkAsync ( FSForkIOParam *paramBlock );
A pointer to a fork I/O parameter block. See FSForkIOParam for a description of the FSForkIOParam data type.
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 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 flushed, using FSFlushFork , PBFlushForkSync , or PBFlushForkAsync.
Files.h
Allocates space on a volume to an open fork.
OSErr PBAllocateForkSync ( FSForkIOParam *paramBlock );
A pointer to a fork I/O parameter block. See FSForkIOParam for a description of the FSForkIOParam data type.
A result code. See “File Manager Result Codes.”
The relevant fields of the parameter block are:
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 functions, 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 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 PBAllocateForkSync 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 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 flushed, using FSFlushFork , PBFlushForkSync , or PBFlushForkAsync.
Files.h
Searches for objects traversed by a catalog iterator that match a given set of criteria.
void PBCatalogSearchAsync ( FSCatalogBulkParam *paramBlock );
A pointer to a catalog information parameter block. See FSCatalogBulkParam for a description of the FSCatalogBulkParam data type.
The relevant fields of this parameter 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 the entire volume has been searched, errFSNoMoreItems is returned.
iterator On input, the iterator to use. Objects traversed by this iterator are matched against the criteria specified by the searchParams field. 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.
searchParams On input, a pointer to an FSSearchParams 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 PBCatalogSearchAsync 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 maximumItems 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 field to point to FSCatalogInfo structures containing the values to match against.
maximumItems On input, the maximum number of items to return for this call.
actualItems On output, the actual number of items returned for this call.
containerChanged On output, a Boolean value indicating whether the container’s contents have changed. If true, the container’s contents changed since the previous PBCatalogSearchAsync 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.
whichInfo On input, 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 field. See “Catalog Information Bitmap Constants” for a description of the bits in this field.
catalogInfo On output, a pointer to an array of FSCatalogInfo structures; one for each found item. On input, the catalogInfo field should point to an array of maximumItems catalog information structures. This field is optional; if you do not wish any catalog information returned, pass NULL here.
refs On output, a pointer to an array of FSRef structures; one for each returned item. On input, if you want an FSRef for each item found, pass a pointer to an array of maximumItems FSRef structures. Otherwise, pass NULL.
names On output, a pointer to an array of filenames; one for each returned item. On input, if you want the Unicode filename for each item found, pass a pointer to an array of maximumItems HFSUniStr255 structures. Otherwise, pass NULL.
A single search may span more than one call to PBCatalogSearchAsync. The call may complete with no error before scanning the entire volume. This typically happens because the time limit ( searchTime) has been reached or maximumItems items have been returned. If the search is not completed, you can continue the search by making another call to PBCatalogSearchAsync and passing the updated iterator returned by the previous call in the iterator field.
Before calling this function, you should determine that it is present, by calling the Gestalt function.
Files.h
Searches for objects traversed by a catalog iterator that match a given set of criteria.
OSErr PBCatalogSearchSync ( FSCatalogBulkParam *paramBlock );
A pointer to a catalog information parameter block. See FSCatalogBulkParam for a description of the FSCatalogBulkParam data type.
A result code. See “File Manager Result Codes.” When the entire volume has been searched, errFSNoMoreItems is returned.
The relevant fields of this parameter are:
iterator On input, the iterator to use. Objects traversed by this iterator are matched against the criteria specified by the searchParams field. 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.
searchParams On input, a pointer to an FSSearchParams 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 PBCatalogSearchSync 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 maximumItems 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 field to point to FSCatalogInfo structures containing the values to match against.
maximumItems On input, the maximum number of items to return for this call.
actualItems On output, the actual number of items returned for this call.
containerChanged On output, a Boolean value indicating whether the container’s contents have changed. If true, the container’s contents changed since the previous PBCatalogSearchSync 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.
whichInfo On input, 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 field. See “Catalog Information Bitmap Constants” for a description of the bits in this field.
catalogInfo On output, a pointer to an array of FSCatalogInfo structures; one for each found item. On input, the catalogInfo field should point to an array of maximumItems catalog information structures. This field is optional; if you do not wish any catalog information returned, pass NULL here.
refs On output, a pointer to an array of FSRef structures; one for each returned item. On input, if you want an FSRef for each item found, pass a pointer to an array of maximumItems FSRef structures. Otherwise, pass NULL.
names On output, a pointer to an array of filenames; one for each returned item. On input, if you want the Unicode filename for each item found, pass a pointer to an array of maximumItems HFSUniStr255 structures. Otherwise, pass NULL.
A single search may span more than one call to PBCatalogSearchSync. The call may complete with no error before scanning the entire volume. This typically happens because the time limit ( searchTime) has been reached or maximumItems items have been returned. If the search is not completed, you can continue the search by making another call to PBCatalogSearchSync and passing the updated iterator returned by the previous call in the iterator field.
Before calling this function, you should determine that it is present, by calling the Gestalt function.
Files.hCloses an open fork.
void PBCloseForkAsync ( FSForkIOParam *paramBlock );
A pointer to a fork I/O parameter block. See FSForkIOParam for a description of the FSForkIOParam.
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 fork to close. After the call to this function, the reference number in this parameter is invalid.
The PBCloseForkAsync function causes all data written to the fork to be written to disk, in the same manner as the PBFlushForkAsync function, before it closes the fork.
Files.hCloses an open fork.
OSErr PBCloseForkSync ( FSForkIOParam *paramBlock );
A pointer to a fork I/O parameter block. See FSForkIOParam for a description of the FSForkIOParam.
A result code. See “File Manager Result Codes.”
The relevant field of the parameter block is:
forkRefNum On input, the reference number of the fork to close. After the call to this function, the reference number in this parameter is invalid.
The PBCloseForkSync function causes all data written to the fork to be written to disk, in the same manner as the PBFlushForkSync function, before it closes the fork.
Files.h
Closes a catalog iterator.
void PBCloseIteratorAsync ( FSCatalogBulkParam *paramBlock );
A pointer to a catalog information parameter block. See FSCatalogBulkParam for a description of the FSCatalogBulkParam data type.
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.
iterator On input, the catalog iterator to close. PBCloseIteratorAsync releases memory and other system resources used by the iterator, making the iterator invalid. See FSIterator for a description of the FSIterator data type.
Files.h
Closes a catalog iterator.
OSErr PBCloseIteratorSync ( FSCatalogBulkParam *paramBlock );
A pointer to a catalog information parameter block. See FSCatalogBulkParam for a description of the FSCatalogBulkParam data type.
A result code. See “File Manager Result Codes.”
The relevant field of the parameter block is:
iterator On input, the catalog iterator to close. PBCloseIteratorSync releases memory and other system resources used by the iterator, making the iterator invalid. See FSIterator for a description of the FSIterator data type.
Files.h
Determines whether two FSRef structures refer to the same file or directory.
void PBCompareFSRefsAsync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
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. 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 call may return other errors, including nsvErr, fnfErr, dirNFErr, and volOffLinErr. See “File Manager Result Codes”.
ref On input, a pointer to the first FSRef to compare. See FSRef for a description of the FSRef data type.
parentRef On input, a pointer to the second FSRef to compare.
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.
Files.h
Determines whether two FSRef structures refer to the same file or directory.
OSErr PBCompareFSRefsSync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
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.
The relevant fields of the parameter block are:
ref On input, a pointer to the first FSRef to compare. See FSRef for a description of the FSRef data type.
parentRef On input, a pointer to the second FSRef to compare.
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.
Files.h
Creates a new directory (folder) with a Unicode name.
void PBCreateDirectoryUnicodeAsync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
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. See “File Manager Result Codes”.
ref On input, a pointer to an FSRef for the parent directory where the new directory is to be created.
nameLength On input, the number of Unicode characters in the new directory's name.
name On input, a pointer to the Unicode name of the new directory.
whichInfo On input, a bitmap specifying which catalog information fields to set for the new directory. Specify the values for these fields in the catInfo field. 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 field.
catInfo On input, a pointer to the FSCatalogInfo structure which specifies the values of the new directory’s catalog information fields. Specify which fields to set in the whichInfo field. Specify NULL if you do not wish to set catalog information for the new directory.
newRef On output, a pointer to the FSRef for the new directory. If you do not want the FSRef returned, pass NULL on input.
spec On output, a pointer to the FSSpec for the new directory. If you do not want the FSSpec returned, pass NULL on input.
ioDirID On output, the directory ID of the new directory.
You may optionally set catalog information for the new directory using the whichInfo and catInfo fields; 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 catInfo field. This will be used by the volume format when converting the Unicode filename to other encodings.
Files.h
Creates a new directory (folder) with a Unicode name.
OSErr PBCreateDirectoryUnicodeSync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
A result code. See “File Manager Result Codes.”
The relevant fields of the parameter block are:
ref On input, a pointer to an FSRef for the parent directory where the new directory is to be created.
nameLength On input, the number of Unicode characters in the new directory's name.
name On input, a pointer to the Unicode name of the new directory.
whichInfo On input, a bitmap specifying which catalog information fields to set for the new directory. Specify the values for these fields in the catInfo field. 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 field.
catInfo On input, a pointer to the FSCatalogInfo structure which specifies the values of the new directory’s catalog information fields. Specify which fields to set in the whichInfo field. Specify NULL if you do not wish to set catalog information for the new directory.
newRef On output, a pointer to the FSRef for the new directory. If you do not want the FSRef returned, pass NULL on input.
spec On output, a pointer to the FSSpec for the new directory. If you do not want the FSSpec returned, pass NULL on input.
ioDirID On output, the directory ID of the new directory.
You may optionally set catalog information for the new directory using the whichInfo and catInfo fields; 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 catInfo field. This will be used by the volume format when converting the Unicode filename to other encodings.
Files.h
Creates a new file with a Unicode name.
void PBCreateFileUnicodeAsync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
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. See “File Manager Result Codes”.
ref On input, a pointer to an FSRef for the directory where the file is to be created.
nameLength On input, the number of Unicode characters in the file's name.
name On input, a pointer to the Unicode name of the new file.
whichInfo On input, a bitmap specifying which catalog information fields to set for the new file. Specify the values for these fields in the catInfo field. If you do not wish to set catalog information for the new file, pass the constant kFSCatInfoNone here. See “Catalog Information Bitmap Constants” for a description of the bits defined for this field.
catInfo On input, a pointer to the FSCatalogInfo structure which specifies the values of the new file’s catalog information fields. Specify which fields to set in the whichInfo field. This field is optional; specify NULL if you do not wish to set catalog information for the new file.
newRef On output, a pointer to the FSRef for the new file. If you do not want the FSRef returned, pass NULL on input.
spec On output, a pointer to the FSSpec for the new file. If you do not want the FSSpec returned, pass NULL on input.
You may optionally set catalog information for the file using the whichInfo and catInfo fields; 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 catInfo field. This will be used by the volume format when converting the Unicode filename to other encodings.
If the PBCreateFileUnicodeAsync function is present, but is not implemented by a particular volume, the File Manager will emulate this function by making the appropriate call to PBHCreateAsync. 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.
Files.h
Creates a new file with a Unicode name.
OSErr PBCreateFileUnicodeSync ( FSRefParam *paramBlock );
A pointer to a file system reference parameter block. See FSRefParam for a description of the FSRefParam data type.
A result code. See “File Manager Result Codes.”
The relevant fields of the parameter block are:
ref On input, a pointer to an FSRef for the directory where the file is to be created.
nameLength On input, the number of Unicode characters in the file's name.
name On input, a pointer to the Unicode name of the new file.
whichInfo On input, a bitmap specifying which catalog information fields to set for the new file. Specify the values for these fields in the catInfo field. If you do not wish to set catalog information for the new file, pass the constant kFSCatInfoNone here. See “Catalog Information Bitmap Constants”