ResKnife/External/MoreFiles/FSpCompat.c

1 line
26 KiB
C
Raw Normal View History

2002-03-29 14:59:03 +00:00
/* File: FSpCompat.c Contains: FSSpec compatibility functions. Version: MoreFiles Copyright: <09> 1992-2001 by Apple Computer, Inc., all rights reserved. You may incorporate this sample code into your applications without restriction, though the sample code has been provided "AS IS" and the responsibility for its operation is 100% yours. However, what you are not permitted to do is to redistribute the source as "DSC Sample Code" after having made changes. If you're going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple Sample Code, but that you've made changes. File Ownership: DRI: Apple Macintosh Developer Technical Support Other Contact: Apple Macintosh Developer Technical Support <http://developer.apple.com/bugreporter/> Technology: DTS Sample Code Writers: (JL) Jim Luther Change History (most recent first): <2> 2/7/01 JL Added standard header. Updated names of includes. Updated various routines to use new calling convention of the MoreFilesExtras accessor functions. <1> 12/06/99 JL MoreFiles 1.5. */ /* ** If building application 68K code, set GENERATENODATA to 0 for faster code. ** If building stand-alone 68K code, set GENERATENODATA to 1 so globals ** (static variables) are not used. */ #ifndef GENERATENODATA #define GENERATENODATA 0 #endif #include <MacTypes.h> #include <MacErrors.h> #include <Files.h> #include <LowMem.h> #include <Gestalt.h> #include <Resources.h> #include <Script.h> #define __COMPILINGMOREFILES #include "MoreFilesExtras.h" #include "FSpCompat.h" /*****************************************************************************/ /* local constants */ enum { gestaltBugFixAttrsTwo = 'bugy', gestaltFSpExchangeFilesCompatibilityFix = 26, gestaltBugFixAttrsThree = 'bugx', gestaltFSpCreateScriptSupportFix = 1 }; /*****************************************************************************/ /* static prototypes */ #if !__MACOSSEVENORLATER static Boolean FSHasFSSpecCalls(void); static Boolean QTHasFSSpecCalls(void); #endif /* !__MACOSSEVENORLATER */ #if !__MACOSSEVENFIVEORLATER static Boolean HasFSpExchangeFilesCompatibilityFix(void); static OSErr GenerateUniqueName(short volume, long *startSeed, long dir1, long dir2, StringPtr uniqueName); #endif /* !__MACOSSEVENFIVEORLATER */ #if !__MACOSSEVENFIVEONEORLATER static Boolean HasFSpCreateScriptSupportFix(void); #endif /* !__MACOSSEVENFIVEONEORLATER */ /*****************************************************************************/ /* FSHasFSSpecCalls returns true if the file system provides FSSpec calls. */ #if !__MACOSSEVENORLATER static Boolean FSHasFSSpecCalls(void) { long response; #if !GENERATENODATA static Boolean tested = false; static Boolean result = false; #else Boolean result = false; #endif #if !GENERATENODATA if ( !tested ) { tested = true; #endif if ( Gestalt(gestaltFSAttr, &response) == noErr ) { result = ((response & (1L << gestaltHasFSSpecCalls)) != 0); } #if !GENERATENODATA } #endif return ( result ); } #endif /* !__MACOSSEVENORLATER */ /*****************************************************************************/ /* QTHasFSSpecCalls returns true if QuickTime provides FSSpec calls */ /* except for FSpExchangeFiles. */ #if !__MACOSSEVENORLATER static Boolean QTHasFSSpecCalls(void) { long response; #if !GENERATENODATA static Boolean tested = false; static Boolean result = false; #else Boolean result = false; #endif #if !GENERATENODATA if ( !tested ) { tested = true; #endif result = (Gestalt(gestaltQuickTimeVersion, &response) == noErr); #if !GENERATENODATA } #endif return ( result ); } #endif /* !__MACOSSEVENORLATER */ /*****************************************************************************/ /* HasFSpExchangeFilesCompatibilityFix returns true if FSpExchangeFiles */ /* compatibility code has been fixed in system software. */ /* This was fixed by System Update 3.0, so if SystemSevenF