home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-05-01 | 37.0 KB | 927 lines | [ TEXT/MPS ]
{ File: FileManager.p Contains: FileManager Interface Version: Technology: System 8 Release: Universal Interfaces 3.0d3 on Copland DR1 Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved. Bugs?: If you find a problem with this file, send the file and version information (from above) and the problem description to: Internet: apple.bugs@applelink.apple.com AppleLink: APPLE.BUGS } {$IFC UNDEFINED UsingIncludes} {$SETC UsingIncludes := 0} {$ENDC} {$IFC NOT UsingIncludes} UNIT FileManager; INTERFACE {$ENDC} {$IFC UNDEFINED __FILEMANAGER__} {$SETC __FILEMANAGER__ := 1} {$I+} {$SETC FileManagerIncludes := UsingIncludes} {$SETC UsingIncludes := 1} {$IFC UNDEFINED __FILEMANAGERTYPES__} {$I FileManagerTypes.p} {$ENDC} {$IFC UNDEFINED __FILES__} {$I Files.p} {$ENDC} {$IFC UNDEFINED __FINDER__} {$I Finder.p} {$ENDC} {$PUSH} {$ALIGN POWER} {$LibExport+} { You can use FileManager.h or FileManagerSPI.h, but not both } {$IFC UNDEFINED _FILEMANAGERSPI__ } {$IFC FOR_SYSTEM8_PREEMPTIVE } { >>>>>>>>>>>>>>>>>>>>>>>>>>>>> F o u n d a t i o n D e f i n i t i o n s <<<<<<<<<<<<<<<<<<<<<<<<<<<<< } { **************************************************************************** CONSTANTS & TYPES **************************************************************************** } CONST kFSInfoInvalidVersion = 0; kFSInfoD10Version = 1; kFSInfoD11Version = 2; kFSInfoCurrentReleasedVersion = 2; TYPE FSInfoVersion = UInt32; CONST kFSHFSPath = 1; kFSUnixPath = 2; kFSDOSPath = 3; TYPE FSPathnameType = UInt32; CONST kFSFileIsLocked = $00000001; TYPE FSFileFlags = OptionBits; FSFileInformationPtr = ^FSFileInformation; FSFileInformation = RECORD flags: FSFileFlags; finderInfo: FInfo; extendedFinderInfo: FXInfo; creationDate: FSDate; modificationDate: FSDate; dataForkSize: FSSize; resourceForkSize: FSSize; END; CONST kFSFolderIsLocked = $00000001; TYPE FSFolderFlags = OptionBits; FSFolderInformationPtr = ^FSFolderInformation; FSFolderInformation = RECORD flags: FSFolderFlags; finderInfo: DInfo; extendedFinderInfo: DXInfo; creationDate: FSDate; modificationDate: FSDate; END; CONST kFSVolumeIsLockedInHardware = $00000001; kFSVolumeIsLockedInSoftware = $00000002; kFSVolumeIsLockedMask = $00000003; kFSVolumeIsEjectable = $00000004; kFSVolumeIsOffline = $00000008; kFSVolumeIsRemote = $00000010; TYPE FSVolumeFlags = OptionBits; FSVolumeInformationPtr = ^FSVolumeInformation; FSVolumeInformation = RECORD folderInfo: FSFolderInformation; flags: FSVolumeFlags; totalBytes: FSSize; freeBytes: FSSize; constraints: FSMountAccessConstraints; capabilities: FSVolumeCapabilities; END; FSObjectInformationPtr = ^FSObjectInformation; FSObjectInformation = RECORD objectType: FSObjectType; CASE INTEGER OF 0: ( fileInfo: FSFileInformation; ); 1: ( folderInfo: FSFolderInformation; ); 2: ( volumeInfo: FSVolumeInformation; ); END; { >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> C O N T A I N E R S <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< } { **************************************************************************** OBJECTS **************************************************************************** } { Function: FSObjectRefClone Purpose: Return a copy of an FSObjectRef such that the copy also needs to be disposed. Inputs: object_t The object ref to be cloned. Outputs: clone_o Copy of object_t. Notes: The value returned is the same value passed as input in object_t. This call would typically be used to balance a future call to FSObjectRefDispose. Some examples where it might be used: • A called procedure needs to save an FSObjectRef for future use, but the calling conventions dictate that the caller is responsible for disposing of the ref. The called function could call FSObjectRefClone to make its copy. The caller can safely dispose of the ref, yet the callee can use the ref until doing its own dispose. • In object-oriented programming, an object could be passed an FSObjectRef in its constructor. The destructor would be expected to dispose the ref, but so would the routine that created the object. FSObjectRefClone could be used in the constructor. The returned FSObjectRef is registered to the calling process (as must object_t). } FUNCTION FSObjectRefClone(object_t: FSObjectRef; VAR clone_o: FSObjectRef): OSStatus; C; { Function: FSObjectRefDispose Purpose: Dispose of an FSObjectRef previously returned to a process. Inputs: object_t The object ref to be disposed. Outputs: Notes: A process must dispose of all FSObjectRefs returned to it. The FSObjectRefs may be returned as explicit output parameters, or as properties. If a ref is returned several times for a given object, it must be disposed for each time it was returned. When all refs to a given object are disposed, the File Manager will dispose of any resources it allocated in order to operate on that object. All refs for a process will be automatically disposed upon process termination. For refs returned as properties (especially when iterating over muliple objects), the FSObjectRefDisposeBulk call may be more convenient. } FUNCTION FSObjectRefDispose(object_t: FSObjectRef): OSStatus; C; { Function: FSObjectFlush Purpose: Flushes any data cached by the File Manager for the given object. Inputs: object_t The object to be flushed. Outputs: Notes: If object_t is a file, then any data written to that file (via a stream or backing store, regardless of the process that opened the stream or backing store) will be written by the File Manager to any underlying device. If object_t is a volume, then any data written to any file on that volume will be flushed. Any change to properties of object_t will be flushed (regardless of the object's type). Data about the object (or contained in the object) may still reside in the File Manager's caches, but any changes will have been written out by the File Manager. Note that the underlying device's driver, or the device itself, may cache some data, so the File Manager cannot guarantee that all data has actually been written to the underlying media. } FUNCTION FSObjectFlush(object_t: FSObjectRef): OSStatus; C; { Function: FSObjectRefRegister Purpose: Allow an FSObjectRef to be used by another process. Inputs: senderObject_t The object ref. receiverPid_i The other process that will be using senderObject_t. Outputs: Notes: This call allows one process to send an FSObjectRef to another process such that the other process can use the FSObjectRef itself. The process specified by receiverPid_i must also dispose of senderObject_t. The File Manager acts as if senderObject_t has been returned to receiverPid_i. You might use this call if you have several processes where one process (typically a server of some kind) obtains FSObjectRefs for use by other processes (typically clients of that server). If the other process (as specified by receiverPid_i) won't actually call the File Manager with that FSObjectRef, then it doesn't need to be registered to that process. It would also be possible to have the server process make all of the calls to the File Manager. FSObjectRefs could still be passed between client and server, but if the clients never use the refs directly, then there would be no need to register the refs to those clients. (But beware: the server would still be responsible for disposing of all refs returned to it; the server would probably have some cleanup and disposal to do if one of its client processes were to terminate.) } FUNCTION FSObjectRefRegister(senderObject_t: FSObjectRef; receiverPid_i: KernelProcessID): OSStatus; C; { ============================================================================ Volume Sets ============================================================================ } { Function: FSVolumeSetGetInformation Purpose: Returns an FSObjectRef for a Volume Set specified by an FSVolumeSetObjID. Inputs: volumeSet_t The volume set. Outputs: object_o Object ref for the volume set. includesBootVolume_o True if the volume set includes the boot volume. Notes: There is currently only one volume set. In the future there could be others (perhaps file servers; perhaps to support multiple local users). } FUNCTION FSVolumeSetGetInformation(volumeSet_t: FSVolumeSetObjID; VAR includesBootVolume_o: BOOLEAN; VAR object_o: FSObjectRef): OSStatus; C; { ============================================================================ Folders ============================================================================ } { Function: FSFolderCreate Purpose: Create a new named folder within a specified folder Inputs: containerRef_t The object ref of the parent of the new folder. folderName_i The name of the new folder as a _persistent_ TextObject. Outputs: folderRef_o The object ref of the new folder. Notes: An error will be returned if the folder already exists. } FUNCTION FSFolderCreate(containerRef_t: FSObjectRef; folderName_i: ConstFSName; VAR folderRef_o: FSObjectRef): OSStatus; C; { ============================================================================ Files ============================================================================ } { Function: FSFileCreate Purpose: Create a new named file within a specified folder Inputs: containerRef_t The object ref of the parent of the new file. fileName_i The name of the new file as a _persistent_ TextObject. fileCreator_i The new file's Finder creator. fileType_i The new file's Finder type. Outputs: fileRef_o The object ref of the new file. Notes: An error will be returned if the file already exists. } FUNCTION FSFileCreate(containerRef_t: FSObjectRef; fileName_i: ConstFSName; fileCreator_i: OSType; fileType_i: OSType; VAR fileRef_o: FSObjectRef): OSStatus; C; { ============================================================================ Folder and File Requests ============================================================================ } { Function: FSObjectDelete Purpose: Deletes an object. The FSObjectRef is NOT disposed; you must still dispose it yourself. Further attempts to use the ref will return errors (such as E_ObjectNotFound). Inputs: object_t The object to be deleted. Outputs: } FUNCTION FSObjectDelete(object_t: FSObjectRef): OSStatus; C; { Function: FSObjectMoveRename Purpose: Move a file or folder to a new folder and (optionally) rename it. Inputs: sourceObjectRef_t The object ref of the file or folder to move. destContainerRef_i The object ref of the new parent folder. newObjectName_i The new name for the moved file or folder (optional). Outputs: Notes: An error will be returned if another file or folder exists in the folder specified by destContainerRef_i which has the same name as sourceObjectRef_t. } FUNCTION FSObjectMoveRename(sourceObjectRef_t: FSObjectRef; destContainerRef_i: FSObjectRef; newObjectName_i: ConstFSName): OSStatus; C; { Function: FSObjectRename Purpose: Rename a file or folder. Inputs: sourceObjectRef_t The object ref of the file or folder to rename. newObjectName_i The new name for the file or folder. Outputs: Notes: An error will be returned if another file or folder exists in the same folder as sourceObjectRef_t with the name newObjectName_i. } FUNCTION FSObjectRename(sourceObjectRef_t: FSObjectRef; newObjectName_i: ConstFSName): OSStatus; C; { >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> C a p a b i l i t i e s <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< } { **************************************************************************** PROPERTY ACCESS METHODS **************************************************************************** } { ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Object Property Simple Values ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } { Function: FSObjectGetOneProperty Purpose: Get one property attribute of an object. Inputs: objectRef_t The object ref. property_i The property attribute to get. propertySize_i The size of the property buffer specified by propertyValue_o Outputs: property_o The requested property data. Notes: This function can be used to get the value of a simple property as well as other attributes of all properties such as size, type, state, etc. The attribute to get is specified by property_i->attribute. Fork property values must be obtained by using the stream or mapped file access routines. } FUNCTION FSObjectGetOneProperty(objectRef_t: FSObjectRef; {CONST}VAR property_i: FSProperty; propertySize_i: ByteCount; property_o: LogicalAddress): OSStatus; C; { Function: FSObjectGetInformation Purpose: Get a predefined aggregate property set for an object. Inputs: objectRef_t The object ref. infoVersion_i The version of the FSObjectInformation data record specified by objectInfo_o. Outputs: objectInfo_o The aggregate property data (optional). objectName_o The name of the specified object (optional). Notes: Use kFSInfoCurrentReleasedVersion for infoVersion_i to specify the latest version of the FSObjectInformation record. infoVersion_i is ignored if objectInfo_o is omitted. objectName_o, if specified, must reference a preinitialized persistent TextObject of sufficient size to contain the object's name. } FUNCTION FSObjectGetInformation(objectRef_t: FSObjectRef; infoVersion_i: FSInfoVersion; VAR objectInfo_o: FSObjectInformation; objectName_o: FSName): OSStatus; C; { Function: FSObjectGetVolumeInformation Purpose: Get a predefined aggregate property set for a volume object. Inputs: volumeItemRef_t The object ref of a file or folder on the volume or the volume itself. infoVersion_i The version of the FSObjectInformation data record specified by volumeInfo_o. Outputs: volumeInfo_o The aggregate volume property data (optional). volumeObjectRef_o The object ref of the volume (optional). volumeName_o The name of the volume (optional). Notes: Use kFSInfoCurrentReleasedVersion for infoVersion_i to specify the latest version of the FSObjectInformation record. infoVersion_i is ignored if volumeInfo_o is omitted. volumeName_o, if specified, must reference a preinitialized persistent TextObject of sufficient size to contain the volume's name. This function is functionally equivalent to FSObjectGetInformation when the target object ref is the volume's object ref. } FUNCTION FSObjectGetVolumeInformation(volumeItemRef_t: FSObjectRef; infoVersion_i: FSInfoVersion; VAR volumeInfo_o: FSObjectInformation; VAR volumeObjectRef_o: FSObjectRef; volumeName_o: FSName): OSStatus; C; { Function: FSObjectSetOneProperty Purpose: Set one property attribute of an object. Inputs: objectRef_t The object ref. property_i The property attribute to set. propertySize_i The size of the property buffer specified by propertyValue_i. propertyData_i The new property data. Outputs: Notes: Fork property values must be changed by using the stream or mapped file access routines. } FUNCTION FSObjectSetOneProperty(objectRef_t: FSObjectRef; {CONST}VAR property_i: FSProperty; propertySize_i: ByteCount; propertyData_i: ConstLogicalAddress): OSStatus; C; { ============================================================================ Stream-based Access Method ============================================================================ } { Function: FSStreamClose Purpose: Close a stream previously opened with FSStreamOpen or FSStreamOpenWithConstraints. Inputs: stream_t The stream to close. Outputs: Notes: Any data written to the stream is flushed (written by the File Manager) before the stream is closed. The FSStreamObjID, stream_t, may no longer be used. Any resources allocated by the File Manager for use by this stream will be disposed. } FUNCTION FSStreamClose(stream_t: FSStreamObjID): OSStatus; C; { Function: FSStreamFlush Purpose: Any data written to the stream will be written by the File Manager. Inputs: stream_t The stream to flush. Outputs: Notes: Stream data may still reside in the File Manager's caches, but any changes will have been written out by the File Manager. Note that the underlying device's driver, or the device itself, may cache some data, so the File Manager cannot guarantee that all data has actually been written to the underlying media. Other information about the object (such as its modification date) might not be flushed by this call, though any volume-level data needed to access the stream will be. } FUNCTION FSStreamFlush(stream_t: FSStreamObjID): OSStatus; C; { Function: FSStreamGetAbsoluteEOF Purpose: Get the logical end-of-file of an open file fork. Inputs: stream_t The target stream. Outputs: currentEOF_o The logical end-of-file of the specified stream. Notes: } FUNCTION FSStreamGetAbsoluteEOF(stream_t: FSStreamObjID; VAR currentEOF_o: FSOffset): OSStatus; C; { Function: FSStreamGetMark Purpose: Returns the current mark (position offset) for a stream. Inputs: stream_t The stream. Outputs: currentMark_o Current offset in the stream, stream_t. Notes: This call returns the offset from the start of the file that would be equivalent to using a FSForkPositionDescriptor whose positionOffset is 0, and whose positionMode is kFSFromMark. A stream's mark is set to the byte following the last read or write, or via FSStreamSetMark. } FUNCTION FSStreamGetMark(stream_t: FSStreamObjID; VAR currentMark_o: FSOffset): OSStatus; C; { Function: FSStreamOpen Purpose: Open a file fork for stream access. Inputs: fileObjectRef_t The object ref of the file to open. fork_i The fork to open. Outputs: stream_o The new stream ID. Notes: The only allowable values for fork_i are kFSDataFork and kFSResourceFork. FSStreamOpen attempts to open the fork with exclusive read/write access. If the file is locked or is open on another stream with conflicting access constraints, then an error is returned. Use FSStreamOpenWithConstraints() to specify particular access constratins. } FUNCTION FSStreamOpen(fileObjectRef_i: FSObjectRef; fork_i: FSForkType; VAR stream_o: FSStreamObjID): OSStatus; C; { Function: FSStreamSetAbsoluteEOF Purpose: Set the logical end-of-file of an open file fork. Inputs: stream_t The target stream. eof_i The new logical end-of-file of the stream. Outputs: Notes: If there is not enough space on the volume to set the EOF of the fork specified by stream_t to eof_i, then the EOF is not changed and an error is returned. } FUNCTION FSStreamSetAbsoluteEOF(stream_t: FSStreamObjID; {CONST}VAR eof_i: FSOffset): OSStatus; C; { Function: FSStreamSetMark Purpose: Sets the current mark (position offset) for a stream. Inputs: stream_t The stream. newPosition_i The new position of the stream's mark. options_i Outputs: originalMark_o The stream's mark, before being changed (relative to the start of the stream). currentMark_o The new mark, relative to the start of the stream. Notes: A stream's mark is usually used for sequential access to a stream, or to position relative to the ending position of the last operation on a stream. This call lets you explicitly set the mark for future operations that will operate relative to the current mark. If kFSMarkPinToEOF is set in options_i, and the new position specified by newPosition_i would exceed the current end of the stream (also known as End Of File or EOF), then the mark will be set to the EOF and E_NoError is returned. Otherwise, an error will returned. The mark may never be set past the end of the stream. } FUNCTION FSStreamSetMark(stream_t: FSStreamObjID; {CONST}VAR newPosition_i: FSForkPositionDescriptor; options_i: FSStreamSetMarkOptions; VAR originalMark_o: FSOffset; VAR currentMark_o: FSOffset): OSStatus; C; { Function: FSStreamSimpleRead Purpose: Read data from an open stream. Inputs: stream_t The target stream. requestLength_i The number of bytes to read from the fork. position_i The starting position for the read operation Outputs: data_o The address of a buffer to the read bytes. actualLength_o The actual number of bytes read from the file (optional). currentMark_o The mark position within the stream after the read operation (optional) Notes: The stream mark is always positioned after the last byte read after all calls to FSStreamSimpleRead(). If an attempt is made to read beyond the logical EOF of the fork, then the mark is set at the logical EOF of the file, actualLength_o contains the actual number of bytes read, and an error is returned. } FUNCTION FSStreamSimpleRead(stream_t: FSStreamObjID; requestLength_i: ByteCount; {CONST}VAR position_i: FSForkPositionDescriptor; data_o: LogicalAddress; VAR actualLength_o: ByteCount; VAR currentMark_o: FSOffset): OSStatus; C; { Function: FSStreamSimpleWrite Purpose: Write data to an open stream. Inputs: stream_t The target stream. requestLength_i The number of bytes to write to the fork. data_i The address of a buffer contating the data to write. position_i The starting position for the write operation Outputs: actualLength_o The actual number of bytes written to the file (optional). currentMark_o The mark position within the stream after the read operation (optional) Notes: The stream mark is always positioned after the last byte written after all calls to FSStreamSimpleWrite(). If an attempt is made to write beyond the logical EOF of the fork, then the EOF is moved to the byte following the last written byte. } FUNCTION FSStreamSimpleWrite(stream_t: FSStreamObjID; requestLength_i: ByteCount; data_i: ConstLogicalAddress; {CONST}VAR position_i: FSForkPositionDescriptor; VAR actualLength_o: ByteCount; VAR currentMark_o: FSOffset): OSStatus; C; { ============================================================================ Memory-mapped Access Method(Backing Store Requests) ============================================================================ } { Function: FSMappedFileClose Purpose: Closes an access path to a file used for backing store. Inputs: backingStore_t The backing store object. Outputs: Notes: Basically the same as FSStreamClose, but for a backing store. All data written to this backing store (by writing to pages backed by this store) will be flushed (written) by the File Manager. } FUNCTION FSMappedFileClose(backingStore_t: FSBackingStoreObjID): OSStatus; C; { Function: FSMappedFileFlush Purpose: Any data written via the backing store will be written by the File Manager. Inputs: backingStore_t The backing store to flush. Outputs: Notes: Data may still reside in the File Manager's caches, but any changes will have been written out by the File Manager. Note that the underlying device's driver, or the device itself, may cache some data, so the File Manager cannot guarantee that all data has actually been written to the underlying media. Other information about the object (such as its modification date) might not be flushed by this call, though any volume-level data needed to access the fork data will be. } FUNCTION FSMappedFileFlush(backingStore_t: FSBackingStoreObjID): OSStatus; C; { Function: FSMappedFileGetAbsoluteEOF Purpose: Return the EOF (length) of the fork being accessed by the given backing store. Inputs: backingStore_t The backing store used to access the fork. Outputs: currentEOF_o The size, in bytes, of the fork. Notes: Since access to a fork via a backing store (i.e. memory mapped file access) is accomplished by directly accessing memory pages, the virtual memory system must read and write entire pages. If the last page is modified, the entire page is written, resulting in the fork size being rounded up to a multiple of a page size. Similarly for access to pages beyond the fork's EOF. This call returns the current EOF (length) of the underlying fork. This may be set implicitly by writing to backed pages, or by using the FSMappedFileSetEOF call. It may also be changed by streams opened to the same fork. } FUNCTION FSMappedFileGetAbsoluteEOF(backingStore_t: FSBackingStoreObjID; VAR currentEOF_0: FSOffset): OSStatus; C; { Function: FSMappedFileOpen Purpose: Open a file fork for memory mapped access. Inputs: fileObjectRef_t The object ref of the file to open. fork_i The fork to open. Outputs: backingStore_o The backing store used to access the fork. Notes: The only allowable values for fork_i are kFSDataFork and kFSResourceFork. FSMappedFileOpen attempts to open the fork with exclusive read/write access. If the file is locked or is open on another stream with conflicting access constraints, then an error is returned. Use FSMappedFileOpenWithConstraints() to specify particular access constratins. } FUNCTION FSMappedFileOpen(fileObjectRef_t: FSObjectRef; fork_i: FSForkType; VAR backingStore_o: FSBackingStoreObjID): OSStatus; C; { Function: FSMappedFileSetAbsoluteEOF Purpose: Sets the EOF (length) of the fork being accessed by the given backing store. Inputs: backingStore_t The backing store used to access the fork. eof_i The new length (EOF) of the fork. Outputs: currentEOF_o The new size, in bytes, of the fork. Notes: Since access to a fork via a backing store (i.e. memory mapped file access) is accomplished by directly accessing memory pages, the virtual memory system must read and write entire pages. If the last page is modified, the entire page is written, resulting in the fork size being rounded up to a multiple of a page size. Similarly for access to pages beyond the fork's EOF. This call allows the EOF to be explicitly set for a fork being accessed via a backing store. Any data beyond the EOF will not actually be written to the fork. The File Manager has no way to detect whether access to pages occurs beyond the EOF; it is a programming error to access bytes beyond the EOF via a backing store. This call would typically be used when a fork has been memory mapped to enable convenient access to a file's data structures as if it were completely in memory. You would make all changes to the data structures, then use this call to indicate the number of bytes that are valid and should be written to the fork. } FUNCTION FSMappedFileSetAbsoluteEOF(backingStore_t: FSBackingStoreObjID; {CONST}VAR eof_i: FSOffset; VAR currentEOF_o: FSOffset): OSStatus; C; { **************************************************************************** NAVIGATION & ENUMERATION **************************************************************************** } { ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Object Iteration ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } { Function: FSObjectIterateOnce Purpose: Iterate to the next object in the current container and get aggregate property information. Inputs: iterator_t The object iterator. objectInfoVersion_i The version of the FSObjectInformation data record specified by objectInfo_o. Outputs: objectInfo_o Aggregate property information about the current iterator object (optional). objectRef_o The object ref of the current iterator object (optional). objectName_o The name of the current iterator object (optional). Notes: Use kFSInfoCurrentReleasedVersion for infoVersion_i to specify the latest version of the FSObjectInformation record. infoVersion_i is ignored if objectInfo_o is omitted. objectName_o, if specified, must reference a preinitialized persistent TextObject of sufficient size to contain the object's name. If the iterator has reached the end of it's current container, then an exception will be returned. } FUNCTION FSObjectIterateOnce(iterator_t: FSObjectIteratorObjID; objectInfoVersion_i: FSInfoVersion; VAR objectInfo_o: FSObjectInformation; VAR objectRef_o: FSObjectRef; objectName_o: FSName): OSStatus; C; { Function: FSObjectIteratorChangeCurrentScope Purpose: Move an object iterator into or out of a container. Inputs: iterator_t The object iterator. movement_i The direction to move: into or out of a container. Outputs: Notes: If movement_i is kFSObjectEnter, then the iterator must be positioned on an object that is capable of containing other objects; it does not need to actually contain any objects at that time. That object will become the new current scope of the iterator and it will be in Start Of Iteration state (meaning that all objects in the current scope have yet to be returned). The iterator will not be positioned on any object. If movement_i is kFSObjectExit, then the current scope will become the object that contains the current scope; the iterator's new position will be the object that was the current scope. If the current scope and the outermost scope were the same, then the outermost scope will also change to the new current scope and E_ExitIteratorScope is returned (so that you realize you will be iterating outside of the scope that you used to create the iterator; the iterator remains usable). Object iterators keep track of all of the objects between the outermost scope and the current scope (this is known as the "scope stack"). If any object in the scope stack is moved, the iterator is invalidated and will return the error E_IteratorScopeException until it has been explicitly fixed (by FSObjectIteratorRecreate) or disposed. This call adds or removes objects from the scope stack. } FUNCTION FSObjectIteratorChangeCurrentScope(iterator_t: FSObjectIteratorObjID; movement_i: FSObjectIteratorMovement): OSStatus; C; { Function: FSObjectIteratorCreate Purpose: Create an iterator for iterating over objects. Inputs: outermostScope_t The initial outermost scope and current scope. options_i Controls whether the iterator will traverse objects in a single container or all embedded (nested) containers. Also controls which kinds of objects will be returned. Outputs: iterator_o The object iterator. Notes: The outermost scope and current scope of the iterator are set to outermostScope_t. The iterator is not positioned on any object, though it is inside outermostScope_t. OutermostScope_t must be an object capable of containing other objects (such as the Universe, a volume set, a volume, or a folder). The iterator is put into "Start Of Iteration" state, meaning that all objects in the current scope have yet to be returned. The File Manager allocates resources and maintains state for every iterator. When you have finished using an iterator, you should call FSObjectIteratorDispose to dispose of it. } FUNCTION FSObjectIteratorCreate(outermostScope_t: FSObjectRef; options_i: FSObjectIteratorCreationOptions; VAR iterator_o: FSObjectIteratorObjID): OSStatus; C; { Function: FSObjectIteratorDispose Purpose: Dispose of an object iterator. Inputs: iterator_t The object iterator. Outputs: Notes: The File Manager will dispose of the iterator and release any resources allocated to the iterator. Further attempts to use the iterator will result in an error. } FUNCTION FSObjectIteratorDispose(iterator_t: FSObjectIteratorObjID): OSStatus; C; { Function: FSObjectIteratorRestart Purpose: Place an object iterator in the Start Of Iterator state, in its current scope. Inputs: iterator_t The object iterator. Outputs: Notes: The iterator is not positioned on any object. The iterator is put into "Start Of Iteration" state, meaning that all objects in the current scope have yet to be returned. You would use this call to completely restart iteration within the current scope, ignoring any state about objects previously returned in the current scope. The outermost scope is not affected. State information about which objects have been returned from scopes outside the current scope is unchanged. } FUNCTION FSObjectIteratorRestart(iterator_t: FSObjectIteratorObjID): OSStatus; C; { ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Object Resolution ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } { Function: FSObjectCreateRef Purpose: Get the object ref for a named object in a given container. Inputs: container_i The object container ref. objectName_i The name of the target object. Outputs: objectRef_o The resulting object ref. Notes: } FUNCTION FSObjectCreateRef(container_i: FSObjectRef; objectName_i: ConstFSName; VAR objectRef_o: FSObjectRef): OSStatus; C; { Function: FSObjectExchange Purpose: Exchange the properties of two objects. Typically used for "safe saving", while maintaining an object's persistent reference. Inputs: object1_i One object. object2_i The object to exchange it with. Outputs: Notes: This call is used to allow a "safe save" that preserves an object's persistent reference. For example, you might want to save an updated set of properties to an object so that any errors while saving result in the object being unchanged; but, you also want the object's persistent reference to remain unchanged (so that things like aliases still work). What you would do is create a second object somewhere (in a temporary folder, for example). Write out all of the properties, both unchanged and changed, to the second object. When done saving, you would call FSObjectExchange with both objects; the contents of the two objects get swapped in such a way that the original object has the new properties, but retains its old persistent reference. } FUNCTION FSObjectExchange(object1_i: FSObjectRef; object2_i: FSObjectRef): OSStatus; C; { Function: FSObjectGetContainerRef Purpose: Get the object ref for the container of a given object. Inputs: objectRef_i The object of interest. Outputs: containerRef_o The object ref of the container of containerRef_o. Notes: } FUNCTION FSObjectGetContainerRef(objectRef_i: FSObjectRef; VAR containerRef_o: FSObjectRef): OSStatus; C; { Function: FSObjectRefGetFSSpec Purpose: Return an FSSpec for an object (suitable for use with the Files API). Inputs: object_t The object. Outputs: fSSpec_o An FSSpec that specifies the same object as object_t, suitable for use with the Files API. Notes: This call is intended to be used by code that is required to use both the Files API and the FileManager API (or has clients that use both APIs). For example, a piece of code may already exist with an API that uses FSSpecs, but has been converted internally to use the FSObjectRefs; it would use this call to produce an FSSpec as an output for the pre-existing API. It would be best to provide an API that allows its clients to use FSObjectRefs. } FUNCTION FSObjectRefGetFSSpec(object_t: FSObjectRef; VAR fSSpec_o: FSSpec): OSStatus; C; { } FUNCTION FSPathnameResolve(container_i: FSObjectRef; path_i: ConstCStringPtr; pathLength_i: ByteCount; pathType_i: FSPathnameType; VAR objectRef_o: FSObjectRef): OSStatus; C; { Function: FSSpecGetFSObjectRef Purpose: Return an FSObjectRef for an object specified via an FSSpec. Inputs: theFSSpec_t An FSSpec for the object. Outputs: theObject_o An FSObjectRef for the object. Notes: This call is intended to be used by code that is required to use both the Files API and the FileManager API (or has clients that use both APIs). For example, a piece of code may already exist with an API that uses FSSpecs, but has been converted internally to use the FSObjectRefs; it would use this call to take an input FSSpec and convert it to an FSObjectRef to use internally; the FSObjectRef would then be disposed before completing the call. It would be best to provide an API that allows its clients to use FSObjectRefs. } FUNCTION FSSpecGetFSObjectRef({CONST}VAR theFSSpec_t: FSSpec; VAR theObject_o: FSObjectRef): OSStatus; C; { Function: FSVolumeGetInformation Purpose: Get the volume object ref for a given volume object ID. Inputs: volume_t The volume's object ID. Outputs: object_o The volume's object ref. Notes: } FUNCTION FSVolumeGetInformation(volume_t: FSVolumeObjID; VAR object_o: FSObjectRef): OSStatus; C; FUNCTION FSObjectGetOnePropertySize(objectRef_t: FSObjectRef; {CONST}VAR property_i: FSProperty; VAR propertySize_o: FSSize): OSStatus; C; {$ENDC} {$ENDC} {$ALIGN RESET} {$POP} {$SETC UsingIncludes := FileManagerIncludes} {$ENDC} {__FILEMANAGER__} {$IFC NOT UsingIncludes} END. {$ENDC}