home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FileURLDesc.h
-
- Description:
- Handy routines for dealing with typeFileURL. These routines assist
- in sending and receiving typeFileURL descriptors in Apple events,
- most helpfully in dealing with references to nonexistent files.
-
- Copyright:
- © Copyright 2001 Apple Computer, Inc. All rights reserved.
-
- Disclaimer:
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
- copyrights in this original Apple software (the "Apple Software"), to use,
- reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions of
- the Apple Software. Neither the name, trademarks, service marks or logos of
- Apple Computer, Inc. may be used to endorse or promote products derived from the
- Apple Software without specific prior written permission from Apple. Except as
- expressly stated in this notice, no other rights or licenses, express or implied,
- are granted by Apple herein, including but not limited to any patent rights that
- may be infringed by your derivative works or by other works in which the Apple
- Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
- OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
- (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Change History (most recent first):
- May 31, 2001 -- created
- */
-
-
- #ifndef _FILEURLDESC_
- #define _FILEURLDESC_
-
- #if FRAMEWORKS
- #include <Carbon/Carbon.h>
- #else
- #include <Files.h>
- #include <Navigation.h>
- #include <AppleEvents.h>
- #include <AEDataModel.h>
- #include <CFString.h>
- #include <CFURL.h>
- #endif
-
- /**************************************************************************
- typeFileURL is a simple AE data type. The data of a file URL is the data
- of a 'file'-scheme CFURL. This type is also sent by and can be used with
- the Drag Manager.
- **************************************************************************/
-
- #define typeFileURL 'furl'
-
-
- /**************************************************************************
- This call extracts the operative parts of a NavReplyRecord and creates a CFURLRef.
- After calling FURLCreateFromNavReply, you are responsible for releasing the CFURLRef.
- **************************************************************************/
-
- OSStatus FURLCreateFromNavReply(CFAllocatorRef allocator, const NavReplyRecord * navReply, CFURLRef* ref);
-
-
- /**************************************************************************
- These calls can be used to put typeFileURL descriptors into and out of Apple event descriptors and records.
- FURLCreateDescFromCFURL takes a CFURLRef and fills out an AEDesc record, which you are then responsible for
- disposing of when you are finished with it. FURLPutParamCFURL works like AEPutParamDesc but takes a
- CFURLRef (which you remain responsible for). The FURLPutKeyCFURL is an equivalent function for an AERecord.
-
- These calls obey AppleEvent calling conventions and return an OSErr.
- **************************************************************************/
-
- OSStatus FURLCreateDescFromCFURL(CFURLRef url, AEDesc * desc);
- OSStatus FURLPutParamCFURL(AppleEvent * event, DescType key, CFURLRef url);
- #define FURLPutKeyCFURL(e, k, u) FURLPutParamCFURL((AERecord *)e, k, u)
-
-
- /**************************************************************************
- These calls can be used to create CFURLs from the contents of Apple event structures. FURLCreateFromAEDesc
- takes a string AEDesc and creates a new CFURL, returning you the CFURLRef; it does not affect the input desc.
- FURLCreateFromAppleEventParam extracts a string descriptor from an Apple event and creates a CFURLRef
- from it if possible. FURLCreateFromAERecordKey is the equivalent function for dealing with AERecords instead of
- Apple events.
-
- For all of these calls, if the input string is typeChar, typeStyledText, or typeUnicodeText, it will be
- percent-escaped. If it is a typeFileURL it is assumed to be escaped already.
-
- You are resposible for disposing of the CFURLRef.
- **************************************************************************/
-
- OSStatus FURLCreateFromAEDesc(CFAllocatorRef allocator, const AEDesc * desc, CFURLRef * url);
- OSStatus FURLCreateFromAppleEventParam(CFAllocatorRef allocator, const AppleEvent * event, DescType key, CFURLRef * url);
- #define FURLCreateFromAERecordKey(a, e, k, u) FURLCreateFromAppleEventParam(a, (const AERecord *)e, k, u)
-
-
- /**************************************************************************
- This call is an alternative to CFURLCreateFromFSRef, but takes an FSSpec that may specify a nonexistent
- file.
- **************************************************************************/
-
- OSStatus FURLCreateFromFSSpec(CFAllocatorRef allocator, const FSSpec * spec, CFURLRef * ref);
-
-
- /**************************************************************************
- This call can be used to create a new file from a file specified by a CFURL. It behaves like FSCreateFileUnicode
- (which it uses) but takes a CFURL instead of an FSRef and UniChar *. It also takes the whichInfo and catalogInfo
- fields and passes them unaltered to FSCreateFileUnicode. Note that the entire path up to the leaf
- node file must exist; this call will not create intermediate directories specified in the URL. It returns the
- same error codes as FSCreateUnicode.
- **************************************************************************/
-
- OSStatus FURLCreateFileWithCFURL(CFURLRef url, FSCatalogInfoBitmap whichInfo,
- const FSCatalogInfo * catalogInfo, FSRef * ref);
-
- /**************************************************************************
- The following routines can be installed as coercion handlers in your application. They coerce between typeFileURL and
- the following types:
-
- typeChar
- typeStyledText
- typeUnicodeText
- cFile
- typeFSSpec
- typeFSRef
- typeObjectSpecifier
-
- In the case of typeObjectSpecifier, the keyAEKeyData field of the specifier can be any string type
- to coerce to a typeFileURL, and will be typeUnicodeText when coercing from typeFileURL.
- **************************************************************************/
-
- OSErr FURLCoerceDescToFURL(const AEDesc *fromDesc, DescType toType, long handlerRefcon, AEDesc *toDesc);
- OSErr FURLCoerceFURLPtrToDesc(DescType typeCode, const void *dataPtr, Size dataSize, DescType toType, long handlerRefcon, AEDesc *result);
-
-
- #endif
-