You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(447) |
Nov
(163) |
Dec
(57) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(172) |
Feb
|
Mar
(123) |
Apr
(64) |
May
(1) |
Jun
(278) |
Jul
(89) |
Aug
(97) |
Sep
(62) |
Oct
(53) |
Nov
(119) |
Dec
(60) |
| 2006 |
Jan
(76) |
Feb
(1094) |
Mar
(363) |
Apr
(163) |
May
(57) |
Jun
(43) |
Jul
(39) |
Aug
(15) |
Sep
(33) |
Oct
(62) |
Nov
(8) |
Dec
|
| 2007 |
Jan
(9) |
Feb
(34) |
Mar
(2) |
Apr
(14) |
May
(8) |
Jun
(40) |
Jul
(21) |
Aug
(1) |
Sep
(20) |
Oct
(15) |
Nov
(26) |
Dec
|
| 2008 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(32) |
Jun
|
Jul
|
Aug
(3) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <cre...@us...> - 2006-03-28 03:57:52
|
Revision: 1164 Author: creecode Date: 2006-03-27 19:57:46 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1164&view=rev Log Message: ----------- update MoreFilesX to v1.0.2, added a new directory MoreFilesX because the download comes separately from MoreFiles, don't want to commingle old and new code Added Paths: ----------- Frontier/trunk/Common/MoreFilesX/MoreFilesX.c Frontier/trunk/Common/MoreFilesX/MoreFilesX.h Added: Frontier/trunk/Common/MoreFilesX/MoreFilesX.c =================================================================== --- Frontier/trunk/Common/MoreFilesX/MoreFilesX.c (rev 0) +++ Frontier/trunk/Common/MoreFilesX/MoreFilesX.c 2006-03-28 03:57:46 UTC (rev 1164) @@ -0,0 +1 @@ +/* File: MoreFilesX.c Abstract: A collection of useful high-level File Manager routines which use the HFS Plus APIs wherever possible. Version: 1.0.2 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. Copyright \xA9 1992-2005 Apple Computer, Inc., All Rights Reserved For bug reports, consult the following page on the World Wide Web: <http://developer.apple.com/bugreporter/> Change History (most recent first): <8> 17 Feb 2005 <rdar://problem/4012003> Fixed casting and comparison warnings when "-Werror -Wmissing-declarations -Wmissing-prototypes -Wall -W -Wcast-qual -Wpointer-arith -Wno-four-char-constants -Wno-unknown-pragmas" are used with XCode 2.0. <7> 18 Dec 2004 <rdar://problem/3926695> Replaced FSLockRange and FSUnlockRange with FSLockRangeCompat and FSUnlockRangeCompat. <6> 05 Jan 2004 <rdar://problem/3510800> Changed FSMoveRenameObjectUnicode to handle source and destination directories being the same, and to make sure the destination actually is a directory. <5> 22 Sep 2002 <rdar://problem/3016251> Changed FSMoveRenameObjectUnicode to not use the Temporary folder because it isn't available on NFS volumes. <4> 19 Apr 2002 <rdar://problem/2853905> Fixed #if test around header includes. <3> 19 Apr 2002 <rdar://problem/2850624> Fixed C++ compile errors and Project Builder warnings. <2> 19 Apr 2002 <rdar://problem/2853901> Updated standard disclaimer. <1> 25 Jan 2002 MoreFilesX 1.0 */ #if defined(__MACH__) #include <Carbon/Carbon.h> #include <string.h> #else #include <Carbon.h> #include <string.h> #endif #include "MoreFilesX.h" /* Set BuildingMoreFilesXForMacOS9 to 1 if building for Mac OS 9 */ #ifndef BuildingMoreFilesXForMacOS9 #define BuildingMoreFilesXForMacOS9 0 #endif /* macro for casting away const when you really have to */ #define CONST_CAST(type, const_var) (*(type*)((void *)&(const_var))) /*****************************************************************************/ #pragma mark ----- Local type definitions ----- struct FSIterateContainerGlobals { IterateContainerFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */ FSCatalogInfoBitmap whichInfo; /* fields of the CatalogInfo to get */ FSCatalogInfo catalogInfo; /* FSCatalogInfo */ FSRef ref; /* FSRef */ FSSpec spec; /* FSSpec */ FSSpec *specPtr; /* pointer to spec field, or NULL */ HFSUniStr255 name; /* HFSUniStr255 */ HFSUniStr255 *namePtr; /* pointer to name field, or NULL */ void *yourDataPtr; /* a pointer to caller supplied data the filter may need to access */ ItemCount maxLevels; /* maximum levels to iterate through */ ItemCount currentLevel; /* the current level FSIterateContainerLevel is on */ Boolean quitFlag; /* set to true if filter wants to kill interation */ Boolean containerChanged; /* temporary - set to true if the current container changed during iteration */ OSErr result; /* result */ ItemCount actualObjects; /* number of objects returned */ }; typedef struct FSIterateContainerGlobals FSIterateContainerGlobals; struct FSDeleteContainerGlobals { OSErr result; /* result */ ItemCount actualObjects; /* number of objects returned */ FSCatalogInfo catalogInfo; /* FSCatalogInfo */ }; typedef struct FSDeleteContainerGlobals FSDeleteContainerGlobals; /*****************************************************************************/ #pragma mark ----- Local prototypes ----- static void FSDeleteContainerLevel( const FSRef *container, FSDeleteContainerGlobals *theGlobals); static void FSIterateContainerLevel( FSIterateContainerGlobals *theGlobals); static OSErr GenerateUniqueHFSUniStr( long *startSeed, const FSRef *dir1, const FSRef *dir2, HFSUniStr255 *uniqueName); /*****************************************************************************/ #pragma mark ----- File Access Routines ----- /*****************************************************************************/ OSErr FSCopyFork( SInt16 srcRefNum, SInt16 dstRefNum, void *copyBufferPtr, ByteCount copyBufferSize) { OSErr srcResult; OSErr dstResult; OSErr result; SInt64 forkSize; ByteCount readActualCount; /* check input parameters */ require_action((NULL != copyBufferPtr) && (0 != copyBufferSize), BadParameter, result = paramErr); /* get source fork size */ result = FSGetForkSize(srcRefNum, &forkSize); require_noerr(result, SourceFSGetForkSizeFailed); /* allocate disk space for destination fork */ result = FSSetForkSize(dstRefNum, fsFromStart, forkSize); require_noerr(result, DestinationFSSetForkSizeFailed); /* reset source fork's position to 0 */ result = FSSetForkPosition(srcRefNum, fsFromStart, 0); require_noerr(result, SourceFSSetForkPositionFailed); /* reset destination fork's position to 0 */ result = FSSetForkPosition(dstRefNum, fsFromStart, 0); require_noerr(result, DestinationFSSetForkPositionFailed); /* If copyBufferSize is greater than 4K bytes, make it a multiple of 4k bytes */ /* This will make writes on local volumes faster */ if ( (copyBufferSize >= 0x00001000) && ((copyBufferSize & 0x00000fff) != 0) ) { copyBufferSize &= ~(0x00001000 - 1); } /* copy source to destination */ srcResult = dstResult = noErr; while ( (noErr == srcResult) && (noErr == dstResult) ) { srcResult = FSReadFork(srcRefNum, fsAtMark + noCacheMask, 0, copyBufferSize, copyBufferPtr, &readActualCount); dstResult = FSWriteFork(dstRefNum, fsAtMark + noCacheMask, 0, readActualCount, copyBufferPtr, NULL); } /* make sure there were no errors at the destination */ require_noerr_action(dstResult, DestinationFSWriteForkFailed, result = dstResult); /* make sure the error at the source was eofErr */ require_action(eofErr == srcResult, SourceResultNotEofErr, result = srcResult); /* everything went as expected */ result = noErr; SourceResultNotEofErr: DestinationFSWriteForkFailed: DestinationFSSetForkPositionFailed: SourceFSSetForkPositionFailed: DestinationFSSetForkSizeFailed: SourceFSGetForkSizeFailed: BadParameter: return ( result ); } /*****************************************************************************/ #pragma mark ----- Volume Access Routines ----- /*****************************************************************************/ OSErr FSGetVolParms( FSVolumeRefNum volRefNum, UInt32 bufferSize, GetVolParmsInfoBuffer *volParmsInfo, UInt32 *actualInfoSize) { OSErr result; HParamBlockRec pb; /* check parameters */ require_action((NULL != volParmsInfo) && (NULL != actualInfoSize), BadParameter, result = paramErr); pb.ioParam.ioNamePtr = NULL; pb.ioParam.ioVRefNum = volRefNum; pb.ioParam.ioBuffer = (Ptr)volParmsInfo; pb.ioParam.ioReqCount = (SInt32)bufferSize; result = PBHGetVolParmsSync(&pb); require_noerr(result, PBHGetVolParmsSync); /* return number of bytes the file system returned in volParmsInfo buffer */ *actualInfoSize = (UInt32)pb.ioParam.ioActCount; PBHGetVolParmsSync: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSGetVRefNum( const FSRef *ref, FSVolumeRefNum *vRefNum) { OSErr result; FSCatalogInfo catalogInfo; /* check parameters */ require_action(NULL != vRefNum, BadParameter, result = paramErr); /* get the volume refNum from the FSRef */ result = FSGetCatalogInfo(ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); /* return volume refNum from catalogInfo */ *vRefNum = catalogInfo.volume; FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSGetVInfo( FSVolumeRefNum volume, HFSUniStr255 *volumeName, /* can be NULL */ UInt64 *freeBytes, /* can be NULL */ UInt64 *totalBytes) /* can be NULL */ { OSErr result; FSVolumeInfo info; /* ask for the volume's sizes only if needed */ result = FSGetVolumeInfo(volume, 0, NULL, (((NULL != freeBytes) || (NULL != totalBytes)) ? kFSVolInfoSizes : kFSVolInfoNone), &info, volumeName, NULL); require_noerr(result, FSGetVolumeInfo); if ( NULL != freeBytes ) { *freeBytes = info.freeBytes; } if ( NULL != totalBytes ) { *totalBytes = info.totalBytes; } FSGetVolumeInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetVolFileSystemID( FSVolumeRefNum volume, UInt16 *fileSystemID, /* can be NULL */ UInt16 *signature) /* can be NULL */ { OSErr result; FSVolumeInfo info; result = FSGetVolumeInfo(volume, 0, NULL, kFSVolInfoFSInfo, &info, NULL, NULL); require_noerr(result, FSGetVolumeInfo); if ( NULL != fileSystemID ) { *fileSystemID = info.filesystemID; } if ( NULL != signature ) { *signature = info.signature; } FSGetVolumeInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetMountedVolumes( FSRef ***volumeRefsHandle, /* pointer to handle of FSRefs */ ItemCount *numVolumes) { OSErr result; OSErr memResult; ItemCount volumeIndex; FSRef ref; /* check parameters */ require_action((NULL != volumeRefsHandle) && (NULL != numVolumes), BadParameter, result = paramErr); /* No volumes yet */ *numVolumes = 0; /* Allocate a handle for the results */ *volumeRefsHandle = (FSRef **)NewHandle(0); require_action(NULL != *volumeRefsHandle, NewHandle, result = memFullErr); /* Call FSGetVolumeInfo in loop to get all volumes starting with the first */ volumeIndex = 1; do { result = FSGetVolumeInfo(0, volumeIndex, NULL, kFSVolInfoNone, NULL, NULL, &ref); if ( noErr == result ) { /* concatenate the FSRef to the end of the handle */ PtrAndHand(&ref, (Handle)*volumeRefsHandle, sizeof(FSRef)); memResult = MemError(); require_noerr_action(memResult, MemoryAllocationFailed, result = memResult); ++(*numVolumes); /* increment the volume count */ ++volumeIndex; /* and the volumeIndex to get the next volume*/ } } while ( noErr == result ); /* nsvErr is OK -- it just means there are no more volumes */ require(nsvErr == result, FSGetVolumeInfo); return ( noErr ); /**********************/ MemoryAllocationFailed: FSGetVolumeInfo: /* dispose of handle if already allocated and clear the outputs */ if ( NULL != *volumeRefsHandle ) { DisposeHandle((Handle)*volumeRefsHandle); *volumeRefsHandle = NULL; } *numVolumes = 0; NewHandle: BadParameter: return ( result ); } /*****************************************************************************/ #pragma mark ----- FSRef/FSpec/Path/Name Conversion Routines ----- /*****************************************************************************/ OSErr FSRefMakeFSSpec( const FSRef *ref, FSSpec *spec) { OSErr result; /* check parameters */ require_action(NULL != spec, BadParameter, result = paramErr); result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, spec, NULL); require_noerr(result, FSGetCatalogInfo); FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSMakeFSRef( FSVolumeRefNum volRefNum, SInt32 dirID, ConstStr255Param name, FSRef *ref) { OSErr result; FSRefParam pb; /* check parameters */ require_action(NULL != ref, BadParameter, result = paramErr); pb.ioVRefNum = volRefNum; pb.ioDirID = dirID; pb.ioNamePtr = CONST_CAST(StringPtr, name); pb.newRef = ref; result = PBMakeFSRefSync(&pb); require_noerr(result, PBMakeFSRefSync); PBMakeFSRefSync: BadParameter: return ( result ); } /*****************************************************************************/ OSStatus FSMakePath( SInt16 volRefNum, SInt32 dirID, ConstStr255Param name, UInt8 *path, UInt32 maxPathSize) { OSStatus result; FSRef ref; /* check parameters */ require_action(NULL != path, BadParameter, result = paramErr); /* convert the inputs to an FSRef */ result = FSMakeFSRef(volRefNum, dirID, name, &ref); require_noerr(result, FSMakeFSRef); /* and then convert the FSRef to a path */ result = FSRefMakePath(&ref, path, maxPathSize); require_noerr(result, FSRefMakePath); FSRefMakePath: FSMakeFSRef: BadParameter: return ( result ); } /*****************************************************************************/ OSStatus FSPathMakeFSSpec( const UInt8 *path, FSSpec *spec, Boolean *isDirectory) /* can be NULL */ { OSStatus result; FSRef ref; /* check parameters */ require_action(NULL != spec, BadParameter, result = paramErr); /* convert the POSIX path to an FSRef */ result = FSPathMakeRef(path, &ref, isDirectory); require_noerr(result, FSPathMakeRef); /* and then convert the FSRef to an FSSpec */ result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL); require_noerr(result, FSGetCatalogInfo); FSGetCatalogInfo: FSPathMakeRef: BadParameter: return ( result ); } /*****************************************************************************/ OSErr UnicodeNameGetHFSName( UniCharCount nameLength, const UniChar *name, TextEncoding textEncodingHint, Boolean isVolumeName, Str31 hfsName) { OSStatus result; ByteCount unicodeByteLength; ByteCount unicodeBytesConverted; ByteCount actualPascalBytes; UnicodeMapping uMapping; UnicodeToTextInfo utInfo; /* check parameters */ require_action(NULL != hfsName, BadParameter, result = paramErr); /* make sure output is valid in case we get errors or there's nothing to convert */ hfsName[0] = 0; unicodeByteLength = nameLength * sizeof(UniChar); if ( 0 == unicodeByteLength ) { /* do nothing */ result = noErr; } else { /* if textEncodingHint is kTextEncodingUnknown, get a "default" textEncodingHint */ if ( kTextEncodingUnknown == textEncodingHint ) { ScriptCode script; RegionCode region; script = (ScriptCode)GetScriptManagerVariable(smSysScript); region = (RegionCode)GetScriptManagerVariable(smRegionCode); result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, region, NULL, &textEncodingHint ); if ( paramErr == result ) { /* ok, ignore the region and try again */ result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, kTextRegionDontCare, NULL, &textEncodingHint ); } if ( noErr != result ) { /* ok... try something */ textEncodingHint = kTextEncodingMacRoman; } } uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeV2_0, kUnicodeCanonicalDecompVariant, kUnicode16BitFormat); uMapping.otherEncoding = GetTextEncodingBase(textEncodingHint); uMapping.mappingVersion = kUnicodeUseHFSPlusMapping; result = CreateUnicodeToTextInfo(&uMapping, &utInfo); require_noerr(result, CreateUnicodeToTextInfo); result = ConvertFromUnicodeToText(utInfo, unicodeByteLength, name, kUnicodeLooseMappingsMask, 0, NULL, 0, NULL, /* offsetCounts & offsetArrays */ isVolumeName ? kHFSMaxVolumeNameChars : kHFSMaxFileNameChars, &unicodeBytesConverted, &actualPascalBytes, &hfsName[1]); require_noerr(result, ConvertFromUnicodeToText); hfsName[0] = (unsigned char)actualPascalBytes; /* fill in length byte */ ConvertFromUnicodeToText: /* verify the result in debug builds -- there's really not anything you can do if it fails */ verify_noerr(DisposeUnicodeToTextInfo(&utInfo)); } CreateUnicodeToTextInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr HFSNameGetUnicodeName( ConstStr31Param hfsName, TextEncoding textEncodingHint, HFSUniStr255 *unicodeName) { ByteCount unicodeByteLength; OSStatus result; UnicodeMapping uMapping; TextToUnicodeInfo tuInfo; ByteCount pascalCharsRead; /* check parameters */ require_action(NULL != unicodeName, BadParameter, result = paramErr); /* make sure output is valid in case we get errors or there's nothing to convert */ unicodeName->length = 0; if ( 0 == StrLength(CONST_CAST(StringPtr, hfsName)) ) { result = noErr; } else { /* if textEncodingHint is kTextEncodingUnknown, get a "default" textEncodingHint */ if ( kTextEncodingUnknown == textEncodingHint ) { ScriptCode script; RegionCode region; script = GetScriptManagerVariable(smSysScript); region = GetScriptManagerVariable(smRegionCode); result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, region, NULL, &textEncodingHint); if ( paramErr == result ) { /* ok, ignore the region and try again */ result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, kTextRegionDontCare, NULL, &textEncodingHint); } if ( noErr != result ) { /* ok... try something */ textEncodingHint = kTextEncodingMacRoman; } } uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeV2_0, kUnicodeCanonicalDecompVariant, kUnicode16BitFormat); uMapping.otherEncoding = GetTextEncodingBase(textEncodingHint); uMapping.mappingVersion = kUnicodeUseHFSPlusMapping; result = CreateTextToUnicodeInfo(&uMapping, &tuInfo); require_noerr(result, CreateTextToUnicodeInfo); result = ConvertFromTextToUnicode(tuInfo, hfsName[0], &hfsName[1], 0, /* no control flag bits */ 0, NULL, 0, NULL, /* offsetCounts & offsetArrays */ sizeof(unicodeName->unicode), /* output buffer size in bytes */ &pascalCharsRead, &unicodeByteLength, unicodeName->unicode); require_noerr(result, ConvertFromTextToUnicode); /* convert from byte count to char count */ unicodeName->length = unicodeByteLength / sizeof(UniChar); ConvertFromTextToUnicode: /* verify the result in debug builds -- there's really not anything you can do if it fails */ verify_noerr(DisposeTextToUnicodeInfo(&tuInfo)); } CreateTextToUnicodeInfo: BadParameter: return ( result ); } /*****************************************************************************/ #pragma mark ----- File/Directory Manipulation Routines ----- /*****************************************************************************/ Boolean FSRefValid(const FSRef *ref) { return ( noErr == FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, NULL, NULL) ); } /*****************************************************************************/ OSErr FSGetParentRef( const FSRef *ref, FSRef *parentRef) { OSErr result; FSCatalogInfo catalogInfo; /* check parameters */ require_action(NULL != parentRef, BadParameter, result = paramErr); result = FSGetCatalogInfo(ref, kFSCatInfoNodeID, &catalogInfo, NULL, NULL, parentRef); require_noerr(result, FSGetCatalogInfo); /* * Note: FSRefs always point to real file system objects. So, there cannot * be a FSRef to the parent of volume root directories. Early versions of * Mac OS X do not handle this case correctly and incorrectly return a * FSRef for the parent of volume root directories instead of returning an * invalid FSRef (a cleared FSRef is invalid). The next three lines of code * ensure that you won't run into this bug. WW9D! */ if ( fsRtDirID == catalogInfo.nodeID ) { /* clear parentRef and return noErr which is the proper behavior */ memset(parentRef, 0, sizeof(FSRef)); } FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSGetFileDirName( const FSRef *ref, HFSUniStr255 *outName) { OSErr result; /* check parameters */ require_action(NULL != outName, BadParameter, result = paramErr); result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, outName, NULL, NULL); require_noerr(result, FSGetCatalogInfo); FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSGetNodeID( const FSRef *ref, long *nodeID, /* can be NULL */ Boolean *isDirectory) /* can be NULL */ { OSErr result; FSCatalogInfo catalogInfo; FSCatalogInfoBitmap whichInfo; /* determine what catalog information to get */ whichInfo = kFSCatInfoNone; /* start with none */ if ( NULL != nodeID ) { whichInfo |= kFSCatInfoNodeID; } if ( NULL != isDirectory ) { whichInfo |= kFSCatInfoNodeFlags; } result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); if ( NULL != nodeID ) { *nodeID = catalogInfo.nodeID; } if ( NULL != isDirectory ) { *isDirectory = (0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags)); } FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetUserPrivilegesPermissions( const FSRef *ref, UInt8 *userPrivileges, /* can be NULL */ UInt32 permissions[4]) /* can be NULL */ { OSErr result; FSCatalogInfo catalogInfo; FSCatalogInfoBitmap whichInfo; /* determine what catalog information to get */ whichInfo = kFSCatInfoNone; /* start with none */ if ( NULL != userPrivileges ) { whichInfo |= kFSCatInfoUserPrivs; } if ( NULL != permissions ) { whichInfo |= kFSCatInfoPermissions; } result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); if ( NULL != userPrivileges ) { *userPrivileges = catalogInfo.userPrivileges; } if ( NULL != permissions ) { BlockMoveData(&catalogInfo.permissions, permissions, sizeof(UInt32) * 4); } FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSCheckLock( const FSRef *ref) { OSErr result; FSCatalogInfo catalogInfo; FSVolumeInfo volumeInfo; /* get nodeFlags and vRefNum for container */ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoVolume, &catalogInfo, NULL, NULL,NULL); require_noerr(result, FSGetCatalogInfo); /* is file locked? */ if ( 0 != (catalogInfo.nodeFlags & kFSNodeLockedMask) ) { result = fLckdErr; /* file is locked */ } else { /* file isn't locked, but is volume locked? */ /* get volume flags */ result = FSGetVolumeInfo(catalogInfo.volume, 0, NULL, kFSVolInfoFlags, &volumeInfo, NULL, NULL); require_noerr(result, FSGetVolumeInfo); if ( 0 != (volumeInfo.flags & kFSVolFlagHardwareLockedMask) ) { result = wPrErr; /* volume locked by hardware */ } else if ( 0 != (volumeInfo.flags & kFSVolFlagSoftwareLockedMask) ) { result = vLckdErr; /* volume locked by software */ } } FSGetVolumeInfo: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetForkSizes( const FSRef *ref, UInt64 *dataLogicalSize, /* can be NULL */ UInt64 *rsrcLogicalSize) /* can be NULL */ { OSErr result; FSCatalogInfoBitmap whichInfo; FSCatalogInfo catalogInfo; whichInfo = kFSCatInfoNodeFlags; if ( NULL != dataLogicalSize ) { /* get data fork size */ whichInfo |= kFSCatInfoDataSizes; } if ( NULL != rsrcLogicalSize ) { /* get resource fork size */ whichInfo |= kFSCatInfoRsrcSizes; } /* get nodeFlags and catalog info */ result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL,NULL); require_noerr(result, FSGetCatalogInfo); /* make sure FSRef was to a file */ require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), FSRefNotFile, result = notAFileErr); if ( NULL != dataLogicalSize ) { /* return data fork size */ *dataLogicalSize = catalogInfo.dataLogicalSize; } if ( NULL != rsrcLogicalSize ) { /* return resource fork size */ *rsrcLogicalSize = catalogInfo.rsrcLogicalSize; } FSRefNotFile: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetTotalForkSizes( const FSRef *ref, UInt64 *totalLogicalSize, /* can be NULL */ UInt64 *totalPhysicalSize, /* can be NULL */ ItemCount *forkCount) /* can be NULL */ { OSErr result; CatPositionRec forkIterator; SInt64 forkSize; SInt64 *forkSizePtr; UInt64 forkPhysicalSize; UInt64 *forkPhysicalSizePtr; /* Determine if forkSize needed */ if ( NULL != totalLogicalSize) { *totalLogicalSize = 0; forkSizePtr = &forkSize; } else { forkSizePtr = NULL; } /* Determine if forkPhysicalSize is needed */ if ( NULL != totalPhysicalSize ) { *totalPhysicalSize = 0; forkPhysicalSizePtr = &forkPhysicalSize; } else { forkPhysicalSizePtr = NULL; } /* zero fork count if returning it */ if ( NULL != forkCount ) { *forkCount = 0; } /* Iterate through the forks to get the sizes */ forkIterator.initialize = 0; do { result = FSIterateForks(ref, &forkIterator, NULL, forkSizePtr, forkPhysicalSizePtr); if ( noErr == result ) { if ( NULL != totalLogicalSize ) { *totalLogicalSize += forkSize; } if ( NULL != totalPhysicalSize ) { *totalPhysicalSize += forkPhysicalSize; } if ( NULL != forkCount ) { ++*forkCount; } } } while ( noErr == result ); /* any error result other than errFSNoMoreItems is serious */ require(errFSNoMoreItems == result, FSIterateForks); /* Normal exit */ result = noErr; FSIterateForks: return ( result ); } /*****************************************************************************/ OSErr FSBumpDate( const FSRef *ref) { OSStatus result; FSCatalogInfo catalogInfo; UTCDateTime oldDateTime; #if !BuildingMoreFilesXForMacOS9 FSRef parentRef; Boolean notifyParent; #endif #if !BuildingMoreFilesXForMacOS9 /* Get the node flags, the content modification date and time, and the parent ref */ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoContentMod, &catalogInfo, NULL, NULL, &parentRef); require_noerr(result, FSGetCatalogInfo); /* Notify the parent if this is a file */ notifyParent = (0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask)); #else /* Get the content modification date and time */ result = FSGetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); #endif oldDateTime = catalogInfo.contentModDate; /* Get the current date and time */ result = GetUTCDateTime(&catalogInfo.contentModDate, kUTCDefaultOptions); require_noerr(result, GetUTCDateTime); /* if the old date and time is the the same as the current, bump the seconds by one */ if ( (catalogInfo.contentModDate.fraction == oldDateTime.fraction) && (catalogInfo.contentModDate.lowSeconds == oldDateTime.lowSeconds) && (catalogInfo.contentModDate.highSeconds == oldDateTime.highSeconds) ) { ++catalogInfo.contentModDate.lowSeconds; if ( 0 == catalogInfo.contentModDate.lowSeconds ) { ++catalogInfo.contentModDate.highSeconds; } } /* Bump the content modification date and time */ result = FSSetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo); require_noerr(result, FSSetCatalogInfo); #if !BuildingMoreFilesXForMacOS9 /* * The problem with FNNotify is that it is not available under Mac OS 9 * and there's no way to test for that except for looking for the symbol * or something. So, I'll just conditionalize this for those who care * to send a notification. */ /* Send a notification for the parent of the file, or for the directory */ result = FNNotify(notifyParent ? &parentRef : ref, kFNDirectoryModifiedMessage, kNilOptions); require_noerr(result, FNNotify); #endif /* ignore errors from FSSetCatalogInfo (volume might be write protected) and FNNotify */ FNNotify: FSSetCatalogInfo: return ( noErr ); /**********************/ GetUTCDateTime: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetFinderInfo( const FSRef *ref, FinderInfo *info, /* can be NULL */ ExtendedFinderInfo *extendedInfo, /* can be NULL */ Boolean *isDirectory) /* can be NULL */ { OSErr result; FSCatalogInfo catalogInfo; FSCatalogInfoBitmap whichInfo; /* determine what catalog information is really needed */ whichInfo = kFSCatInfoNone; if ( NULL != info ) { /* get FinderInfo */ whichInfo |= kFSCatInfoFinderInfo; } if ( NULL != extendedInfo ) { /* get ExtendedFinderInfo */ whichInfo |= kFSCatInfoFinderXInfo; } if ( NULL != isDirectory ) { whichInfo |= kFSCatInfoNodeFlags; } result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); /* return FinderInfo if requested */ if ( NULL != info ) { BlockMoveData(catalogInfo.finderInfo, info, sizeof(FinderInfo)); } /* return ExtendedFinderInfo if requested */ if ( NULL != extendedInfo) { BlockMoveData(catalogInfo.extFinderInfo, extendedInfo, sizeof(ExtendedFinderInfo)); } /* set isDirectory Boolean if requested */ if ( NULL != isDirectory) { *isDirectory = (0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags)); } FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSSetFinderInfo( const FSRef *ref, const FinderInfo *info, const ExtendedFinderInfo *extendedInfo) { OSErr result; FSCatalogInfo catalogInfo; FSCatalogInfoBitmap whichInfo; /* determine what catalog information will be set */ whichInfo = kFSCatInfoNone; /* start with none */ if ( NULL != info ) { /* set FinderInfo */ whichInfo |= kFSCatInfoFinderInfo; BlockMoveData(info, catalogInfo.finderInfo, sizeof(FinderInfo)); } if ( NULL != extendedInfo ) { /* set ExtendedFinderInfo */ whichInfo |= kFSCatInfoFinderXInfo; BlockMoveData(extendedInfo, catalogInfo.extFinderInfo, sizeof(ExtendedFinderInfo)); } result = FSSetCatalogInfo(ref, whichInfo, &catalogInfo); require_noerr(result, FSGetCatalogInfo); FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSChangeCreatorType( const FSRef *ref, OSType fileCreator, OSType fileType) { OSErr result; FSCatalogInfo catalogInfo; FSRef parentRef; /* get nodeFlags, finder info, and parent FSRef */ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoFinderInfo, &catalogInfo , NULL, NULL, &parentRef); require_noerr(result, FSGetCatalogInfo); /* make sure FSRef was to a file */ require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), FSRefNotFile, result = notAFileErr); /* If fileType not 0x00000000, change fileType */ if ( fileType != (OSType)0x00000000 ) { ((FileInfo *)&catalogInfo.finderInfo)->fileType = fileType; } /* If creator not 0x00000000, change creator */ if ( fileCreator != (OSType)0x00000000 ) { ((FileInfo *)&catalogInfo.finderInfo)->fileCreator = fileCreator; } /* now, save the new information back to disk */ result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo); require_noerr(result, FSSetCatalogInfo); /* and attempt to bump the parent directory's mod date to wake up */ /* the Finder to the change we just made (ignore errors from this) */ verify_noerr(FSBumpDate(&parentRef)); FSSetCatalogInfo: FSRefNotFile: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSChangeFinderFlags( const FSRef *ref, Boolean setBits, UInt16 flagBits) { OSErr result; FSCatalogInfo catalogInfo; FSRef parentRef; /* get the current finderInfo */ result = FSGetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, &parentRef); require_noerr(result, FSGetCatalogInfo); /* set or clear the appropriate bits in the finderInfo.finderFlags */ if ( setBits ) { /* OR in the bits */ ((FileInfo *)&catalogInfo.finderInfo)->finderFlags |= flagBits; } else { /* AND out the bits */ ((FileInfo *)&catalogInfo.finderInfo)->finderFlags &= ~flagBits; } /* save the modified finderInfo */ result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo); require_noerr(result, FSSetCatalogInfo); /* and attempt to bump the parent directory's mod date to wake up the Finder */ /* to the change we just made (ignore errors from this) */ verify_noerr(FSBumpDate(&parentRef)); FSSetCatalogInfo: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSSetInvisible( const FSRef *ref) { return ( FSChangeFinderFlags(ref, true, kIsInvisible) ); } OSErr FSClearInvisible( const FSRef *ref) { return ( FSChangeFinderFlags(ref, false, kIsInvisible) ); } /*****************************************************************************/ OSErr FSSetNameLocked( const FSRef *ref) { return ( FSChangeFinderFlags(ref, true, kNameLocked) ); } OSErr FSClearNameLocked( const FSRef *ref) { return ( FSChangeFinderFlags(ref, false, kNameLocked) ); } /*****************************************************************************/ OSErr FSSetIsStationery( const FSRef *ref) { return ( FSChangeFinderFlags(ref, true, kIsStationery) ); } OSErr FSClearIsStationery( const FSRef *ref) { return ( FSChangeFinderFlags(ref, false, kIsStationery) ); } /*****************************************************************************/ OSErr FSSetHasCustomIcon( const FSRef *ref) { return ( FSChangeFinderFlags(ref, true, kHasCustomIcon) ); } OSErr FSClearHasCustomIcon( const FSRef *ref) { return ( FSChangeFinderFlags(ref, false, kHasCustomIcon) ); } /*****************************************************************************/ OSErr FSClearHasBeenInited( const FSRef *ref) { return ( FSChangeFinderFlags(ref, false, kHasBeenInited) ); } /*****************************************************************************/ OSErr FSCopyFileMgrAttributes( const FSRef *sourceRef, const FSRef *destinationRef, Boolean copyLockBit) { OSErr result; FSCatalogInfo catalogInfo; /* get the source information */ result = FSGetCatalogInfo(sourceRef, kFSCatInfoSettableInfo, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); /* don't copy the hasBeenInited bit; clear it */ ((FileInfo *)&catalogInfo.finderInfo)->finderFlags &= ~kHasBeenInited; /* should the locked bit be copied? */ if ( !copyLockBit ) { /* no, make sure the locked bit is clear */ catalogInfo.nodeFlags &= ~kFSNodeLockedMask; } /* set the destination information */ result = FSSetCatalogInfo(destinationRef, kFSCatInfoSettableInfo, &catalogInfo); require_noerr(result, FSSetCatalogInfo); FSSetCatalogInfo: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSMoveRenameObjectUnicode( const FSRef *ref, const FSRef *destDirectory, UniCharCount nameLength, const UniChar *name, /* can be NULL (no rename during move) */ TextEncoding textEncodingHint, FSRef *newRef) /* if function fails along the way, newRef is final location of file */ { OSErr result; FSVolumeRefNum destVRefNum; UInt32 destDirID; FSCatalogInfo catalogInfo; FSRef originalDirectory; TextEncoding originalTextEncodingHint; HFSUniStr255 originalName; HFSUniStr255 uniqueName; /* unique name given to object while moving it to destination */ long theSeed; /* the seed for generating unique names */ /* check parameters */ require_action(NULL != newRef, BadParameter, result = paramErr); /* newRef = input to start with */ BlockMoveData(ref, newRef, sizeof(FSRef)); /* get destDirectory's NodeFlags, vRefNum and dirID */ result = FSGetCatalogInfo(destDirectory, kFSCatInfoNodeFlags | kFSCatInfoVolume | kFSCatInfoNodeID, &catalogInfo, NULL, NULL, NULL); require_noerr(result, DestinationBad); /* make sure destination is a directory */ require_action(0 != (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), DestinationBad, result = dirNFErr); /* save destVRefNum and dirID */ destVRefNum = catalogInfo.volume; destDirID = catalogInfo.nodeID; /* get ref's vRefNum, parent DirID, TextEncoding, name and parent directory */ result = FSGetCatalogInfo(ref, kFSCatInfoTextEncoding | kFSCatInfoVolume | kFSCatInfoParentDirID, &catalogInfo, &originalName, NULL, &originalDirectory); require_noerr(result, SourceBad); /* save TextEncoding */ originalTextEncodingHint = catalogInfo.textEncodingHint; /* make sure ref and destDirectory are on same volume */ require_action(destVRefNum == catalogInfo.volume, NotSameVolume, result = diffVolErr); /* Skip a few steps if we're not renaming */ if ( NULL != name ) { /* if we are not moving, only renaming, skip some more steps */ if ( destDirID == catalogInfo.parentDirID ) { /* Rename the object to new name */ result = FSRenameUnicode(newRef, nameLength, name, textEncodingHint, newRef); require_noerr(result, FSRenameUnicodeSimple); } else { /* generate a name that is unique in both directories */ theSeed = 0x4a696d4c; /* a fine unlikely filename */ result = GenerateUniqueHFSUniStr(&theSeed, &originalDirectory, destDirectory, &uniqueName); require_noerr(result, GenerateUniqueHFSUniStrFailed); /* Rename the object to uniqueName */ result = FSRenameUnicode(newRef, uniqueName.length, uniqueName.unicode, kTextEncodingUnknown, newRef); require_noerr(result, FSRenameUnicodeBeforeMoveFailed); /* Move object to its new home */ result = FSMoveObject(newRef, destDirectory, newRef); require_noerr(result, FSMoveObjectAfterRenameFailed); /* Rename the object to new name */ result = FSRenameUnicode(newRef, nameLength, name, textEncodingHint, newRef); require_noerr(result, FSRenameUnicodeAfterMoveFailed); } } else { /* if we are not moving, skip the move call (which will fail under 9.0 through 10.1.x) and return noErr */ if ( destDirID != catalogInfo.parentDirID ) { /* Move object to its new home */ result = FSMoveObject(newRef, destDirectory, newRef); require_noerr(result, FSMoveObjectNoRenameFailed); } } return ( result ); /*************/ /* * failure handling code when renaming */ FSRenameUnicodeAfterMoveFailed: /* Error handling: move object back to original location - ignore errors */ verify_noerr(FSMoveObject(newRef, &originalDirectory, newRef)); FSMoveObjectAfterRenameFailed: /* Error handling: rename object back to original name - ignore errors */ verify_noerr(FSRenameUnicode(newRef, originalName.length, originalName.unicode, originalTextEncodingHint, newRef)); FSRenameUnicodeBeforeMoveFailed: GenerateUniqueHFSUniStrFailed: FSRenameUnicodeSimple: /* * failure handling code for renaming or not */ FSMoveObjectNoRenameFailed: NotSameVolume: SourceBad: DestinationBad: BadParameter: return ( result ); } /*****************************************************************************/ /* The FSDeleteContainerLevel function deletes the contents of a container directory. All files and subdirectories in the specified container are deleted. If a locked file or directory is encountered, it is unlocked and then deleted. If any unexpected errors are encountered, FSDeleteContainerLevel quits and returns to the caller. container --> FSRef to a directory. theGlobals --> A pointer to a FSDeleteContainerGlobals struct which contains the variables that do not need to be allocated each time FSDeleteContainerLevel recurses. That lets FSDeleteContainerLevel use less stack space per recursion level. */ static void FSDeleteContainerLevel( const FSRef *container, FSDeleteContainerGlobals *theGlobals) { /* level locals */ FSIterator iterator; FSRef itemToDelete; UInt16 nodeFlags; /* Open FSIterator for flat access and give delete optimization hint */ theGlobals->result = FSOpenIterator(container, kFSIterateFlat + kFSIterateDelete, &iterator); require_noerr(theGlobals->result, FSOpenIterator); /* delete the contents of the directory */ do { /* get 1 item to delete */ theGlobals->result = FSGetCatalogInfoBulk(iterator, 1, &theGlobals->actualObjects, NULL, kFSCatInfoNodeFlags, &theGlobals->catalogInfo, &itemToDelete, NULL, NULL); if ( (noErr == theGlobals->result) && (1 == theGlobals->actualObjects) ) { /* save node flags in local in case we have to recurse */ nodeFlags = theGlobals->catalogInfo.nodeFlags; /* is it a file or directory? */ if ( 0 != (nodeFlags & kFSNodeIsDirectoryMask) ) { /* it's a directory -- delete its contents before attempting to delete it */ FSDeleteContainerLevel(&itemToDelete, theGlobals); } /* are we still OK to delete? */ if ( noErr == theGlobals->result ) { /* is item locked? */ if ( 0 != (nodeFlags & kFSNodeLockedMask) ) { /* then attempt to unlock it (ignore result since FSDeleteObject will set it correctly) */ theGlobals->catalogInfo.nodeFlags = nodeFlags & ~kFSNodeLockedMask; (void) FSSetCatalogInfo(&itemToDelete, kFSCatInfoNodeFlags, &theGlobals->catalogInfo); } /* delete the item */ theGlobals->result = FSDeleteObject(&itemToDelete); } } } while ( noErr == theGlobals->result ); /* we found the end of the items normally, so return noErr */ if ( errFSNoMoreItems == theGlobals->result ) { theGlobals->result = noErr; } /* close the FSIterator (closing an open iterator should never fail) */ verify_noerr(FSCloseIterator(iterator)); FSOpenIterator: return; } /*****************************************************************************/ OSErr FSDeleteContainerContents( const FSRef *container) { FSDeleteContainerGlobals theGlobals; /* delete container's contents */ FSDeleteContainerLevel(container, &theGlobals); return ( theGlobals.result ); } /*****************************************************************************/ OSErr FSDeleteContainer( const FSRef *container) { OSErr result; FSCatalogInfo catalogInfo; /* get nodeFlags for container */ result = FSGetCatalogInfo(container, kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL,NULL); require_noerr(result, FSGetCatalogInfo); /* make sure container is a directory */ require_action(0 != (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), ContainerNotDirectory, result = dirNFErr); /* delete container's contents */ result = FSDeleteContainerContents(container); require_noerr(result, FSDeleteContainerContents); /* is container locked? */ if ( 0 != (catalogInfo.nodeFlags & kFSNodeLockedMask) ) { /* then attempt to unlock container (ignore result since FSDeleteObject will set it correctly) */ catalogInfo.nodeFlags &= ~kFSNodeLockedMask; (void) FSSetCatalogInfo(container, kFSCatInfoNodeFlags, &catalogInfo); } /* delete the container */ result = FSDeleteObject(container); FSDeleteContainerContents: ContainerNotDirectory: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ /* The FSIterateContainerLevel function iterates the contents of a container directory and calls a IterateContainerFilterProc function once for each file and directory found. theGlobals --> A pointer to a FSIterateContainerGlobals struct which contains the variables needed globally by all recusion levels of FSIterateContainerLevel. That makes FSIterateContainer thread safe since each call to it uses its own global world. It also contains the variables that do not need to be allocated each time FSIterateContainerLevel recurses. That lets FSIterateContainerLevel use less stack space per recursion level. */ static void FSIterateContainerLevel( FSIterateContainerGlobals *theGlobals) { FSIterator iterator; /* If maxLevels is zero, we aren't checking levels */ /* If currentLevel < maxLevels, look at this level */ if ( (theGlobals->maxLevels == 0) || (theGlobals->currentLevel < theGlobals->maxLevels) ) { /* Open FSIterator for flat access to theGlobals->ref */ theGlobals->result = FSOpenIterator(&theGlobals->ref, kFSIterateFlat, &iterator); require_noerr(theGlobals->result, FSOpenIterator); ++theGlobals->currentLevel; /* Go to next level */ /* Call FSGetCatalogInfoBulk in loop to get all items in the container */ do { theGlobals->result = FSGetCatalogInfoBulk(iterator, 1, &theGlobals->actualObjects, &theGlobals->containerChanged, theGlobals->whichInfo, &theGlobals->catalogInfo, &theGlobals->ref, theGlobals->specPtr, theGlobals->namePtr); if ( (noErr == theGlobals->result || errFSNoMoreItems == theGlobals->result) && (0 != theGlobals->actualObjects) ) { /* Call the IterateFilterProc */ theGlobals->quitFlag = CallIterateContainerFilterProc(theGlobals->iterateFilter, theGlobals->containerChanged, theGlobals->currentLevel, &theGlobals->catalogInfo, &theGlobals->ref, theGlobals->specPtr, theGlobals->namePtr, theGlobals->yourDataPtr); /* Is it a directory? */ if ( 0 != (theGlobals->catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) ) { /* Keep going? */ if ( !theGlobals->quitFlag ) { /* Dive again if the IterateFilterProc didn't say "quit" */ FSIterateContainerLevel(theGlobals); } } } /* time to fall back a level? */ } while ( (noErr == theGlobals->result) && (!theGlobals->quitFlag) ); /* errFSNoMoreItems is OK - it only means we hit the end of this level */ /* afpAccessDenied is OK, too - it only means we cannot see inside a directory */ if ( (errFSNoMoreItems == theGlobals->result) || (afpAccessDenied == theGlobals->result) ) { theGlobals->result = noErr; } --theGlobals->currentLevel; /* Return to previous level as we leave */ /* Close the FSIterator (closing an open iterator should never fail) */ verify_noerr(FSCloseIterator(iterator)); } FSOpenIterator: return; } /*****************************************************************************/ OSErr FSIterateContainer( const FSRef *container, ItemCount maxLevels, FSCatalogInfoBitmap whichInfo, Boolean wantFSSpec, Boolean wantName, IterateContainerFilterProcPtr iterateFilter, void *yourDataPtr) { OSErr result; FSIterateContainerGlobals theGlobals; /* make sure there is an iterateFilter */ require_action(iterateFilter != NULL, NoIterateFilter, result = paramErr); /* * set up the globals we need to access from the recursive routine */ theGlobals.iterateFilter = iterateFilter; /* we need the node flags no matter what was requested so we can detect files vs. directories */ theGlobals.whichInfo = whichInfo | kFSCatInfoNodeFlags; /* start with input container -- the first OpenIterator will ensure it is a directory */ theGlobals.ref = *container; if ( wantFSSpec ) { theGlobals.specPtr = &theGlobals.spec; } else { theGlobals.specPtr = NULL; } if ( wantName ) { theGlobals.namePtr = &theGlobals.name; } else { theGlobals.namePtr = NULL; } theGlobals.yourDataPtr = yourDataPtr; theGlobals.maxLevels = maxLevels; theGlobals.currentLevel = 0; theGlobals.quitFlag = false; theGlobals.containerChanged = false; theGlobals.result = noErr; theGlobals.actualObjects = 0; /* here we go into recursion land... */ FSIterateContainerLevel(&theGlobals); result = theGlobals.result; require_noerr(result, FSIterateContainerLevel); FSIterateContainerLevel: NoIterateFilter: return ( result ); } /*****************************************************************************/ OSErr FSGetDirectoryItems( const FSRef *container, FSRef ***refsHandle, /* pointer to handle of FSRefs */ ItemCount *numRefs, Boolean *containerChanged) { /* Grab items 10 at a time. */ enum { kMaxItemsPerBulkCall = 10 }; OSErr result; OSErr memResult; FSIterator iterator; FSRef refs[kMaxItemsPerBulkCall]; ItemCount actualObjects; Boolean changed; /* check parameters */ require_action((NULL != refsHandle) && (NULL != numRefs) && (NULL != containerChanged), BadParameter, result = paramErr); *numRefs = 0; *containerChanged = false; *refsHandle = (FSRef **)NewHandle(0); require_action(NULL != *refsHandle, NewHandle, result = memFullErr); /* open an FSIterator */ result = FSOpenIterator(container, kFSIterateFlat, &iterator); require_noerr(result, FSOpenIterator); /* Call FSGetCatalogInfoBulk in loop to get all items in the container */ do { result = FSGetCatalogInfoBulk(iterator, kMaxItemsPerBulkCall, &actualObjects, &changed, kFSCatInfoNone, NULL, refs, NULL, NULL); /* if the container changed, set containerChanged for output, but keep going */ if ( changed ) { *containerChanged = changed; } /* any result other than noErr and errFSNoMoreItems is serious */ require((noErr == result) || (errFSNoMoreItems == result), FSGetCatalogInfoBulk); /* add objects to output array and count */ if ( 0 != actualObjects ) { /* concatenate the FSRefs to the end of the handle */ PtrAndHand(refs, (Handle)*refsHandle, actualObjects * sizeof(FSRef)); memResult = MemError(); require_noerr_action(memResult, MemoryAllocationFailed, result = memResult); *numRefs += actualObjects; } } while ( noErr == result ); verify_noerr(FSCloseIterator(iterator)); /* closing an open iterator should never fail, but... */ return ( noErr ); /**********************/ MemoryAllocationFailed: FSGetCatalogInfoBulk: /* close the iterator */ verify_noerr(FSCloseIterator(iterator)); FSOpenIterator: /* dispose of handle if already allocated and clear the outputs */ if ( NULL != *refsHandle ) { DisposeHandle((Handle)*refsHandle); *refsHandle = NULL; } *numRefs = 0; NewHandle: BadParameter: return ( result ); } /*****************************************************************************/ /* The GenerateUniqueName function generates a HFSUniStr255 name that is unique in both dir1 and dir2. startSeed --> A pointer to a long which is used to generate the unique name. <-- It is modified on output to a value which should be used to generate the next unique name. dir1 --> The first directory. dir2 --> The second directory. uniqueName <-- A pointer to a HFSUniStr255 where the unique name is to be returned. */ static OSErr GenerateUniqueHFSUniStr( long *startSeed, const FSRef *dir1, const FSRef *dir2, HFSUniStr255 *uniqueName) { OSErr result; long i; FSRefParam pb; FSRef newRef; unsigned char hexStr[17] = "0123456789ABCDEF"; /* set up the parameter block */ pb.name = uniqueName->unicode; pb.nameLength = 8; /* always 8 characters */ pb.textEncodingHint = kTextEncodingUnknown; pb.newRef = &newRef; /* loop until we get fnfErr with a filename in both directories */ result = noErr; while ( fnfErr != result ) { /* convert startSeed to 8 character Unicode string */ uniqueName->length = 8; for ( i = 0; i < 8; ++i ) { uniqueName->unicode[i] = hexStr[((*startSeed >> ((7-i)*4)) & 0xf)]; } /* try in dir1 */ pb.ref = dir1; result = PBMakeFSRefUnicodeSync(&pb); if ( fnfErr == result ) { /* try in dir2 */ pb.ref = dir2; result = PBMakeFSRefUnicodeSync(&pb); if ( fnfErr != result ) { /* exit if anything other than noErr or fnfErr */ require_noerr(result, Dir2PBMakeFSRefUnicodeSyncFailed); } } else { /* exit if anything other than noErr or fnfErr */ require_noerr(result, Dir1PBMakeFSRefUnicodeSyncFailed); } /* increment seed for next pass through loop, */ /* or for next call to GenerateUniqueHFSUniStr */ ++(*startSeed); } /* we have a unique file name which doesn't exist in dir1 or dir2 */ result = noErr; Dir2PBMakeFSRefUnicodeSyncFailed: Dir1PBMakeFSRefUnicodeSyncFailed: return ( result ); } /*****************************************************************************/ OSErr FSExchangeObjectsCompat( const FSRef *sourceRef, const FSRef *destRef, FSRef *newSourceRef, FSRef *newDestRef) { enum { /* get all settable info except for mod dates, plus the volume refNum and parent directory ID */ kGetCatInformationMask = (kFSCatInfoSettableInfo | kFSCatInfoVolume | kFSCatInfoParentDirID) & ~(kFSCatInfoContentMod | kFSCatInfoAttrMod), /* set everything possible except for mod dates */ kSetCatinformationMask = kFSCatInfoSettableInfo & ~(kFSCatInfoContentMod | kFSCatInfoAttrMod) }; OSErr result; GetVolParmsInfoBuffer volParmsInfo; UInt32 infoSize; FSCatalogInfo sourceCatalogInfo; /* source file's catalog information */ FSCatalogInfo destCatalogInfo; /* destination file's catalog information */ HFSUniStr255 sourceName; /* source file's Unicode name */ HFSUniStr255 destName; /* destination file's Unicode name */ FSRef sourceCurrentRef; /* FSRef to current location of source file throughout this function */ FSRef destCurrentRef; /* FSRef to current location of destination file throughout this function */ FSRef sourceParentRef; /* FSRef to parent directory of source file */ FSRef destParentRef; /* FSRef to parent directory of destination file */ HFSUniStr255 sourceUniqueName; /* unique name given to source file while exchanging it with destination */ HFSUniStr255 destUniqueName; /* unique name given to destination file while exchanging it with source */ long theSeed; /* the seed for generating unique names */ Boolean sameParentDirs; /* true if source and destinatin parent directory is the same */ /* check parameters */ require_action((NULL != newSourceRef) && (NULL != newDestRef), BadParameter, result = paramErr); /* output refs and current refs = input refs to start with */ BlockMoveData(sourceRef, newSourceRef, sizeof(FSRef)); BlockMoveData(sourceRef, &sourceCurrentRef, sizeof(FSRef)); BlockMoveData(destRef, newDestRef, sizeof(FSRef)); BlockMoveData(destRef, &destCurrentRef, sizeof(FSRef)); /* get source volume's vRefNum */ result = FSGetCatalogInfo(&sourceCurrentRef, kFSCatInfoVolume, &sourceCatalogInfo, NULL, NULL, NULL); require_noerr(result, DetermineSourceVRefNumFailed); /* see if that volume supports FSExchangeObjects */ result = FSGetVolParms(sourceCatalogInfo.volume, sizeof(GetVolParmsInfoBuffer), &volParmsInfo, &infoSize); if ( (noErr == result) && VolSupportsFSExchangeObjects(&volParmsInfo) ) { /* yes - use FSExchangeObjects */ result = FSExchangeObjects(sourceRef, destRef); } else { /* no - emulate FSExchangeObjects */ /* Note: The compatibility case won't work for files with *Btree control blocks. */ /* Right now the only *Btree files are created by the system. */ /* get all catalog information and Unicode names for each file */ result = FSGetCatalogInfo(&sourceCurrentRef, kGetCatInformationMask, &sourceCatalogInfo, &sourceName, NULL, &sourceParentRef); require_noerr(result, SourceFSGetCatalogInfoFailed); result = FSGetCatalogInfo(&destCurrentRef, kGetCatInformationMask, &destCatalogInfo, &destName, NULL, &destParentRef); require_noerr(result, DestFSGetCatalogInfoFailed); /* make sure source and destination are on same volume */ require_action(sourceCatalogInfo.volume == destCatalogInfo.volume, NotSameVolume, result = diffVolErr); /* make sure both files are *really* files */ require_action((0 == (sourceCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask)) && (0 == (destCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask)), NotAFile, result = notAFileErr); /* generate 2 names that are unique in both directories */ theSeed = 0x4a696d4c; /* a fine unlikely filename */ result = GenerateUniqueHFSUniStr(&theSeed, &sourceParentRef, &destParentRef, &sourceUniqueName); require_noerr(result, GenerateUniqueHFSUniStr1Failed); result = GenerateUniqueHFSUniStr(&theSeed, &sourceParentRef, &destParentRef, &destUniqueName); require_noerr(result, GenerateUniqueHFSUniStr2Failed); /* rename sourceCurrentRef to sourceUniqueName */ result = FSRenameUnicode(&sourceCurrentRef, sourceUniqueName.length, sourceUniqueName.unicode, kTextEncodingUnknown, newSourceRef); require_noerr(result, FSRenameUnicode1Failed); BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); /* rename destCurrentRef to destUniqueName */ result = FSRenameUnicode(&destCurrentRef, destUniqueName.length, destUniqueName.unicode, kTextEncodingUnknown, newDestRef); require_noerr(result, FSRenameUnicode2Failed); BlockMoveData(newDestRef, &destCurrentRef, sizeof(FSRef)); /* are the source and destination parent directories the same? */ sameParentDirs = ( sourceCatalogInfo.parentDirID == destCatalogInfo.parentDirID ); if ( !sameParentDirs ) { /* move source file to dest parent directory */ result = FSMoveObject(&sourceCurrentRef, &destParentRef, newSourceRef); require_noerr(result, FSMoveObject1Failed); BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); /* move dest file to source parent directory */ result = FSMoveObject(&destCurrentRef, &sourceParentRef, newDestRef); require_noerr(result, FSMoveObject2Failed); BlockMoveData(newDestRef, &destCurrentRef, sizeof(FSRef)); } /* At this point, the files are in their new locations (if they were moved). */ /* The source file is named sourceUniqueName and is in the directory referred to */ /* by destParentRef. The destination file is named destUniqueName and is in the */ /* directory referred to by sourceParentRef. */ /* give source file the dest file's catalog information except for mod dates */ res... [truncated message content] |
|
From: <cre...@us...> - 2006-03-28 03:57:14
|
Revision: 1163 Author: creecode Date: 2006-03-27 19:57:11 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1163&view=rev Log Message: ----------- update MoreFilesX to v1.0.2, added a new directory MoreFilesX because the download comes separately from MoreFiles, don't want to commingle old and new code Removed Paths: ------------- Frontier/trunk/Common/MoreFiles/MoreFilesX.c Frontier/trunk/Common/MoreFiles/MoreFilesX.h Deleted: Frontier/trunk/Common/MoreFiles/MoreFilesX.c =================================================================== --- Frontier/trunk/Common/MoreFiles/MoreFilesX.c 2006-03-28 03:46:47 UTC (rev 1162) +++ Frontier/trunk/Common/MoreFiles/MoreFilesX.c 2006-03-28 03:57:11 UTC (rev 1163) @@ -1,2773 +0,0 @@ - -/* $Id$ */ - -/* - File: MoreFilesX.c - - Contains: A collection of useful high-level File Manager routines - which use the HFS Plus APIs wherever possible. - - Version: MoreFilesX 1.0.1 - - Copyright: \xA9 1992-2002 by 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\xD5s - 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. - - File Ownership: - - DRI: Apple Macintosh Developer Technical Support - - Other Contact: For bug reports, consult the following page on - the World Wide Web: - http://developer.apple.com/bugreporter/ - - Technology: DTS Sample Code - - Writers: - - (JL) Jim Luther - - Change History (most recent first): - - <4> 8/22/02 JL [3016251] Changed FSMoveRenameObjectUnicode to not use - the Temporary folder because it isn't available on - NFS volumes. - <3> 4/19/02 JL [2853905] Fixed #if test around header includes. - <2> 4/19/02 JL [2850624] Fixed C++ compile errors and Project Builder - warnings. - <2> 4/19/02 JL [2853901] Updated standard disclaimer. - <1> 1/25/02 JL MoreFilesX 1.0 -*/ - -#if defined(__MACH__) - #include <Carbon/Carbon.h> - #include <string.h> -#else - #include <Carbon.h> - #include <string.h> -#endif - -#include "MoreFilesX.h" - -/* Set BuildingMoreFilesXForMacOS9 to 1 if building for Mac OS 9 */ -#ifndef BuildingMoreFilesXForMacOS9 - #define BuildingMoreFilesXForMacOS9 0 -#endif - -/*****************************************************************************/ - -#pragma mark ----- Local type definitions ----- - -struct FSIterateContainerGlobals -{ - IterateContainerFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */ - FSCatalogInfoBitmap whichInfo; /* fields of the CatalogInfo to get */ - FSCatalogInfo catalogInfo; /* FSCatalogInfo */ - FSRef ref; /* FSRef */ - FSSpec spec; /* FSSpec */ - FSSpec *specPtr; /* pointer to spec field, or NULL */ - HFSUniStr255 name; /* HFSUniStr255 */ - HFSUniStr255 *namePtr; /* pointer to name field, or NULL */ - void *yourDataPtr; /* a pointer to caller supplied data the filter may need to access */ - ItemCount maxLevels; /* maximum levels to iterate through */ - ItemCount currentLevel; /* the current level FSIterateContainerLevel is on */ - Boolean quitFlag; /* set to true if filter wants to kill interation */ - Boolean containerChanged; /* temporary - set to true if the current container changed during iteration */ - OSErr result; /* result */ - ItemCount actualObjects; /* number of objects returned */ -}; -typedef struct FSIterateContainerGlobals FSIterateContainerGlobals; - -struct FSDeleteContainerGlobals -{ - OSErr result; /* result */ - ItemCount actualObjects; /* number of objects returned */ - FSCatalogInfo catalogInfo; /* FSCatalogInfo */ -}; -typedef struct FSDeleteContainerGlobals FSDeleteContainerGlobals; - -/*****************************************************************************/ - -#pragma mark ----- Local prototypes ----- - -static -void -FSDeleteContainerLevel( - const FSRef *container, - FSDeleteContainerGlobals *theGlobals); - -static -void -FSIterateContainerLevel( - FSIterateContainerGlobals *theGlobals); - -static -OSErr -GenerateUniqueHFSUniStr( - long *startSeed, - const FSRef *dir1, - const FSRef *dir2, - HFSUniStr255 *uniqueName); - -/*****************************************************************************/ - -#pragma mark ----- File Access Routines ----- - -/*****************************************************************************/ - -OSErr -FSCopyFork( - SInt16 srcRefNum, - SInt16 dstRefNum, - void *copyBufferPtr, - ByteCount copyBufferSize) -{ - OSErr srcResult; - OSErr dstResult; - OSErr result; - SInt64 forkSize; - ByteCount readActualCount; - - /* check input parameters */ - require_action((NULL != copyBufferPtr) && (0 != copyBufferSize), BadParameter, result = paramErr); - - /* get source fork size */ - result = FSGetForkSize(srcRefNum, &forkSize); - require_noerr(result, SourceFSGetForkSizeFailed); - - /* allocate disk space for destination fork */ - result = FSSetForkSize(dstRefNum, fsFromStart, forkSize); - require_noerr(result, DestinationFSSetForkSizeFailed); - - /* reset source fork's position to 0 */ - result = FSSetForkPosition(srcRefNum, fsFromStart, 0); - require_noerr(result, SourceFSSetForkPositionFailed); - - /* reset destination fork's position to 0 */ - result = FSSetForkPosition(dstRefNum, fsFromStart, 0); - require_noerr(result, DestinationFSSetForkPositionFailed); - - /* If copyBufferSize is greater than 4K bytes, make it a multiple of 4k bytes */ - /* This will make writes on local volumes faster */ - if ( (copyBufferSize >= 0x00001000) && ((copyBufferSize & 0x00000fff) != 0) ) - { - copyBufferSize &= ~(0x00001000 - 1); - } - - /* copy source to destination */ - srcResult = dstResult = noErr; - while ( (noErr == srcResult) && (noErr == dstResult) ) - { - srcResult = FSReadFork(srcRefNum, fsAtMark + noCacheMask, 0, copyBufferSize, copyBufferPtr, &readActualCount); - dstResult = FSWriteFork(dstRefNum, fsAtMark + noCacheMask, 0, readActualCount, copyBufferPtr, NULL); - } - - /* make sure there were no errors at the destination */ - require_noerr_action(dstResult, DestinationFSWriteForkFailed, result = dstResult); - - /* make sure the error at the source was eofErr */ - require_action(eofErr == srcResult, SourceResultNotEofErr, result = srcResult); - - /* everything went as expected */ - result = noErr; - -SourceResultNotEofErr: -DestinationFSWriteForkFailed: -DestinationFSSetForkPositionFailed: -SourceFSSetForkPositionFailed: -DestinationFSSetForkSizeFailed: -SourceFSGetForkSizeFailed: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -#pragma mark ----- Volume Access Routines ----- - -/*****************************************************************************/ - -OSErr -FSGetVolParms( - FSVolumeRefNum volRefNum, - UInt32 bufferSize, - GetVolParmsInfoBuffer *volParmsInfo, - UInt32 *actualInfoSize) -{ - OSErr result; - HParamBlockRec pb; - - /* check parameters */ - require_action((NULL != volParmsInfo) && (NULL != actualInfoSize), - BadParameter, result = paramErr); - - pb.ioParam.ioNamePtr = NULL; - pb.ioParam.ioVRefNum = volRefNum; - pb.ioParam.ioBuffer = (Ptr)volParmsInfo; - pb.ioParam.ioReqCount = (SInt32)bufferSize; - result = PBHGetVolParmsSync(&pb); - require_noerr(result, PBHGetVolParmsSync); - - /* return number of bytes the file system returned in volParmsInfo buffer */ - *actualInfoSize = (UInt32)pb.ioParam.ioActCount; - -PBHGetVolParmsSync: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetVRefNum( - const FSRef *ref, - FSVolumeRefNum *vRefNum) -{ - OSErr result; - FSCatalogInfo catalogInfo; - - /* check parameters */ - require_action(NULL != vRefNum, BadParameter, result = paramErr); - - /* get the volume refNum from the FSRef */ - result = FSGetCatalogInfo(ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - - /* return volume refNum from catalogInfo */ - *vRefNum = catalogInfo.volume; - -FSGetCatalogInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetVInfo( - FSVolumeRefNum volume, - HFSUniStr255 *volumeName, /* can be NULL */ - UInt64 *freeBytes, /* can be NULL */ - UInt64 *totalBytes) /* can be NULL */ -{ - OSErr result; - FSVolumeInfo info; - - /* ask for the volume's sizes only if needed */ - result = FSGetVolumeInfo(volume, 0, NULL, - (((NULL != freeBytes) || (NULL != totalBytes)) ? kFSVolInfoSizes : kFSVolInfoNone), - &info, volumeName, NULL); - require_noerr(result, FSGetVolumeInfo); - - if ( NULL != freeBytes ) - { - *freeBytes = info.freeBytes; - } - if ( NULL != totalBytes ) - { - *totalBytes = info.totalBytes; - } - -FSGetVolumeInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetVolFileSystemID( - FSVolumeRefNum volume, - UInt16 *fileSystemID, /* can be NULL */ - UInt16 *signature) /* can be NULL */ -{ - OSErr result; - FSVolumeInfo info; - - result = FSGetVolumeInfo(volume, 0, NULL, kFSVolInfoFSInfo, &info, NULL, NULL); - require_noerr(result, FSGetVolumeInfo); - - if ( NULL != fileSystemID ) - { - *fileSystemID = info.filesystemID; - } - if ( NULL != signature ) - { - *signature = info.signature; - } - -FSGetVolumeInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetMountedVolumes( - FSRef ***volumeRefsHandle, /* pointer to handle of FSRefs */ - ItemCount *numVolumes) -{ - OSErr result; - OSErr memResult; - ItemCount volumeIndex; - FSRef ref; - - /* check parameters */ - require_action((NULL != volumeRefsHandle) && (NULL != numVolumes), - BadParameter, result = paramErr); - - /* No volumes yet */ - *numVolumes = 0; - - /* Allocate a handle for the results */ - *volumeRefsHandle = (FSRef **)NewHandle(0); - require_action(NULL != *volumeRefsHandle, NewHandle, result = memFullErr); - - /* Call FSGetVolumeInfo in loop to get all volumes starting with the first */ - volumeIndex = 1; - do - { - result = FSGetVolumeInfo(0, volumeIndex, NULL, kFSVolInfoNone, NULL, NULL, &ref); - if ( noErr == result ) - { - /* concatenate the FSRef to the end of the handle */ - PtrAndHand(&ref, (Handle)*volumeRefsHandle, sizeof(FSRef)); - memResult = MemError(); - require_noerr_action(memResult, MemoryAllocationFailed, result = memResult); - - ++(*numVolumes); /* increment the volume count */ - ++volumeIndex; /* and the volumeIndex to get the next volume*/ - } - } while ( noErr == result ); - - /* nsvErr is OK -- it just means there are no more volumes */ - require(nsvErr == result, FSGetVolumeInfo); - - return ( noErr ); - - /**********************/ - -MemoryAllocationFailed: -FSGetVolumeInfo: - - /* dispose of handle if already allocated and clear the outputs */ - if ( NULL != *volumeRefsHandle ) - { - DisposeHandle((Handle)*volumeRefsHandle); - *volumeRefsHandle = NULL; - } - *numVolumes = 0; - -NewHandle: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -#pragma mark ----- FSRef/FSpec/Path/Name Conversion Routines ----- - -/*****************************************************************************/ - -OSErr -FSRefMakeFSSpec( - const FSRef *ref, - FSSpec *spec) -{ - OSErr result; - - /* check parameters */ - require_action(NULL != spec, BadParameter, result = paramErr); - - result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, spec, NULL); - require_noerr(result, FSGetCatalogInfo); - -FSGetCatalogInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSMakeFSRef( - FSVolumeRefNum volRefNum, - SInt32 dirID, - ConstStr255Param name, - FSRef *ref) -{ - OSErr result; - FSRefParam pb; - - /* check parameters */ - require_action(NULL != ref, BadParameter, result = paramErr); - - pb.ioVRefNum = volRefNum; - pb.ioDirID = dirID; - pb.ioNamePtr = (StringPtr)name; - pb.newRef = ref; - result = PBMakeFSRefSync(&pb); - require_noerr(result, PBMakeFSRefSync); - -PBMakeFSRefSync: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSStatus -FSMakePath( - SInt16 volRefNum, - SInt32 dirID, - ConstStr255Param name, - UInt8 *path, - UInt32 maxPathSize) -{ - OSStatus result; - FSRef ref; - - /* check parameters */ - require_action(NULL != path, BadParameter, result = paramErr); - - /* convert the inputs to an FSRef */ - result = FSMakeFSRef(volRefNum, dirID, name, &ref); - require_noerr(result, FSMakeFSRef); - - /* and then convert the FSRef to a path */ - result = FSRefMakePath(&ref, path, maxPathSize); - require_noerr(result, FSRefMakePath); - -FSRefMakePath: -FSMakeFSRef: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSStatus -FSPathMakeFSSpec( - const UInt8 *path, - FSSpec *spec, - Boolean *isDirectory) /* can be NULL */ -{ - OSStatus result; - FSRef ref; - - /* check parameters */ - require_action(NULL != spec, BadParameter, result = paramErr); - - /* convert the POSIX path to an FSRef */ - result = FSPathMakeRef(path, &ref, isDirectory); - require_noerr(result, FSPathMakeRef); - - /* and then convert the FSRef to an FSSpec */ - result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL); - require_noerr(result, FSGetCatalogInfo); - -FSGetCatalogInfo: -FSPathMakeRef: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -UnicodeNameGetHFSName( - UniCharCount nameLength, - const UniChar *name, - TextEncoding textEncodingHint, - Boolean isVolumeName, - Str31 hfsName) -{ - OSStatus result; - ByteCount unicodeByteLength; - ByteCount unicodeBytesConverted; - ByteCount actualPascalBytes; - UnicodeMapping uMapping; - UnicodeToTextInfo utInfo; - - /* check parameters */ - require_action(NULL != hfsName, BadParameter, result = paramErr); - - /* make sure output is valid in case we get errors or there's nothing to convert */ - hfsName[0] = 0; - - unicodeByteLength = nameLength * sizeof(UniChar); - if ( 0 == unicodeByteLength ) - { - /* do nothing */ - result = noErr; - } - else - { - /* if textEncodingHint is kTextEncodingUnknown, get a "default" textEncodingHint */ - if ( kTextEncodingUnknown == textEncodingHint ) - { - ScriptCode script; - RegionCode region; - - script = (ScriptCode)GetScriptManagerVariable(smSysScript); - region = (RegionCode)GetScriptManagerVariable(smRegionCode); - result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, region, - NULL, &textEncodingHint ); - if ( paramErr == result ) - { - /* ok, ignore the region and try again */ - result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, - kTextRegionDontCare, NULL, &textEncodingHint ); - } - if ( noErr != result ) - { - /* ok... try something */ - textEncodingHint = kTextEncodingMacRoman; - } - } - - uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeV2_0, - kUnicodeCanonicalDecompVariant, kUnicode16BitFormat); - uMapping.otherEncoding = GetTextEncodingBase(textEncodingHint); - uMapping.mappingVersion = kUnicodeUseHFSPlusMapping; - - result = CreateUnicodeToTextInfo(&uMapping, &utInfo); - require_noerr(result, CreateUnicodeToTextInfo); - - result = ConvertFromUnicodeToText(utInfo, unicodeByteLength, name, kUnicodeLooseMappingsMask, - 0, NULL, 0, NULL, /* offsetCounts & offsetArrays */ - isVolumeName ? kHFSMaxVolumeNameChars : kHFSMaxFileNameChars, - &unicodeBytesConverted, &actualPascalBytes, &hfsName[1]); - require_noerr(result, ConvertFromUnicodeToText); - - hfsName[0] = (unsigned char)actualPascalBytes; /* fill in length byte */ - -ConvertFromUnicodeToText: - - /* verify the result in debug builds -- there's really not anything you can do if it fails */ - verify_noerr(DisposeUnicodeToTextInfo(&utInfo)); - } - -CreateUnicodeToTextInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -HFSNameGetUnicodeName( - ConstStr31Param hfsName, - TextEncoding textEncodingHint, - HFSUniStr255 *unicodeName) -{ - ByteCount unicodeByteLength; - OSStatus result; - UnicodeMapping uMapping; - TextToUnicodeInfo tuInfo; - ByteCount pascalCharsRead; - - /* check parameters */ - require_action(NULL != unicodeName, BadParameter, result = paramErr); - - /* make sure output is valid in case we get errors or there's nothing to convert */ - unicodeName->length = 0; - - if ( 0 == StrLength(hfsName) ) - { - result = noErr; - } - else - { - /* if textEncodingHint is kTextEncodingUnknown, get a "default" textEncodingHint */ - if ( kTextEncodingUnknown == textEncodingHint ) - { - ScriptCode script; - RegionCode region; - - script = GetScriptManagerVariable(smSysScript); - region = GetScriptManagerVariable(smRegionCode); - result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, region, - NULL, &textEncodingHint); - if ( paramErr == result ) - { - /* ok, ignore the region and try again */ - result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, - kTextRegionDontCare, NULL, &textEncodingHint); - } - if ( noErr != result ) - { - /* ok... try something */ - textEncodingHint = kTextEncodingMacRoman; - } - } - - uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeV2_0, - kUnicodeCanonicalDecompVariant, kUnicode16BitFormat); - uMapping.otherEncoding = GetTextEncodingBase(textEncodingHint); - uMapping.mappingVersion = kUnicodeUseHFSPlusMapping; - - result = CreateTextToUnicodeInfo(&uMapping, &tuInfo); - require_noerr(result, CreateTextToUnicodeInfo); - - result = ConvertFromTextToUnicode(tuInfo, hfsName[0], &hfsName[1], - 0, /* no control flag bits */ - 0, NULL, 0, NULL, /* offsetCounts & offsetArrays */ - sizeof(unicodeName->unicode), /* output buffer size in bytes */ - &pascalCharsRead, &unicodeByteLength, unicodeName->unicode); - require_noerr(result, ConvertFromTextToUnicode); - - /* convert from byte count to char count */ - unicodeName->length = unicodeByteLength / sizeof(UniChar); - -ConvertFromTextToUnicode: - - /* verify the result in debug builds -- there's really not anything you can do if it fails */ - verify_noerr(DisposeTextToUnicodeInfo(&tuInfo)); - } - -CreateTextToUnicodeInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -#pragma mark ----- File/Directory Manipulation Routines ----- - -/*****************************************************************************/ - -Boolean FSRefValid(const FSRef *ref) -{ - return ( noErr == FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, NULL, NULL) ); -} - -/*****************************************************************************/ - -OSErr -FSGetParentRef( - const FSRef *ref, - FSRef *parentRef) -{ - OSErr result; - FSCatalogInfo catalogInfo; - - /* check parameters */ - require_action(NULL != parentRef, BadParameter, result = paramErr); - - result = FSGetCatalogInfo(ref, kFSCatInfoNodeID, &catalogInfo, NULL, NULL, parentRef); - require_noerr(result, FSGetCatalogInfo); - - /* - * Note: FSRefs always point to real file system objects. So, there cannot - * be a FSRef to the parent of volume root directories. Early versions of - * Mac OS X do not handle this case correctly and incorrectly return a - * FSRef for the parent of volume root directories instead of returning an - * invalid FSRef (a cleared FSRef is invalid). The next three lines of code - * ensure that you won't run into this bug. WW9D! - */ - if ( fsRtDirID == catalogInfo.nodeID ) - { - /* clear parentRef and return noErr which is the proper behavior */ - memset(parentRef, 0, sizeof(FSRef)); - } - -FSGetCatalogInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetFileDirName( - const FSRef *ref, - HFSUniStr255 *outName) -{ - OSErr result; - - /* check parameters */ - require_action(NULL != outName, BadParameter, result = paramErr); - - result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, outName, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - -FSGetCatalogInfo: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetNodeID( - const FSRef *ref, - long *nodeID, /* can be NULL */ - Boolean *isDirectory) /* can be NULL */ -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSCatalogInfoBitmap whichInfo; - - /* determine what catalog information to get */ - whichInfo = kFSCatInfoNone; /* start with none */ - if ( NULL != nodeID ) - { - whichInfo |= kFSCatInfoNodeID; - } - if ( NULL != isDirectory ) - { - whichInfo |= kFSCatInfoNodeFlags; - } - - result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - - if ( NULL != nodeID ) - { - *nodeID = catalogInfo.nodeID; - } - if ( NULL != isDirectory ) - { - *isDirectory = (0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags)); - } - -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetUserPrivilegesPermissions( - const FSRef *ref, - UInt8 *userPrivileges, /* can be NULL */ - UInt32 permissions[4]) /* can be NULL */ -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSCatalogInfoBitmap whichInfo; - - /* determine what catalog information to get */ - whichInfo = kFSCatInfoNone; /* start with none */ - if ( NULL != userPrivileges ) - { - whichInfo |= kFSCatInfoUserPrivs; - } - if ( NULL != permissions ) - { - whichInfo |= kFSCatInfoPermissions; - } - - result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - - if ( NULL != userPrivileges ) - { - *userPrivileges = catalogInfo.userPrivileges; - } - if ( NULL != permissions ) - { - BlockMoveData(&catalogInfo.permissions, permissions, sizeof(UInt32) * 4); - } - -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSCheckLock( - const FSRef *ref) -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSVolumeInfo volumeInfo; - - /* get nodeFlags and vRefNum for container */ - result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoVolume, &catalogInfo, NULL, NULL,NULL); - require_noerr(result, FSGetCatalogInfo); - - /* is file locked? */ - if ( 0 != (catalogInfo.nodeFlags & kFSNodeLockedMask) ) - { - result = fLckdErr; /* file is locked */ - } - else - { - /* file isn't locked, but is volume locked? */ - - /* get volume flags */ - result = FSGetVolumeInfo(catalogInfo.volume, 0, NULL, kFSVolInfoFlags, &volumeInfo, NULL, NULL); - require_noerr(result, FSGetVolumeInfo); - - if ( 0 != (volumeInfo.flags & kFSVolFlagHardwareLockedMask) ) - { - result = wPrErr; /* volume locked by hardware */ - } - else if ( 0 != (volumeInfo.flags & kFSVolFlagSoftwareLockedMask) ) - { - result = vLckdErr; /* volume locked by software */ - } - } - -FSGetVolumeInfo: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetForkSizes( - const FSRef *ref, - UInt64 *dataLogicalSize, /* can be NULL */ - UInt64 *rsrcLogicalSize) /* can be NULL */ -{ - OSErr result; - FSCatalogInfoBitmap whichInfo; - FSCatalogInfo catalogInfo; - - whichInfo = kFSCatInfoNodeFlags; - if ( NULL != dataLogicalSize ) - { - /* get data fork size */ - whichInfo |= kFSCatInfoDataSizes; - } - if ( NULL != rsrcLogicalSize ) - { - /* get resource fork size */ - whichInfo |= kFSCatInfoRsrcSizes; - } - - /* get nodeFlags and catalog info */ - result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL,NULL); - require_noerr(result, FSGetCatalogInfo); - - /* make sure FSRef was to a file */ - require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), FSRefNotFile, result = notAFileErr); - - if ( NULL != dataLogicalSize ) - { - /* return data fork size */ - *dataLogicalSize = catalogInfo.dataLogicalSize; - } - if ( NULL != rsrcLogicalSize ) - { - /* return resource fork size */ - *rsrcLogicalSize = catalogInfo.rsrcLogicalSize; - } - -FSRefNotFile: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetTotalForkSizes( - const FSRef *ref, - UInt64 *totalLogicalSize, /* can be NULL */ - UInt64 *totalPhysicalSize, /* can be NULL */ - ItemCount *forkCount) /* can be NULL */ -{ - OSErr result; - CatPositionRec forkIterator; - SInt64 forkSize; - SInt64 *forkSizePtr; - UInt64 forkPhysicalSize; - UInt64 *forkPhysicalSizePtr; - - /* Determine if forkSize needed */ - if ( NULL != totalLogicalSize) - { - *totalLogicalSize = 0; - forkSizePtr = &forkSize; - } - else - { - forkSizePtr = NULL; - } - - /* Determine if forkPhysicalSize is needed */ - if ( NULL != totalPhysicalSize ) - { - *totalPhysicalSize = 0; - forkPhysicalSizePtr = &forkPhysicalSize; - } - else - { - forkPhysicalSizePtr = NULL; - } - - /* zero fork count if returning it */ - if ( NULL != forkCount ) - { - *forkCount = 0; - } - - /* Iterate through the forks to get the sizes */ - forkIterator.initialize = 0; - do - { - result = FSIterateForks(ref, &forkIterator, NULL, forkSizePtr, forkPhysicalSizePtr); - if ( noErr == result ) - { - if ( NULL != totalLogicalSize ) - { - *totalLogicalSize += forkSize; - } - - if ( NULL != totalPhysicalSize ) - { - *totalPhysicalSize += forkPhysicalSize; - } - - if ( NULL != forkCount ) - { - ++*forkCount; - } - } - } while ( noErr == result ); - - /* any error result other than errFSNoMoreItems is serious */ - require(errFSNoMoreItems == result, FSIterateForks); - - /* Normal exit */ - result = noErr; - -FSIterateForks: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSBumpDate( - const FSRef *ref) -{ - OSStatus result; - FSCatalogInfo catalogInfo; - UTCDateTime oldDateTime; -#if !BuildingMoreFilesXForMacOS9 - FSRef parentRef; - Boolean notifyParent; -#endif - -#if !BuildingMoreFilesXForMacOS9 - /* Get the node flags, the content modification date and time, and the parent ref */ - result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoContentMod, &catalogInfo, NULL, NULL, &parentRef); - require_noerr(result, FSGetCatalogInfo); - - /* Notify the parent if this is a file */ - notifyParent = (0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask)); -#else - /* Get the content modification date and time */ - result = FSGetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); -#endif - - oldDateTime = catalogInfo.contentModDate; - - /* Get the current date and time */ - result = GetUTCDateTime(&catalogInfo.contentModDate, kUTCDefaultOptions); - require_noerr(result, GetUTCDateTime); - - /* if the old date and time is the the same as the current, bump the seconds by one */ - if ( (catalogInfo.contentModDate.fraction == oldDateTime.fraction) && - (catalogInfo.contentModDate.lowSeconds == oldDateTime.lowSeconds) && - (catalogInfo.contentModDate.highSeconds == oldDateTime.highSeconds) ) - { - ++catalogInfo.contentModDate.lowSeconds; - if ( 0 == catalogInfo.contentModDate.lowSeconds ) - { - ++catalogInfo.contentModDate.highSeconds; - } - } - - /* Bump the content modification date and time */ - result = FSSetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo); - require_noerr(result, FSSetCatalogInfo); - -#if !BuildingMoreFilesXForMacOS9 - /* - * The problem with FNNotify is that it is not available under Mac OS 9 - * and there's no way to test for that except for looking for the symbol - * or something. So, I'll just conditionalize this for those who care - * to send a notification. - */ - - /* Send a notification for the parent of the file, or for the directory */ - result = FNNotify(notifyParent ? &parentRef : ref, kFNDirectoryModifiedMessage, kNilOptions); - require_noerr(result, FNNotify); -#endif - - /* ignore errors from FSSetCatalogInfo (volume might be write protected) and FNNotify */ -FNNotify: -FSSetCatalogInfo: - - return ( noErr ); - - /**********************/ - -GetUTCDateTime: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetFinderInfo( - const FSRef *ref, - FinderInfo *info, /* can be NULL */ - ExtendedFinderInfo *extendedInfo, /* can be NULL */ - Boolean *isDirectory) /* can be NULL */ -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSCatalogInfoBitmap whichInfo; - - /* determine what catalog information is really needed */ - whichInfo = kFSCatInfoNone; - - if ( NULL != info ) - { - /* get FinderInfo */ - whichInfo |= kFSCatInfoFinderInfo; - } - - if ( NULL != extendedInfo ) - { - /* get ExtendedFinderInfo */ - whichInfo |= kFSCatInfoFinderXInfo; - } - - if ( NULL != isDirectory ) - { - whichInfo |= kFSCatInfoNodeFlags; - } - - result = FSGetCatalogInfo(ref, whichInfo, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - - /* return FinderInfo if requested */ - if ( NULL != info ) - { - BlockMoveData(catalogInfo.finderInfo, info, sizeof(FinderInfo)); - } - - /* return ExtendedFinderInfo if requested */ - if ( NULL != extendedInfo) - { - BlockMoveData(catalogInfo.extFinderInfo, extendedInfo, sizeof(ExtendedFinderInfo)); - } - - /* set isDirectory Boolean if requested */ - if ( NULL != isDirectory) - { - *isDirectory = (0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags)); - } - -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSSetFinderInfo( - const FSRef *ref, - const FinderInfo *info, - const ExtendedFinderInfo *extendedInfo) -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSCatalogInfoBitmap whichInfo; - - /* determine what catalog information will be set */ - whichInfo = kFSCatInfoNone; /* start with none */ - if ( NULL != info ) - { - /* set FinderInfo */ - whichInfo |= kFSCatInfoFinderInfo; - BlockMoveData(info, catalogInfo.finderInfo, sizeof(FinderInfo)); - } - if ( NULL != extendedInfo ) - { - /* set ExtendedFinderInfo */ - whichInfo |= kFSCatInfoFinderXInfo; - BlockMoveData(extendedInfo, catalogInfo.extFinderInfo, sizeof(ExtendedFinderInfo)); - } - - result = FSSetCatalogInfo(ref, whichInfo, &catalogInfo); - require_noerr(result, FSGetCatalogInfo); - -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSChangeCreatorType( - const FSRef *ref, - OSType fileCreator, - OSType fileType) -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSRef parentRef; - - /* get nodeFlags, finder info, and parent FSRef */ - result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoFinderInfo, &catalogInfo , NULL, NULL, &parentRef); - require_noerr(result, FSGetCatalogInfo); - - /* make sure FSRef was to a file */ - require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), FSRefNotFile, result = notAFileErr); - - /* If fileType not 0x00000000, change fileType */ - if ( fileType != (OSType)0x00000000 ) - { - ((FileInfo *)&catalogInfo.finderInfo)->fileType = fileType; - } - - /* If creator not 0x00000000, change creator */ - if ( fileCreator != (OSType)0x00000000 ) - { - ((FileInfo *)&catalogInfo.finderInfo)->fileCreator = fileCreator; - } - - /* now, save the new information back to disk */ - result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo); - require_noerr(result, FSSetCatalogInfo); - - /* and attempt to bump the parent directory's mod date to wake up */ - /* the Finder to the change we just made (ignore errors from this) */ - verify_noerr(FSBumpDate(&parentRef)); - -FSSetCatalogInfo: -FSRefNotFile: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSChangeFinderFlags( - const FSRef *ref, - Boolean setBits, - UInt16 flagBits) -{ - OSErr result; - FSCatalogInfo catalogInfo; - FSRef parentRef; - - /* get the current finderInfo */ - result = FSGetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, &parentRef); - require_noerr(result, FSGetCatalogInfo); - - /* set or clear the appropriate bits in the finderInfo.finderFlags */ - if ( setBits ) - { - /* OR in the bits */ - ((FileInfo *)&catalogInfo.finderInfo)->finderFlags |= flagBits; - } - else - { - /* AND out the bits */ - ((FileInfo *)&catalogInfo.finderInfo)->finderFlags &= ~flagBits; - } - - /* save the modified finderInfo */ - result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo); - require_noerr(result, FSSetCatalogInfo); - - /* and attempt to bump the parent directory's mod date to wake up the Finder */ - /* to the change we just made (ignore errors from this) */ - verify_noerr(FSBumpDate(&parentRef)); - -FSSetCatalogInfo: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSSetInvisible( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, true, kIsInvisible) ); -} - -OSErr -FSClearInvisible( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, false, kIsInvisible) ); -} - -/*****************************************************************************/ - -OSErr -FSSetNameLocked( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, true, kNameLocked) ); -} - -OSErr -FSClearNameLocked( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, false, kNameLocked) ); -} - -/*****************************************************************************/ - -OSErr -FSSetIsStationery( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, true, kIsStationery) ); -} - -OSErr -FSClearIsStationery( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, false, kIsStationery) ); -} - -/*****************************************************************************/ - -OSErr -FSSetHasCustomIcon( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, true, kHasCustomIcon) ); -} - -OSErr -FSClearHasCustomIcon( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, false, kHasCustomIcon) ); -} - -/*****************************************************************************/ - -OSErr -FSClearHasBeenInited( - const FSRef *ref) -{ - return ( FSChangeFinderFlags(ref, false, kHasBeenInited) ); -} - -/*****************************************************************************/ - -OSErr -FSCopyFileMgrAttributes( - const FSRef *sourceRef, - const FSRef *destinationRef, - Boolean copyLockBit) -{ - OSErr result; - FSCatalogInfo catalogInfo; - - /* get the source information */ - result = FSGetCatalogInfo(sourceRef, kFSCatInfoSettableInfo, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, FSGetCatalogInfo); - - /* don't copy the hasBeenInited bit; clear it */ - ((FileInfo *)&catalogInfo.finderInfo)->finderFlags &= ~kHasBeenInited; - - /* should the locked bit be copied? */ - if ( !copyLockBit ) - { - /* no, make sure the locked bit is clear */ - catalogInfo.nodeFlags &= ~kFSNodeLockedMask; - } - - /* set the destination information */ - result = FSSetCatalogInfo(destinationRef, kFSCatInfoSettableInfo, &catalogInfo); - require_noerr(result, FSSetCatalogInfo); - -FSSetCatalogInfo: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSMoveRenameObjectUnicode( - const FSRef *ref, - const FSRef *destDirectory, - UniCharCount nameLength, - const UniChar *name, /* can be NULL (no rename during move) */ - TextEncoding textEncodingHint, - FSRef *newRef) /* if function fails along the way, newRef is final location of file */ -{ - OSErr result; - FSVolumeRefNum vRefNum; - FSCatalogInfo catalogInfo; - FSRef originalDirectory; - TextEncoding originalTextEncodingHint; - HFSUniStr255 originalName; - HFSUniStr255 uniqueName; /* unique name given to object while moving it to destination */ - long theSeed; /* the seed for generating unique names */ - - /* check parameters */ - require_action(NULL != newRef, BadParameter, result = paramErr); - - /* newRef = input to start with */ - BlockMoveData(ref, newRef, sizeof(FSRef)); - - /* get destDirectory's vRefNum */ - result = FSGetCatalogInfo(destDirectory, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL); - require_noerr(result, DestinationBad); - - /* save vRefNum */ - vRefNum = catalogInfo.volume; - - /* get ref's vRefNum, TextEncoding, name and parent directory*/ - result = FSGetCatalogInfo(ref, kFSCatInfoTextEncoding + kFSCatInfoVolume, &catalogInfo, &originalName, NULL, &originalDirectory); - require_noerr(result, SourceBad); - - /* save TextEncoding */ - originalTextEncodingHint = catalogInfo.textEncodingHint; - - /* make sure ref and destDirectory are on same volume */ - require_action(vRefNum == catalogInfo.volume, NotSameVolume, result = diffVolErr); - - /* Skip a few steps if we're not renaming */ - if ( NULL != name ) - { - /* generate a name that is unique in both directories */ - theSeed = 0x4a696d4c; /* a fine unlikely filename */ - - result = GenerateUniqueHFSUniStr(&theSeed, &originalDirectory, destDirectory, &uniqueName); - require_noerr(result, GenerateUniqueHFSUniStrFailed); - - /* Rename the object to uniqueName */ - result = FSRenameUnicode(ref, uniqueName.length, uniqueName.unicode, kTextEncodingUnknown, newRef); - require_noerr(result, FSRenameUnicodeBeforeMoveFailed); - - /* Move object to its new home */ - result = FSMoveObject(newRef, destDirectory, newRef); - require_noerr(result, FSMoveObjectAfterRenameFailed); - - /* Rename the object to new name */ - result = FSRenameUnicode(ref, nameLength, name, textEncodingHint, newRef); - require_noerr(result, FSRenameUnicodeAfterMoveFailed); - } - else - { - /* Move object to its new home */ - result = FSMoveObject(newRef, destDirectory, newRef); - require_noerr(result, FSMoveObjectNoRenameFailed); - } - - return ( result ); - - /*************/ - -/* - * failure handling code when renaming - */ - -FSRenameUnicodeAfterMoveFailed: - - /* Error handling: move object back to original location - ignore errors */ - verify_noerr(FSMoveObject(newRef, &originalDirectory, newRef)); - -FSMoveObjectAfterRenameFailed: - - /* Error handling: rename object back to original name - ignore errors */ - verify_noerr(FSRenameUnicode(newRef, originalName.length, originalName.unicode, originalTextEncodingHint, newRef)); - -FSRenameUnicodeBeforeMoveFailed: -GenerateUniqueHFSUniStrFailed: - -/* - * failure handling code for renaming or not - */ -FSMoveObjectNoRenameFailed: -NotSameVolume: -SourceBad: -DestinationBad: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -/* - The FSDeleteContainerLevel function deletes the contents of a container - directory. All files and subdirectories in the specified container are - deleted. If a locked file or directory is encountered, it is unlocked - and then deleted. If any unexpected errors are encountered, - FSDeleteContainerLevel quits and returns to the caller. - - container --> FSRef to a directory. - theGlobals --> A pointer to a FSDeleteContainerGlobals struct - which contains the variables that do not need to - be allocated each time FSDeleteContainerLevel - recurses. That lets FSDeleteContainerLevel use - less stack space per recursion level. -*/ - -static -void -FSDeleteContainerLevel( - const FSRef *container, - FSDeleteContainerGlobals *theGlobals) -{ - /* level locals */ - FSIterator iterator; - FSRef itemToDelete; - UInt16 nodeFlags; - - /* Open FSIterator for flat access and give delete optimization hint */ - theGlobals->result = FSOpenIterator(container, kFSIterateFlat + kFSIterateDelete, &iterator); - require_noerr(theGlobals->result, FSOpenIterator); - - /* delete the contents of the directory */ - do - { - /* get 1 item to delete */ - theGlobals->result = FSGetCatalogInfoBulk(iterator, 1, &theGlobals->actualObjects, - NULL, kFSCatInfoNodeFlags, &theGlobals->catalogInfo, - &itemToDelete, NULL, NULL); - if ( (noErr == theGlobals->result) && (1 == theGlobals->actualObjects) ) - { - /* save node flags in local in case we have to recurse */ - nodeFlags = theGlobals->catalogInfo.nodeFlags; - - /* is it a file or directory? */ - if ( 0 != (nodeFlags & kFSNodeIsDirectoryMask) ) - { - /* it's a directory -- delete its contents before attempting to delete it */ - FSDeleteContainerLevel(&itemToDelete, theGlobals); - } - /* are we still OK to delete? */ - if ( noErr == theGlobals->result ) - { - /* is item locked? */ - if ( 0 != (nodeFlags & kFSNodeLockedMask) ) - { - /* then attempt to unlock it (ignore result since FSDeleteObject will set it correctly) */ - theGlobals->catalogInfo.nodeFlags = nodeFlags & ~kFSNodeLockedMask; - (void) FSSetCatalogInfo(&itemToDelete, kFSCatInfoNodeFlags, &theGlobals->catalogInfo); - } - /* delete the item */ - theGlobals->result = FSDeleteObject(&itemToDelete); - } - } - } while ( noErr == theGlobals->result ); - - /* we found the end of the items normally, so return noErr */ - if ( errFSNoMoreItems == theGlobals->result ) - { - theGlobals->result = noErr; - } - - /* close the FSIterator (closing an open iterator should never fail) */ - verify_noerr(FSCloseIterator(iterator)); - -FSOpenIterator: - - return; -} - -/*****************************************************************************/ - -OSErr -FSDeleteContainerContents( - const FSRef *container) -{ - FSDeleteContainerGlobals theGlobals; - - /* delete container's contents */ - FSDeleteContainerLevel(container, &theGlobals); - - return ( theGlobals.result ); -} - -/*****************************************************************************/ - -OSErr -FSDeleteContainer( - const FSRef *container) -{ - OSErr result; - FSCatalogInfo catalogInfo; - - /* get nodeFlags for container */ - result = FSGetCatalogInfo(container, kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL,NULL); - require_noerr(result, FSGetCatalogInfo); - - /* make sure container is a directory */ - require_action(0 != (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask), ContainerNotDirectory, result = dirNFErr); - - /* delete container's contents */ - result = FSDeleteContainerContents(container); - require_noerr(result, FSDeleteContainerContents); - - /* is container locked? */ - if ( 0 != (catalogInfo.nodeFlags & kFSNodeLockedMask) ) - { - /* then attempt to unlock container (ignore result since FSDeleteObject will set it correctly) */ - catalogInfo.nodeFlags &= ~kFSNodeLockedMask; - (void) FSSetCatalogInfo(container, kFSCatInfoNodeFlags, &catalogInfo); - } - - /* delete the container */ - result = FSDeleteObject(container); - -FSDeleteContainerContents: -ContainerNotDirectory: -FSGetCatalogInfo: - - return ( result ); -} - -/*****************************************************************************/ - -/* - The FSIterateContainerLevel function iterates the contents of a container - directory and calls a IterateContainerFilterProc function once for each - file and directory found. - - theGlobals --> A pointer to a FSIterateContainerGlobals struct - which contains the variables needed globally by - all recusion levels of FSIterateContainerLevel. - That makes FSIterateContainer thread safe since - each call to it uses its own global world. - It also contains the variables that do not need - to be allocated each time FSIterateContainerLevel - recurses. That lets FSIterateContainerLevel use - less stack space per recursion level. -*/ - -static -void -FSIterateContainerLevel( - FSIterateContainerGlobals *theGlobals) -{ - FSIterator iterator; - - /* If maxLevels is zero, we aren't checking levels */ - /* If currentLevel < maxLevels, look at this level */ - if ( (theGlobals->maxLevels == 0) || - (theGlobals->currentLevel < theGlobals->maxLevels) ) - { - /* Open FSIterator for flat access to theGlobals->ref */ - theGlobals->result = FSOpenIterator(&theGlobals->ref, kFSIterateFlat, &iterator); - require_noerr(theGlobals->result, FSOpenIterator); - - ++theGlobals->currentLevel; /* Go to next level */ - - /* Call FSGetCatalogInfoBulk in loop to get all items in the container */ - do - { - theGlobals->result = FSGetCatalogInfoBulk(iterator, 1, &theGlobals->actualObjects, - &theGlobals->containerChanged, theGlobals->whichInfo, &theGlobals->catalogInfo, - &theGlobals->ref, theGlobals->specPtr, theGlobals->namePtr); - if ( (noErr == theGlobals->result || errFSNoMoreItems == theGlobals->result) && - (0 != theGlobals->actualObjects) ) - { - /* Call the IterateFilterProc */ - theGlobals->quitFlag = CallIterateContainerFilterProc(theGlobals->iterateFilter, - theGlobals->containerChanged, theGlobals->currentLevel, - &theGlobals->catalogInfo, &theGlobals->ref, - theGlobals->specPtr, theGlobals->namePtr, theGlobals->yourDataPtr); - /* Is it a directory? */ - if ( 0 != (theGlobals->catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) ) - { - /* Keep going? */ - if ( !theGlobals->quitFlag ) - { - /* Dive again if the IterateFilterProc didn't say "quit" */ - FSIterateContainerLevel(theGlobals); - } - } - } - /* time to fall back a level? */ - } while ( (noErr == theGlobals->result) && (!theGlobals->quitFlag) ); - - /* errFSNoMoreItems is OK - it only means we hit the end of this level */ - /* afpAccessDenied is OK, too - it only means we cannot see inside a directory */ - if ( (errFSNoMoreItems == theGlobals->result) || - (afpAccessDenied == theGlobals->result) ) - { - theGlobals->result = noErr; - } - - --theGlobals->currentLevel; /* Return to previous level as we leave */ - - /* Close the FSIterator (closing an open iterator should never fail) */ - verify_noerr(FSCloseIterator(iterator)); - } - -FSOpenIterator: - - return; -} - -/*****************************************************************************/ - -OSErr -FSIterateContainer( - const FSRef *container, - ItemCount maxLevels, - FSCatalogInfoBitmap whichInfo, - Boolean wantFSSpec, - Boolean wantName, - IterateContainerFilterProcPtr iterateFilter, - void *yourDataPtr) -{ - OSErr result; - FSIterateContainerGlobals theGlobals; - - /* make sure there is an iterateFilter */ - require_action(iterateFilter != NULL, NoIterateFilter, result = paramErr); - - /* - * set up the globals we need to access from the recursive routine - */ - theGlobals.iterateFilter = iterateFilter; - /* we need the node flags no matter what was requested so we can detect files vs. directories */ - theGlobals.whichInfo = whichInfo | kFSCatInfoNodeFlags; - /* start with input container -- the first OpenIterator will ensure it is a directory */ - theGlobals.ref = *container; - if ( wantFSSpec ) - { - theGlobals.specPtr = &theGlobals.spec; - } - else - { - theGlobals.specPtr = NULL; - } - if ( wantName ) - { - theGlobals.namePtr = &theGlobals.name; - } - else - { - theGlobals.namePtr = NULL; - } - theGlobals.yourDataPtr = yourDataPtr; - theGlobals.maxLevels = maxLevels; - theGlobals.currentLevel = 0; - theGlobals.quitFlag = false; - theGlobals.containerChanged = false; - theGlobals.result = noErr; - theGlobals.actualObjects = 0; - - /* here we go into recursion land... */ - FSIterateContainerLevel(&theGlobals); - result = theGlobals.result; - require_noerr(result, FSIterateContainerLevel); - -FSIterateContainerLevel: -NoIterateFilter: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSGetDirectoryItems( - const FSRef *container, - FSRef ***refsHandle, /* pointer to handle of FSRefs */ - ItemCount *numRefs, - Boolean *containerChanged) -{ - /* Grab items 10 at a time. */ - enum { kMaxItemsPerBulkCall = 10 }; - - OSErr result; - OSErr memResult; - FSIterator iterator; - FSRef refs[kMaxItemsPerBulkCall]; - ItemCount actualObjects; - Boolean changed; - - /* check parameters */ - require_action((NULL != refsHandle) && (NULL != numRefs) && (NULL != containerChanged), - BadParameter, result = paramErr); - - *numRefs = 0; - *containerChanged = false; - *refsHandle = (FSRef **)NewHandle(0); - require_action(NULL != *refsHandle, NewHandle, result = memFullErr); - - /* open an FSIterator */ - result = FSOpenIterator(container, kFSIterateFlat, &iterator); - require_noerr(result, FSOpenIterator); - - /* Call FSGetCatalogInfoBulk in loop to get all items in the container */ - do - { - result = FSGetCatalogInfoBulk(iterator, kMaxItemsPerBulkCall, &actualObjects, - &changed, kFSCatInfoNone, NULL, refs, NULL, NULL); - - /* if the container changed, set containerChanged for output, but keep going */ - if ( changed ) - { - *containerChanged = changed; - } - - /* any result other than noErr and errFSNoMoreItems is serious */ - require((noErr == result) || (errFSNoMoreItems == result), FSGetCatalogInfoBulk); - - /* add objects to output array and count */ - if ( 0 != actualObjects ) - { - /* concatenate the FSRefs to the end of the handle */ - PtrAndHand(refs, (Handle)*refsHandle, actualObjects * sizeof(FSRef)); - memResult = MemError(); - require_noerr_action(memResult, MemoryAllocationFailed, result = memResult); - - *numRefs += actualObjects; - } - } while ( noErr == result ); - - verify_noerr(FSCloseIterator(iterator)); /* closing an open iterator should never fail, but... */ - - return ( noErr ); - - /**********************/ - -MemoryAllocationFailed: -FSGetCatalogInfoBulk: - - /* close the iterator */ - verify_noerr(FSCloseIterator(iterator)); - -FSOpenIterator: - /* dispose of handle if already allocated and clear the outputs */ - if ( NULL != *refsHandle ) - { - DisposeHandle((Handle)*refsHandle); - *refsHandle = NULL; - } - *numRefs = 0; - -NewHandle: -BadParameter: - - return ( result ); -} - -/*****************************************************************************/ - -/* - The GenerateUniqueName function generates a HFSUniStr255 name that is - unique in both dir1 and dir2. - - startSeed --> A pointer to a long which is used to generate the - unique name. - <-- It is modified on output to a value which should - be used to generate the next unique name. - dir1 --> The first directory. - dir2 --> The second directory. - uniqueName <-- A pointer to a HFSUniStr255 where the unique name - is to be returned. -*/ - -static -OSErr -GenerateUniqueHFSUniStr( - long *startSeed, - const FSRef *dir1, - const FSRef *dir2, - HFSUniStr255 *uniqueName) -{ - OSErr result; - long i; - FSRefParam pb; - FSRef newRef; - unsigned char hexStr[17] = "0123456789ABCDEF"; - - /* set up the parameter block */ - pb.name = uniqueName->unicode; - pb.nameLength = 8; /* always 8 characters */ - pb.textEncodingHint = kTextEncodingUnknown; - pb.newRef = &newRef; - - /* loop until we get fnfErr with a filename in both directories */ - result = noErr; - while ( fnfErr != result ) - { - /* convert startSeed to 8 character Unicode string */ - uniqueName->length = 8; - for ( i = 0; i < 8; ++i ) - { - uniqueName->unicode[i] = hexStr[((*startSeed >> ((7-i)*4)) & 0xf)]; - } - - /* try in dir1 */ - pb.ref = dir1; - result = PBMakeFSRefUnicodeSync(&pb); - if ( fnfErr == result ) - { - /* try in dir2 */ - pb.ref = dir2; - result = PBMakeFSRefUnicodeSync(&pb); - if ( fnfErr != result ) - { - /* exit if anything other than noErr or fnfErr */ - require_noerr(result, Dir2PBMakeFSRefUnicodeSyncFailed); - } - } - else - { - /* exit if anything other than noErr or fnfErr */ - require_noerr(result, Dir1PBMakeFSRefUnicodeSyncFailed); - } - - /* increment seed for next pass through loop, */ - /* or for next call to GenerateUniqueHFSUniStr */ - ++(*startSeed); - } - - /* we have a unique file name which doesn't exist in dir1 or dir2 */ - result = noErr; - -Dir2PBMakeFSRefUnicodeSyncFailed: -Dir1PBMakeFSRefUnicodeSyncFailed: - - return ( result ); -} - -/*****************************************************************************/ - -OSErr -FSExchangeObjectsCompat( - const FSRef *sourceRef, - const FSRef *destRef, - FSRef *newSourceRef, - FSRef *newDestRef) -{ - enum - { - /* get all settable info except for mod dates, plus the volume refNum and parent directory ID */ - kGetCatInformationMask = (kFSCatInfoSettableInfo | - kFSCatInfoVolume | - kFSCatInfoParentDirID) & - ~(kFSCatInfoContentMod | kFSCatInfoAttrMod), - /* set everything possible except for mod dates */ - kSetCatinformationMask = kFSCatInfoSettableInfo & - ~(kFSCatInfoContentMod | kFSCatInfoAttrMod) - }; - - OSErr result; - GetVolParmsInfoBuffer volParmsInfo; - UInt32 infoSize; - FSCatalogInfo sourceCatalogInfo; /* source file's catalog information */ - FSCatalogInfo destCatalogInfo; /* destination file's catalog information */ - HFSUniStr255 sourceName; /* source file's Unicode name */ - HFSUniStr255 destName; /* destination file's Unicode name */ - FSRef sourceCurrentRef; /* FSRef to current location of source file throughout this function */ - FSRef destCurrentRef; /* FSRef to current location of destination file throughout this function */ - FSRef sourceParentRef; /* FSRef to parent directory of source file */ - FSRef destParentRef; /* FSRef to parent directory of destination file */ - HFSUniStr255 sourceUniqueName; /* unique name given to source file while exchanging it with destination */ - HFSUniStr255 destUniqueName; /* unique name given to destination file while exchanging it with source */ - long theSeed; /* the seed for generating unique names */ - Boolean sameParentDirs; /* true if source and destinatin parent directory is the same */ - - /* check parameters */ - require_action((NULL != newSourceRef) && (NULL != newDestRef), BadParameter, result = paramErr); - - /* output refs and current refs = input refs to start with */ - BlockMoveData(sourceRef, newSourceRef, sizeof(FSRef)); - BlockMoveData(sourceRef, &sourceCurrentRef, sizeof(FSRef)); - - BlockMoveData(destRef, newDestRef, sizeof(FSRef)); - BlockMoveData(destRef, &destCurrentRef, sizeof(FSRef)); - - /* get source volume's vRefNum */ - result = FSGetCatalogInfo(&sourceCurrentRef, kFSCatInfoVolume, &sourceCatalogInfo, NULL, NULL, NULL); - require_noerr(result, DetermineSourceVRefNumFailed); - - /* see if that volume supports FSExchangeObjects */ - result = FSGetVolParms(sourceCatalogInfo.volume, sizeof(GetVolParmsInfoBuffer), - &volParmsInfo, &infoSize); - if ( (noErr == result) && VolSupportsFSExchangeObjects(&volParmsInfo) ) - { - /* yes - use FSExchangeObjects */ - result = FSExchangeObjects(sourceRef, destRef); - } - else - { - /* no - emulate FSExchangeObjects */ - - /* Note: The compatibility case won't work for files with *Btree control blocks. */ - /* Right now the only *Btree files are created by the system. */ - - /* get all catalog information and Unicode names for each file */ - result = FSGetCatalogInfo(&sourceCurrentRef, kGetCatInformationMask, &sourceCatalogInfo, &sourceName, NULL, &sourceParentRef); - require_noerr(result, SourceFSGetCatalogInfoFailed); - - result = FSGetCatalogInfo(&destCurrentRef, kGetCatInformationMask, &destCatalogInfo, &destName, NULL, &destParentRef); - require_noerr(result, DestFSGetCatalogInfoFailed); - - /* make sure source and destination are on same volume */ - require_action(sourceCatalogInfo.volume == destCatalogInfo.volume, NotSameVolume, result = diffVolErr); - - /* make sure both files are *really* files */ - require_action((0 == (sourceCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask)) && - (0 == (destCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask)), NotAFile, result = notAFileErr); - - /* generate 2 names that are unique in both directories */ - theSeed = 0x4a696d4c; /* a fine unlikely filename */ - - result = GenerateUniqueHFSUniStr(&theSeed, &sourceParentRef, &destParentRef, &sourceUniqueName); - require_noerr(result, GenerateUniqueHFSUniStr1Failed); - - result = GenerateUniqueHFSUniStr(&theSeed, &sourceParentRef, &destParentRef, &destUniqueName); - require_noerr(result, GenerateUniqueHFSUniStr2Failed); - - /* rename sourceCurrentRef to sourceUniqueName */ - result = FSRenameUnicode(&sourceCurrentRef, sourceUniqueName.length, sourceUniqueName.unicode, kTextEncodingUnknown, newSourceRef); - require_noerr(result, FSRenameUnicode1Failed); - BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); - - /* rename destCurrentRef to destUniqueName */ - result = FSRenameUnicode(&destCurrentRef, destUniqueName.length, destUniqueName.unicode, kTextEncodingUnknown, newDestRef); - require_noerr(result, FSRenameUnicode2Failed); - BlockMoveData(newDestRef, &destCurrentRef, sizeof(FSRef)); - - /* are the source and destination parent directories the same? */ - sameParentDirs = ( sourceCatalogInfo.parentDirID == destCatalogInfo.parentDirID ); - if ( !sameParentDirs ) - { - /* move source file to dest parent directory */ - result = FSMoveObject(&sourceCurrentRef, &destParentRef, newSourceRef); - require_noerr(result, FSMoveObject1Failed); - BlockMoveData(new... [truncated message content] |
|
From: <cre...@us...> - 2006-03-28 03:46:52
|
Revision: 1162 Author: creecode Date: 2006-03-27 19:46:47 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1162&view=rev Log Message: ----------- Added Paths: ----------- Frontier/trunk/Common/MoreFilesX/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <set...@us...> - 2006-03-27 23:19:47
|
Revision: 1161 Author: sethdill Date: 2006-03-27 15:19:43 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1161&view=rev Log Message: ----------- Use GetAvailableWindowPositioningBounds to get the available screen space. Takes both menubar and the dock into account, so I also removed the menubar code. See RFE #1439984 on sourceforge. Modified Paths: -------------- Frontier/trunk/Common/source/quickdraw.c Modified: Frontier/trunk/Common/source/quickdraw.c =================================================================== --- Frontier/trunk/Common/source/quickdraw.c 2006-03-27 19:10:49 UTC (rev 1160) +++ Frontier/trunk/Common/source/quickdraw.c 2006-03-27 23:19:43 UTC (rev 1161) @@ -1229,8 +1229,11 @@ *r = screenBits.bounds; /*default return value, if no window open, or error*/ + /* commenting this out because we don't run on systems without color quickdraw anyway */ + /* if (!havecolorquickdraw ()) goto exit; + */ hdevice = GetDeviceList (); /*start with the first graphics device*/ @@ -1240,12 +1243,14 @@ if (hmost != nil) { - *r = (**hmost).gdRect; - - flmenubar = hmost == GetMainDevice (); + /* + 2006-03-27 SMD - let the OS tell us about the available bounds + this handles the menubar, the dock, and anything else the system knows about + */ + GetAvailableWindowPositioningBounds (hmost, r); } - goto exit; + break; /* exit the while loop */ } if (((**hdevice).gdFlags | (1 << screenActive)) != 0) { /*screen is active*/ @@ -1266,10 +1271,6 @@ hdevice = GetNextDevice (hdevice); /*advance to next device in list*/ } /*while*/ - exit: - - if (flmenubar) - (*r).top += getmenubarheight (); #endif #ifdef WIN95VERSION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-27 19:11:01
|
Revision: 1160 Author: andreradke Date: 2006-03-27 11:10:49 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1160&view=rev Log Message: ----------- Switch additional library paths for linker in Xcode project from absolute to relative, fixing revision 1158. ViewCVS Links: ------------- http://svn.sourceforge.net/frontierkernel/?rev=1158&view=rev Modified Paths: -------------- Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj Modified: Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-27 18:41:32
|
Revision: 1159 Author: andreradke Date: 2006-03-27 10:41:14 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1159&view=rev Log Message: ----------- In postlinking.sh and the associated shell script build phase of the Xcode project, deal with the possibility that the path to the working copy might contain whitespace. Modified Paths: -------------- Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj Frontier/trunk/build_XCode/tools/postlinking.sh Modified: Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj =================================================================== (Binary files differ) Modified: Frontier/trunk/build_XCode/tools/postlinking.sh =================================================================== --- Frontier/trunk/build_XCode/tools/postlinking.sh 2006-03-27 18:15:00 UTC (rev 1158) +++ Frontier/trunk/build_XCode/tools/postlinking.sh 2006-03-27 18:41:14 UTC (rev 1159) @@ -25,32 +25,29 @@ # go to tools directory currdir=`pwd` -cd ${SRCROOT}/tools/ +cd "${SRCROOT}/tools/" # pick up preprocessor definitions from target settings, e.g. "PIKE=1" preprocessor_defs=`echo ${GCC_PREPROCESSOR_DEFINITIONS} | sed -e "s/[A-Z0-9_][A-Z0-9_=]*/-D&/g"` -# collect compiler flags in one string for readability -cflags="${preprocessor_defs} -I${SRCROOT}/../Common/headers" - # set environment variable to stop cc from complaining export MACOSX_DEPLOYMENT_TARGET="10.1" # extract the APP_VERSION_STRING -cc ${cflags} -o appversion appversion.c +cc ${preprocessor_defs} -I"${SRCROOT}/../Common/headers" -o appversion appversion.c version_str=`./appversion` echo "Using version string: ${version_str}" # extract the copyright_year_string -cc ${cflags} -o appcopyright appcopyright.c +cc ${preprocessor_defs} -I"${SRCROOT}/../Common/headers" -o appcopyright appcopyright.c copyright_str=`./appcopyright` echo "Using copyright string: ${copyright_str}" # clean up -rm appversion appcopyright +rm -f appversion appcopyright # revert to previous working directory -cd ${currdir} +cd "${currdir}" ################################################## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-27 18:15:19
|
Revision: 1158 Author: andreradke Date: 2006-03-27 10:15:00 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1158&view=rev Log Message: ----------- Fix linker error about outdated table of contents for libpaigemacho.a by making a copy of the library, running ranlib on the copy, and linking with the copy instead of the original. Also ignore the copy in svn operations to prevent fake commits. Modified Paths: -------------- Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj Property Changed: ---------------- Frontier/trunk/build_XCode/tools/ Modified: Frontier/trunk/build_XCode/Frontier.xcode/project.pbxproj =================================================================== (Binary files differ) Property changes on: Frontier/trunk/build_XCode/tools ___________________________________________________________________ Name: svn:ignore + libpaigemacho.a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <set...@us...> - 2006-03-27 00:26:31
|
Revision: 1157 Author: sethdill Date: 2006-03-26 16:26:26 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1157&view=rev Log Message: ----------- Fix for sourceforge bug #1457286. op.xmlToOutline no longer crashes with an assertion failure when the OPML's <head> is an empty element. Also, if <head> is missing entirely then it throws a script error. Modified Paths: -------------- Frontier/trunk/Common/source/opxml.c Modified: Frontier/trunk/Common/source/opxml.c =================================================================== --- Frontier/trunk/Common/source/opxml.c 2006-03-25 19:26:00 UTC (rev 1156) +++ Frontier/trunk/Common/source/opxml.c 2006-03-27 00:26:26 UTC (rev 1157) @@ -331,15 +331,19 @@ disablelangerror (); - flheadfound = opxmlfindtableitem (htopmldocument, STR_head, &hthead); + flheadfound = opxmlheadexists (htopmldocument); /* 2006-03-26 SMD - this used to call opxmlfindtableitem, which was a problem when the head element was empty */ if (flnewoutline && flheadfound) { + + if (opxmlfindtableitem (htopmldocument, STR_head, &hthead)) { - oppushoutline (ho); + oppushoutline (ho); + + opxmlsetwindowatts (hthead, ho, hto, bso, vo); /*set window attributes*/ + + oppopoutline (); + } - opxmlsetwindowatts (hthead, ho, hto, bso, vo); /*set window attributes*/ - - oppopoutline (); } /*if*/ enablelangerror (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:26:09
|
Revision: 1156 Author: andreradke Date: 2006-03-25 11:26:00 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1156&view=rev Log Message: ----------- Remove erroneously committed tag Removed Paths: ------------- ODBs/branches/frontierRoot-initial/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:23:06
|
Revision: 1155 Author: andreradke Date: 2006-03-25 11:22:46 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1155&view=rev Log Message: ----------- Tagging initial mainResponderWebsites.root Added Paths: ----------- ODBs/tags/mainResponderWebsitesRoot-initial/ Copied: ODBs/tags/mainResponderWebsitesRoot-initial (from rev 1045, ODBs/trunk/mainResponderWebsitesRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:20:58
|
Revision: 1154 Author: andreradke Date: 2006-03-25 11:20:43 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1154&view=rev Log Message: ----------- Tagging initial prefs.root Added Paths: ----------- ODBs/tags/prefsRoot-initial/ Copied: ODBs/tags/prefsRoot-initial (from rev 701, ODBs/trunk/prefsRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:19:19
|
Revision: 1153 Author: andreradke Date: 2006-03-25 11:18:57 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1153&view=rev Log Message: ----------- Tagging initial mainResponder.root Added Paths: ----------- ODBs/tags/mainResponderRoot-initial/ Copied: ODBs/tags/mainResponderRoot-initial (from rev 650, ODBs/trunk/mainResponderRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:17:03
|
Revision: 1152 Author: andreradke Date: 2006-03-25 11:16:11 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1152&view=rev Log Message: ----------- Tagging frontierRoot-initial Added Paths: ----------- ODBs/tags/frontierRoot-initial/ Copied: ODBs/tags/frontierRoot-initial (from rev 649, ODBs/trunk/frontierRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 19:15:43
|
Revision: 1151 Author: andreradke Date: 2006-03-25 11:14:55 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1151&view=rev Log Message: ----------- Tagging frontierRoot-initial Added Paths: ----------- ODBs/branches/frontierRoot-initial/ Copied: ODBs/branches/frontierRoot-initial (from rev 649, ODBs/trunk/frontierRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 18:52:00
|
Revision: 1150 Author: andreradke Date: 2006-03-25 10:51:33 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1150&view=rev Log Message: ----------- Bringing sqlite-source-3.3.4 into the SQLite branch Added Paths: ----------- Frontier/branches/SQLite/Common/sqlite3/ Copied: Frontier/branches/SQLite/Common/sqlite3 (from rev 1149, Frontier/vendor/sqlite3/current) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 18:49:14
|
Revision: 1149 Author: andreradke Date: 2006-03-25 10:48:56 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1149&view=rev Log Message: ----------- Tagging sqlite-source-3.3.4 Added Paths: ----------- Frontier/vendor/sqlite3/sqlite-source-3.3.4/ Copied: Frontier/vendor/sqlite3/sqlite-source-3.3.4 (from rev 1148, Frontier/vendor/sqlite3/current) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 18:45:40
|
Revision: 1148 Author: andreradke Date: 2006-03-25 10:43:10 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1148&view=rev Log Message: ----------- Importing initial SQLite vendor drop Added Paths: ----------- Frontier/vendor/sqlite3/current/ Frontier/vendor/sqlite3/current/alter.c Frontier/vendor/sqlite3/current/analyze.c Frontier/vendor/sqlite3/current/attach.c Frontier/vendor/sqlite3/current/auth.c Frontier/vendor/sqlite3/current/btree.c Frontier/vendor/sqlite3/current/btree.h Frontier/vendor/sqlite3/current/build.c Frontier/vendor/sqlite3/current/callback.c Frontier/vendor/sqlite3/current/complete.c Frontier/vendor/sqlite3/current/date.c Frontier/vendor/sqlite3/current/delete.c Frontier/vendor/sqlite3/current/expr.c Frontier/vendor/sqlite3/current/func.c Frontier/vendor/sqlite3/current/hash.c Frontier/vendor/sqlite3/current/hash.h Frontier/vendor/sqlite3/current/insert.c Frontier/vendor/sqlite3/current/keywordhash.h Frontier/vendor/sqlite3/current/legacy.c Frontier/vendor/sqlite3/current/main.c Frontier/vendor/sqlite3/current/opcodes.c Frontier/vendor/sqlite3/current/opcodes.h Frontier/vendor/sqlite3/current/os.c Frontier/vendor/sqlite3/current/os.h Frontier/vendor/sqlite3/current/os_common.h Frontier/vendor/sqlite3/current/os_unix.c Frontier/vendor/sqlite3/current/os_win.c Frontier/vendor/sqlite3/current/pager.c Frontier/vendor/sqlite3/current/pager.h Frontier/vendor/sqlite3/current/parse.c Frontier/vendor/sqlite3/current/parse.h Frontier/vendor/sqlite3/current/pragma.c Frontier/vendor/sqlite3/current/prepare.c Frontier/vendor/sqlite3/current/printf.c Frontier/vendor/sqlite3/current/random.c Frontier/vendor/sqlite3/current/select.c Frontier/vendor/sqlite3/current/shell.c Frontier/vendor/sqlite3/current/sqlite3.def Frontier/vendor/sqlite3/current/sqlite3.h Frontier/vendor/sqlite3/current/sqliteInt.h Frontier/vendor/sqlite3/current/table.c Frontier/vendor/sqlite3/current/tclsqlite.c Frontier/vendor/sqlite3/current/tokenize.c Frontier/vendor/sqlite3/current/trigger.c Frontier/vendor/sqlite3/current/update.c Frontier/vendor/sqlite3/current/utf.c Frontier/vendor/sqlite3/current/util.c Frontier/vendor/sqlite3/current/vacuum.c Frontier/vendor/sqlite3/current/vdbe.c Frontier/vendor/sqlite3/current/vdbe.h Frontier/vendor/sqlite3/current/vdbeInt.h Frontier/vendor/sqlite3/current/vdbeapi.c Frontier/vendor/sqlite3/current/vdbeaux.c Frontier/vendor/sqlite3/current/vdbefifo.c Frontier/vendor/sqlite3/current/vdbemem.c Frontier/vendor/sqlite3/current/where.c Added: Frontier/vendor/sqlite3/current/alter.c =================================================================== --- Frontier/vendor/sqlite3/current/alter.c (rev 0) +++ Frontier/vendor/sqlite3/current/alter.c 2006-03-25 18:43:10 UTC (rev 1148) @@ -0,0 +1,562 @@ +/* +** 2005 February 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that used to generate VDBE code +** that implements the ALTER TABLE command. +** +** $Id: alter.c,v 1.20 2006/02/09 02:56:03 drh Exp $ +*/ +#include "sqliteInt.h" +#include <ctype.h> + +/* +** The code in this file only exists if we are not omitting the +** ALTER TABLE logic from the build. +*/ +#ifndef SQLITE_OMIT_ALTERTABLE + + +/* +** This function is used by SQL generated to implement the +** ALTER TABLE command. The first argument is the text of a CREATE TABLE or +** CREATE INDEX command. The second is a table name. The table name in +** the CREATE TABLE or CREATE INDEX statement is replaced with the second +** argument and the result returned. Examples: +** +** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') +** -> 'CREATE TABLE def(a, b, c)' +** +** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') +** -> 'CREATE INDEX i ON def(a, b, c)' +*/ +static void renameTableFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + unsigned char const *zSql = sqlite3_value_text(argv[0]); + unsigned char const *zTableName = sqlite3_value_text(argv[1]); + + int token; + Token tname; + unsigned char const *zCsr = zSql; + int len = 0; + char *zRet; + + /* The principle used to locate the table name in the CREATE TABLE + ** statement is that the table name is the first token that is immediatedly + ** followed by a left parenthesis - TK_LP. + */ + if( zSql ){ + do { + /* Store the token that zCsr points to in tname. */ + tname.z = zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and it's length in 'len' (to be used next iteration of this loop). + */ + do { + zCsr += len; + len = sqlite3GetToken(zCsr, &token); + } while( token==TK_SPACE ); + assert( len>0 ); + } while( token!=TK_LP ); + + zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql, + zTableName, tname.z+tname.n); + sqlite3_result_text(context, zRet, -1, sqlite3FreeX); + } +} + +#ifndef SQLITE_OMIT_TRIGGER +/* This function is used by SQL generated to implement the ALTER TABLE +** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER +** statement. The second is a table name. The table name in the CREATE +** TRIGGER statement is replaced with the second argument and the result +** returned. This is analagous to renameTableFunc() above, except for CREATE +** TRIGGER, not CREATE INDEX and CREATE TABLE. +*/ +static void renameTriggerFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + unsigned char const *zSql = sqlite3_value_text(argv[0]); + unsigned char const *zTableName = sqlite3_value_text(argv[1]); + + int token; + Token tname; + int dist = 3; + unsigned char const *zCsr = zSql; + int len = 0; + char *zRet; + + /* The principle used to locate the table name in the CREATE TRIGGER + ** statement is that the table name is the first token that is immediatedly + ** preceded by either TK_ON or TK_DOT and immediatedly followed by one + ** of TK_WHEN, TK_BEGIN or TK_FOR. + */ + if( zSql ){ + do { + /* Store the token that zCsr points to in tname. */ + tname.z = zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and it's length in 'len' (to be used next iteration of this loop). + */ + do { + zCsr += len; + len = sqlite3GetToken(zCsr, &token); + }while( token==TK_SPACE ); + assert( len>0 ); + + /* Variable 'dist' stores the number of tokens read since the most + ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN + ** token is read and 'dist' equals 2, the condition stated above + ** to be met. + ** + ** Note that ON cannot be a database, table or column name, so + ** there is no need to worry about syntax like + ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc. + */ + dist++; + if( token==TK_DOT || token==TK_ON ){ + dist = 0; + } + } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) ); + + /* Variable tname now contains the token that is the old table-name + ** in the CREATE TRIGGER statement. + */ + zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql, + zTableName, tname.z+tname.n); + sqlite3_result_text(context, zRet, -1, sqlite3FreeX); + } +} +#endif /* !SQLITE_OMIT_TRIGGER */ + +/* +** Register built-in functions used to help implement ALTER TABLE +*/ +void sqlite3AlterFunctions(sqlite3 *db){ + static const struct { + char *zName; + signed char nArg; + void (*xFunc)(sqlite3_context*,int,sqlite3_value **); + } aFuncs[] = { + { "sqlite_rename_table", 2, renameTableFunc}, +#ifndef SQLITE_OMIT_TRIGGER + { "sqlite_rename_trigger", 2, renameTriggerFunc}, +#endif + }; + int i; + + for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){ + sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg, + SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0); + } +} + +/* +** Generate the text of a WHERE expression which can be used to select all +** temporary triggers on table pTab from the sqlite_temp_master table. If +** table pTab has no temporary triggers, or is itself stored in the +** temporary database, NULL is returned. +*/ +static char *whereTempTriggers(Parse *pParse, Table *pTab){ + Trigger *pTrig; + char *zWhere = 0; + char *tmp = 0; + const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */ + + /* If the table is not located in the temp-db (in which case NULL is + ** returned, loop through the tables list of triggers. For each trigger + ** that is not part of the temp-db schema, add a clause to the WHERE + ** expression being built up in zWhere. + */ + if( pTab->pSchema!=pTempSchema ){ + for( pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext ){ + if( pTrig->pSchema==pTempSchema ){ + if( !zWhere ){ + zWhere = sqlite3MPrintf("name=%Q", pTrig->name); + }else{ + tmp = zWhere; + zWhere = sqlite3MPrintf("%s OR name=%Q", zWhere, pTrig->name); + sqliteFree(tmp); + } + } + } + } + return zWhere; +} + +/* +** Generate code to drop and reload the internal representation of table +** pTab from the database, including triggers and temporary triggers. +** Argument zName is the name of the table in the database schema at +** the time the generated code is executed. This can be different from +** pTab->zName if this function is being called to code part of an +** "ALTER TABLE RENAME TO" statement. +*/ +static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){ + Vdbe *v; + char *zWhere; + int iDb; /* Index of database containing pTab */ +#ifndef SQLITE_OMIT_TRIGGER + Trigger *pTrig; +#endif + + v = sqlite3GetVdbe(pParse); + if( !v ) return; + iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + assert( iDb>=0 ); + +#ifndef SQLITE_OMIT_TRIGGER + /* Drop any table triggers from the internal schema. */ + for(pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext){ + int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema); + assert( iTrigDb==iDb || iTrigDb==1 ); + sqlite3VdbeOp3(v, OP_DropTrigger, iTrigDb, 0, pTrig->name, 0); + } +#endif + + /* Drop the table and index from the internal schema */ + sqlite3VdbeOp3(v, OP_DropTable, iDb, 0, pTab->zName, 0); + + /* Reload the table, index and permanent trigger schemas. */ + zWhere = sqlite3MPrintf("tbl_name=%Q", zName); + if( !zWhere ) return; + sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0, zWhere, P3_DYNAMIC); + +#ifndef SQLITE_OMIT_TRIGGER + /* Now, if the table is not stored in the temp database, reload any temp + ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. + */ + if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){ + sqlite3VdbeOp3(v, OP_ParseSchema, 1, 0, zWhere, P3_DYNAMIC); + } +#endif +} + +/* +** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" +** command. +*/ +void sqlite3AlterRenameTable( + Parse *pParse, /* Parser context. */ + SrcList *pSrc, /* The table to rename. */ + Token *pName /* The new table name. */ +){ + int iDb; /* Database that contains the table */ + char *zDb; /* Name of database iDb */ + Table *pTab; /* Table being renamed */ + char *zName = 0; /* NULL-terminated version of pName */ + sqlite3 *db = pParse->db; /* Database connection */ + Vdbe *v; +#ifndef SQLITE_OMIT_TRIGGER + char *zWhere = 0; /* Where clause to locate temp triggers */ +#endif + + if( sqlite3MallocFailed() ) goto exit_rename_table; + assert( pSrc->nSrc==1 ); + + pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase); + if( !pTab ) goto exit_rename_table; + iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + zDb = db->aDb[iDb].zName; + + /* Get a NULL terminated version of the new table name. */ + zName = sqlite3NameFromToken(pName); + if( !zName ) goto exit_rename_table; + + /* Check that a table or index named 'zName' does not already exist + ** in database iDb. If so, this is an error. + */ + if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){ + sqlite3ErrorMsg(pParse, + "there is already another table or index with this name: %s", zName); + goto exit_rename_table; + } + + /* Make sure it is not a system table being altered, or a reserved name + ** that the table is being renamed to. + */ + if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){ + sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName); + goto exit_rename_table; + } + if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ + goto exit_rename_table; + } + +#ifndef SQLITE_OMIT_AUTHORIZATION + /* Invoke the authorization callback. */ + if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ + goto exit_rename_table; + } +#endif + + /* Begin a transaction and code the VerifyCookie for database iDb. + ** Then modify the schema cookie (since the ALTER TABLE modifies the + ** schema). + */ + v = sqlite3GetVdbe(pParse); + if( v==0 ){ + goto exit_rename_table; + } + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3ChangeCookie(db, v, iDb); + + /* Modify the sqlite_master table to use the new table name. */ + sqlite3NestedParse(pParse, + "UPDATE %Q.%s SET " +#ifdef SQLITE_OMIT_TRIGGER + "sql = sqlite_rename_table(sql, %Q), " +#else + "sql = CASE " + "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" + "ELSE sqlite_rename_table(sql, %Q) END, " +#endif + "tbl_name = %Q, " + "name = CASE " + "WHEN type='table' THEN %Q " + "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " + "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) " + "ELSE name END " + "WHERE tbl_name=%Q AND " + "(type='table' OR type='index' OR type='trigger');", + zDb, SCHEMA_TABLE(iDb), zName, zName, zName, +#ifndef SQLITE_OMIT_TRIGGER + zName, +#endif + zName, strlen(pTab->zName), pTab->zName + ); + +#ifndef SQLITE_OMIT_AUTOINCREMENT + /* If the sqlite_sequence table exists in this database, then update + ** it with the new table name. + */ + if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){ + sqlite3NestedParse(pParse, + "UPDATE %Q.sqlite_sequence set name = %Q WHERE name = %Q", + zDb, zName, pTab->zName); + } +#endif + +#ifndef SQLITE_OMIT_TRIGGER + /* If there are TEMP triggers on this table, modify the sqlite_temp_master + ** table. Don't do this if the table being ALTERed is itself located in + ** the temp database. + */ + if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){ + sqlite3NestedParse(pParse, + "UPDATE sqlite_temp_master SET " + "sql = sqlite_rename_trigger(sql, %Q), " + "tbl_name = %Q " + "WHERE %s;", zName, zName, zWhere); + sqliteFree(zWhere); + } +#endif + + /* Drop and reload the internal table schema. */ + reloadTableSchema(pParse, pTab, zName); + +exit_rename_table: + sqlite3SrcListDelete(pSrc); + sqliteFree(zName); +} + + +/* +** This function is called after an "ALTER TABLE ... ADD" statement +** has been parsed. Argument pColDef contains the text of the new +** column definition. +** +** The Table structure pParse->pNewTable was extended to include +** the new column during parsing. +*/ +void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ + Table *pNew; /* Copy of pParse->pNewTable */ + Table *pTab; /* Table being altered */ + int iDb; /* Database number */ + const char *zDb; /* Database name */ + const char *zTab; /* Table name */ + char *zCol; /* Null-terminated column definition */ + Column *pCol; /* The new column */ + Expr *pDflt; /* Default value for the new column */ + + if( pParse->nErr ) return; + pNew = pParse->pNewTable; + assert( pNew ); + + iDb = sqlite3SchemaToIndex(pParse->db, pNew->pSchema); + zDb = pParse->db->aDb[iDb].zName; + zTab = pNew->zName; + pCol = &pNew->aCol[pNew->nCol-1]; + pDflt = pCol->pDflt; + pTab = sqlite3FindTable(pParse->db, zTab, zDb); + assert( pTab ); + +#ifndef SQLITE_OMIT_AUTHORIZATION + /* Invoke the authorization callback. */ + if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ + return; + } +#endif + + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + if( pDflt && pDflt->op==TK_NULL ){ + pDflt = 0; + } + + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if( pCol->isPrimKey ){ + sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column"); + return; + } + if( pNew->pIndex ){ + sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column"); + return; + } + if( pCol->notNull && !pDflt ){ + sqlite3ErrorMsg(pParse, + "Cannot add a NOT NULL column with default value NULL"); + return; + } + + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if( pDflt ){ + sqlite3_value *pVal; + if( sqlite3ValueFromExpr(pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){ + /* malloc() has failed */ + return; + } + if( !pVal ){ + sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default"); + return; + } + sqlite3ValueFree(pVal); + } + + /* Modify the CREATE TABLE statement. */ + zCol = sqliteStrNDup((char*)pColDef->z, pColDef->n); + if( zCol ){ + char *zEnd = &zCol[pColDef->n-1]; + while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){ + *zEnd-- = '\0'; + } + sqlite3NestedParse(pParse, + "UPDATE %Q.%s SET " + "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d,length(sql)) " + "WHERE type = 'table' AND name = %Q", + zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1, + zTab + ); + sqliteFree(zCol); + } + + /* If the default value of the new column is NULL, then set the file + ** format to 2. If the default value of the new column is not NULL, + ** the file format becomes 3. + */ + sqlite3MinimumFileFormat(pParse, iDb, pDflt ? 3 : 2); + + /* Reload the schema of the modified table. */ + reloadTableSchema(pParse, pTab, pTab->zName); +} + +/* +** This function is called by the parser after the table-name in +** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument +** pSrc is the full-name of the table being altered. +** +** This routine makes a (partial) copy of the Table structure +** for the table being altered and sets Parse.pNewTable to point +** to it. Routines called by the parser as the column definition +** is parsed (i.e. sqlite3AddColumn()) add the new Column data to +** the copy. The copy of the Table structure is deleted by tokenize.c +** after parsing is finished. +** +** Routine sqlite3AlterFinishAddColumn() will be called to complete +** coding the "ALTER TABLE ... ADD" statement. +*/ +void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ + Table *pNew; + Table *pTab; + Vdbe *v; + int iDb; + int i; + int nAlloc; + + /* Look up the table being altered. */ + assert( pParse->pNewTable==0 ); + if( sqlite3MallocFailed() ) goto exit_begin_add_column; + pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase); + if( !pTab ) goto exit_begin_add_column; + + /* Make sure this is not an attempt to ALTER a view. */ + if( pTab->pSelect ){ + sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); + goto exit_begin_add_column; + } + + assert( pTab->addColOffset>0 ); + iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + + /* Put a copy of the Table struct in Parse.pNewTable for the + ** sqlite3AddColumn() function and friends to modify. + */ + pNew = (Table *)sqliteMalloc(sizeof(Table)); + if( !pNew ) goto exit_begin_add_column; + pParse->pNewTable = pNew; + pNew->nRef = 1; + pNew->nCol = pTab->nCol; + assert( pNew->nCol>0 ); + nAlloc = (((pNew->nCol-1)/8)*8)+8; + assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 ); + pNew->aCol = (Column *)sqliteMalloc(sizeof(Column)*nAlloc); + pNew->zName = sqliteStrDup(pTab->zName); + if( !pNew->aCol || !pNew->zName ){ + goto exit_begin_add_column; + } + memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol); + for(i=0; i<pNew->nCol; i++){ + Column *pCol = &pNew->aCol[i]; + pCol->zName = sqliteStrDup(pCol->zName); + pCol->zColl = 0; + pCol->zType = 0; + pCol->pDflt = 0; + } + pNew->pSchema = pParse->db->aDb[iDb].pSchema; + pNew->addColOffset = pTab->addColOffset; + pNew->nRef = 1; + + /* Begin a transaction and increment the schema cookie. */ + sqlite3BeginWriteOperation(pParse, 0, iDb); + v = sqlite3GetVdbe(pParse); + if( !v ) goto exit_begin_add_column; + sqlite3ChangeCookie(pParse->db, v, iDb); + +exit_begin_add_column: + sqlite3SrcListDelete(pSrc); + return; +} +#endif /* SQLITE_ALTER_TABLE */ Property changes on: Frontier/vendor/sqlite3/current/alter.c ___________________________________________________________________ Name: svn:eol-style + native Added: Frontier/vendor/sqlite3/current/analyze.c =================================================================== --- Frontier/vendor/sqlite3/current/analyze.c (rev 0) +++ Frontier/vendor/sqlite3/current/analyze.c 2006-03-25 18:43:10 UTC (rev 1148) @@ -0,0 +1,403 @@ +/* +** 2005 July 8 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code associated with the ANALYZE command. +** +** @(#) $Id: analyze.c,v 1.16 2006/01/10 17:58:23 danielk1977 Exp $ +*/ +#ifndef SQLITE_OMIT_ANALYZE +#include "sqliteInt.h" + +/* +** This routine generates code that opens the sqlite_stat1 table on cursor +** iStatCur. +** +** If the sqlite_stat1 tables does not previously exist, it is created. +** If it does previously exist, all entires associated with table zWhere +** are removed. If zWhere==0 then all entries are removed. +*/ +static void openStatTable( + Parse *pParse, /* Parsing context */ + int iDb, /* The database we are looking in */ + int iStatCur, /* Open the sqlite_stat1 table on this cursor */ + const char *zWhere /* Delete entries associated with this table */ +){ + sqlite3 *db = pParse->db; + Db *pDb; + int iRootPage; + Table *pStat; + Vdbe *v = sqlite3GetVdbe(pParse); + + pDb = &db->aDb[iDb]; + if( (pStat = sqlite3FindTable(db, "sqlite_stat1", pDb->zName))==0 ){ + /* The sqlite_stat1 tables does not exist. Create it. + ** Note that a side-effect of the CREATE TABLE statement is to leave + ** the rootpage of the new table on the top of the stack. This is + ** important because the OpenWrite opcode below will be needing it. */ + sqlite3NestedParse(pParse, + "CREATE TABLE %Q.sqlite_stat1(tbl,idx,stat)", + pDb->zName + ); + iRootPage = 0; /* Cause rootpage to be taken from top of stack */ + }else if( zWhere ){ + /* The sqlite_stat1 table exists. Delete all entries associated with + ** the table zWhere. */ + sqlite3NestedParse(pParse, + "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", + pDb->zName, zWhere + ); + iRootPage = pStat->tnum; + }else{ + /* The sqlite_stat1 table already exists. Delete all rows. */ + iRootPage = pStat->tnum; + sqlite3VdbeAddOp(v, OP_Clear, pStat->tnum, iDb); + } + + /* Open the sqlite_stat1 table for writing. Unless it was created + ** by this vdbe program, lock it for writing at the shared-cache level. + ** If this vdbe did create the sqlite_stat1 table, then it must have + ** already obtained a schema-lock, making the write-lock redundant. + */ + if( iRootPage>0 ){ + sqlite3TableLock(pParse, iDb, iRootPage, 1, "sqlite_stat1"); + } + sqlite3VdbeAddOp(v, OP_Integer, iDb, 0); + sqlite3VdbeAddOp(v, OP_OpenWrite, iStatCur, iRootPage); + sqlite3VdbeAddOp(v, OP_SetNumColumns, iStatCur, 3); +} + +/* +** Generate code to do an analysis of all indices associated with +** a single table. +*/ +static void analyzeOneTable( + Parse *pParse, /* Parser context */ + Table *pTab, /* Table whose indices are to be analyzed */ + int iStatCur, /* Cursor that writes to the sqlite_stat1 table */ + int iMem /* Available memory locations begin here */ +){ + Index *pIdx; /* An index to being analyzed */ + int iIdxCur; /* Cursor number for index being analyzed */ + int nCol; /* Number of columns in the index */ + Vdbe *v; /* The virtual machine being built up */ + int i; /* Loop counter */ + int topOfLoop; /* The top of the loop */ + int endOfLoop; /* The end of the loop */ + int addr; /* The address of an instruction */ + int iDb; /* Index of database containing pTab */ + + v = sqlite3GetVdbe(pParse); + if( pTab==0 || pTab->pIndex==0 ){ + /* Do no analysis for tables that have no indices */ + return; + } + + iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + assert( iDb>=0 ); +#ifndef SQLITE_OMIT_AUTHORIZATION + if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0, + pParse->db->aDb[iDb].zName ) ){ + return; + } +#endif + + /* Establish a read-lock on the table at the shared-cache level. */ + sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); + + iIdxCur = pParse->nTab; + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); + + /* Open a cursor to the index to be analyzed + */ + assert( iDb==sqlite3SchemaToIndex(pParse->db, pIdx->pSchema) ); + sqlite3VdbeAddOp(v, OP_Integer, iDb, 0); + VdbeComment((v, "# %s", pIdx->zName)); + sqlite3VdbeOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, + (char *)pKey, P3_KEYINFO_HANDOFF); + nCol = pIdx->nColumn; + if( iMem+nCol*2>=pParse->nMem ){ + pParse->nMem = iMem+nCol*2+1; + } + sqlite3VdbeAddOp(v, OP_SetNumColumns, iIdxCur, nCol+1); + + /* Memory cells are used as follows: + ** + ** mem[iMem]: The total number of rows in the table. + ** mem[iMem+1]: Number of distinct values in column 1 + ** ... + ** mem[iMem+nCol]: Number of distinct values in column N + ** mem[iMem+nCol+1] Last observed value of column 1 + ** ... + ** mem[iMem+nCol+nCol]: Last observed value of column N + ** + ** Cells iMem through iMem+nCol are initialized to 0. The others + ** are initialized to NULL. + */ + for(i=0; i<=nCol; i++){ + sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem+i); + } + for(i=0; i<nCol; i++){ + sqlite3VdbeAddOp(v, OP_MemNull, iMem+nCol+i+1, 0); + } + + /* Do the analysis. + */ + endOfLoop = sqlite3VdbeMakeLabel(v); + sqlite3VdbeAddOp(v, OP_Rewind, iIdxCur, endOfLoop); + topOfLoop = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp(v, OP_MemIncr, 1, iMem); + for(i=0; i<nCol; i++){ + sqlite3VdbeAddOp(v, OP_Column, iIdxCur, i); + sqlite3VdbeAddOp(v, OP_MemLoad, iMem+nCol+i+1, 0); + sqlite3VdbeAddOp(v, OP_Ne, 0x100, 0); + } + sqlite3VdbeAddOp(v, OP_Goto, 0, endOfLoop); + for(i=0; i<nCol; i++){ + addr = sqlite3VdbeAddOp(v, OP_MemIncr, 1, iMem+i+1); + sqlite3VdbeChangeP2(v, topOfLoop + 3*i + 3, addr); + sqlite3VdbeAddOp(v, OP_Column, iIdxCur, i); + sqlite3VdbeAddOp(v, OP_MemStore, iMem+nCol+i+1, 1); + } + sqlite3VdbeResolveLabel(v, endOfLoop); + sqlite3VdbeAddOp(v, OP_Next, iIdxCur, topOfLoop); + sqlite3VdbeAddOp(v, OP_Close, iIdxCur, 0); + + /* Store the results. + ** + ** The result is a single row of the sqlite_stmt1 table. The first + ** two columns are the names of the table and index. The third column + ** is a string composed of a list of integer statistics about the + ** index. The first integer in the list is the total number of entires + ** in the index. There is one additional integer in the list for each + ** column of the table. This additional integer is a guess of how many + ** rows of the table the index will select. If D is the count of distinct + ** values and K is the total number of rows, then the integer is computed + ** as: + ** + ** I = (K+D-1)/D + ** + ** If K==0 then no entry is made into the sqlite_stat1 table. + ** If K>0 then it is always the case the D>0 so division by zero + ** is never possible. + */ + sqlite3VdbeAddOp(v, OP_MemLoad, iMem, 0); + addr = sqlite3VdbeAddOp(v, OP_IfNot, 0, 0); + sqlite3VdbeAddOp(v, OP_NewRowid, iStatCur, 0); + sqlite3VdbeOp3(v, OP_String8, 0, 0, pTab->zName, 0); + sqlite3VdbeOp3(v, OP_String8, 0, 0, pIdx->zName, 0); + sqlite3VdbeAddOp(v, OP_MemLoad, iMem, 0); + sqlite3VdbeOp3(v, OP_String8, 0, 0, " ", 0); + for(i=0; i<nCol; i++){ + sqlite3VdbeAddOp(v, OP_MemLoad, iMem, 0); + sqlite3VdbeAddOp(v, OP_MemLoad, iMem+i+1, 0); + sqlite3VdbeAddOp(v, OP_Add, 0, 0); + sqlite3VdbeAddOp(v, OP_AddImm, -1, 0); + sqlite3VdbeAddOp(v, OP_MemLoad, iMem+i+1, 0); + sqlite3VdbeAddOp(v, OP_Divide, 0, 0); + sqlite3VdbeAddOp(v, OP_ToInt, 0, 0); + if( i==nCol-1 ){ + sqlite3VdbeAddOp(v, OP_Concat, nCol*2-1, 0); + }else{ + sqlite3VdbeAddOp(v, OP_Dup, 1, 0); + } + } + sqlite3VdbeOp3(v, OP_MakeRecord, 3, 0, "aaa", 0); + sqlite3VdbeAddOp(v, OP_Insert, iStatCur, 0); + sqlite3VdbeJumpHere(v, addr); + } +} + +/* +** Generate code that will cause the most recent index analysis to +** be laoded into internal hash tables where is can be used. +*/ +static void loadAnalysis(Parse *pParse, int iDb){ + Vdbe *v = sqlite3GetVdbe(pParse); + sqlite3VdbeAddOp(v, OP_LoadAnalysis, iDb, 0); +} + +/* +** Generate code that will do an analysis of an entire database +*/ +static void analyzeDatabase(Parse *pParse, int iDb){ + sqlite3 *db = pParse->db; + Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */ + HashElem *k; + int iStatCur; + int iMem; + + sqlite3BeginWriteOperation(pParse, 0, iDb); + iStatCur = pParse->nTab++; + openStatTable(pParse, iDb, iStatCur, 0); + iMem = pParse->nMem; + for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ + Table *pTab = (Table*)sqliteHashData(k); + analyzeOneTable(pParse, pTab, iStatCur, iMem); + } + loadAnalysis(pParse, iDb); +} + +/* +** Generate code that will do an analysis of a single table in +** a database. +*/ +static void analyzeTable(Parse *pParse, Table *pTab){ + int iDb; + int iStatCur; + + assert( pTab!=0 ); + iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + sqlite3BeginWriteOperation(pParse, 0, iDb); + iStatCur = pParse->nTab++; + openStatTable(pParse, iDb, iStatCur, pTab->zName); + analyzeOneTable(pParse, pTab, iStatCur, pParse->nMem); + loadAnalysis(pParse, iDb); +} + +/* +** Generate code for the ANALYZE command. The parser calls this routine +** when it recognizes an ANALYZE command. +** +** ANALYZE -- 1 +** ANALYZE <database> -- 2 +** ANALYZE ?<database>.?<tablename> -- 3 +** +** Form 1 causes all indices in all attached databases to be analyzed. +** Form 2 analyzes all indices the single database named. +** Form 3 analyzes all indices associated with the named table. +*/ +void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){ + sqlite3 *db = pParse->db; + int iDb; + int i; + char *z, *zDb; + Table *pTab; + Token *pTableName; + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ + return; + } + + if( pName1==0 ){ + /* Form 1: Analyze everything */ + for(i=0; i<db->nDb; i++){ + if( i==1 ) continue; /* Do not analyze the TEMP database */ + analyzeDatabase(pParse, i); + } + }else if( pName2==0 || pName2->n==0 ){ + /* Form 2: Analyze the database or table named */ + iDb = sqlite3FindDb(db, pName1); + if( iDb>=0 ){ + analyzeDatabase(pParse, iDb); + }else{ + z = sqlite3NameFromToken(pName1); + pTab = sqlite3LocateTable(pParse, z, 0); + sqliteFree(z); + if( pTab ){ + analyzeTable(pParse, pTab); + } + } + }else{ + /* Form 3: Analyze the fully qualified table name */ + iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName); + if( iDb>=0 ){ + zDb = db->aDb[iDb].zName; + z = sqlite3NameFromToken(pTableName); + pTab = sqlite3LocateTable(pParse, z, zDb); + sqliteFree(z); + if( pTab ){ + analyzeTable(pParse, pTab); + } + } + } +} + +/* +** Used to pass information from the analyzer reader through to the +** callback routine. +*/ +typedef struct analysisInfo analysisInfo; +struct analysisInfo { + sqlite3 *db; + const char *zDatabase; +}; + +/* +** This callback is invoked once for each index when reading the +** sqlite_stat1 table. +** +** argv[0] = name of the index +** argv[1] = results of analysis - on integer for each column +*/ +static int analysisLoader(void *pData, int argc, char **argv, char **azNotUsed){ + analysisInfo *pInfo = (analysisInfo*)pData; + Index *pIndex; + int i, c; + unsigned int v; + const char *z; + + assert( argc==2 ); + if( argv==0 || argv[0]==0 || argv[1]==0 ){ + return 0; + } + pIndex = sqlite3FindIndex(pInfo->db, argv[0], pInfo->zDatabase); + if( pIndex==0 ){ + return 0; + } + z = argv[1]; + for(i=0; *z && i<=pIndex->nColumn; i++){ + v = 0; + while( (c=z[0])>='0' && c<='9' ){ + v = v*10 + c - '0'; + z++; + } + pIndex->aiRowEst[i] = v; + if( *z==' ' ) z++; + } + return 0; +} + +/* +** Load the content of the sqlite_stat1 table into the index hash tables. +*/ +void sqlite3AnalysisLoad(sqlite3 *db, int iDb){ + analysisInfo sInfo; + HashElem *i; + char *zSql; + + /* Clear any prior statistics */ + for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ + Index *pIdx = sqliteHashData(i); + sqlite3DefaultRowEst(pIdx); + } + + /* Check to make sure the sqlite_stat1 table existss */ + sInfo.db = db; + sInfo.zDatabase = db->aDb[iDb].zName; + if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){ + return; + } + + + /* Load new statistics out of the sqlite_stat1 table */ + zSql = sqlite3MPrintf("SELECT idx, stat FROM %Q.sqlite_stat1", + sInfo.zDatabase); + sqlite3SafetyOff(db); + sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); + sqlite3SafetyOn(db); + sqliteFree(zSql); +} + + +#endif /* SQLITE_OMIT_ANALYZE */ Property changes on: Frontier/vendor/sqlite3/current/analyze.c ___________________________________________________________________ Name: svn:eol-style + native Added: Frontier/vendor/sqlite3/current/attach.c =================================================================== --- Frontier/vendor/sqlite3/current/attach.c (rev 0) +++ Frontier/vendor/sqlite3/current/attach.c 2006-03-25 18:43:10 UTC (rev 1148) @@ -0,0 +1,493 @@ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the ATTACH and DETACH commands. +** +** $Id: attach.c,v 1.49 2006/01/24 12:09:18 danielk1977 Exp $ +*/ +#include "sqliteInt.h" + +/* +** Resolve an expression that was part of an ATTACH or DETACH statement. This +** is slightly different from resolving a normal SQL expression, because simple +** identifiers are treated as strings, not possible column names or aliases. +** +** i.e. if the parser sees: +** +** ATTACH DATABASE abc AS def +** +** it treats the two expressions as literal strings 'abc' and 'def' instead of +** looking for columns of the same name. +** +** This only applies to the root node of pExpr, so the statement: +** +** ATTACH DATABASE abc||def AS 'db2' +** +** will fail because neither abc or def can be resolved. +*/ +static int resolveAttachExpr(NameContext *pName, Expr *pExpr) +{ + int rc = SQLITE_OK; + if( pExpr ){ + if( pExpr->op!=TK_ID ){ + rc = sqlite3ExprResolveNames(pName, pExpr); + }else{ + pExpr->op = TK_STRING; + } + } + return rc; +} + +/* +** An SQL user-function registered to do the work of an ATTACH statement. The +** three arguments to the function come directly from an attach statement: +** +** ATTACH DATABASE x AS y KEY z +** +** SELECT sqlite_attach(x, y, z) +** +** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the +** third argument. +*/ +static void attachFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + int i; + int rc = 0; + sqlite3 *db = sqlite3_user_data(context); + const char *zName; + const char *zFile; + Db *aNew; + char zErr[128]; + char *zErrDyn = 0; + + zFile = (const char *)sqlite3_value_text(argv[0]); + zName = (const char *)sqlite3_value_text(argv[1]); + + /* Check for the following errors: + ** + ** * Too many attached databases, + ** * Transaction currently open + ** * Specified database name already being used. + */ + if( db->nDb>=MAX_ATTACHED+2 ){ + sqlite3_snprintf( + 127, zErr, "too many attached databases - max %d", MAX_ATTACHED + ); + goto attach_error; + } + if( !db->autoCommit ){ + strcpy(zErr, "cannot ATTACH database within transaction"); + goto attach_error; + } + for(i=0; i<db->nDb; i++){ + char *z = db->aDb[i].zName; + if( z && sqlite3StrICmp(z, zName)==0 ){ + sqlite3_snprintf(127, zErr, "database %s is already in use", zName); + goto attach_error; + } + } + + /* Allocate the new entry in the db->aDb[] array and initialise the schema + ** hash tables. + */ + if( db->aDb==db->aDbStatic ){ + aNew = sqliteMalloc( sizeof(db->aDb[0])*3 ); + if( aNew==0 ){ + return; + } + memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2); + }else{ + aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) ); + if( aNew==0 ){ + return; + } + } + db->aDb = aNew; + aNew = &db->aDb[db->nDb++]; + memset(aNew, 0, sizeof(*aNew)); + + /* Open the database file. If the btree is successfully opened, use + ** it to obtain the database schema. At this point the schema may + ** or may not be initialised. + */ + rc = sqlite3BtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt); + if( rc==SQLITE_OK ){ + aNew->pSchema = sqlite3SchemaGet(aNew->pBt); + if( !aNew->pSchema ){ + rc = SQLITE_NOMEM; + }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){ + strcpy(zErr, + "attached databases must use the same text encoding as main database"); + goto attach_error; + } + } + aNew->zName = sqliteStrDup(zName); + aNew->safety_level = 3; + +#if SQLITE_HAS_CODEC + { + extern int sqlite3CodecAttach(sqlite3*, int, void*, int); + extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*); + int nKey; + char *zKey; + int t = sqlite3_value_type(argv[2]); + switch( t ){ + case SQLITE_INTEGER: + case SQLITE_FLOAT: + zErrDyn = sqliteStrDup("Invalid key value"); + rc = SQLITE_ERROR; + break; + + case SQLITE_TEXT: + case SQLITE_BLOB: + nKey = sqlite3_value_bytes(argv[2]); + zKey = (char *)sqlite3_value_blob(argv[2]); + sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); + break; + + case SQLITE_NULL: + /* No key specified. Use the key from the main database */ + sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); + sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); + break; + } + } +#endif + + /* If the file was opened successfully, read the schema for the new database. + ** If this fails, or if opening the file failed, then close the file and + ** remove the entry from the db->aDb[] array. i.e. put everything back the way + ** we found it. + */ + if( rc==SQLITE_OK ){ + sqlite3SafetyOn(db); + rc = sqlite3Init(db, &zErrDyn); + sqlite3SafetyOff(db); + } + if( rc ){ + int iDb = db->nDb - 1; + assert( iDb>=2 ); + if( db->aDb[iDb].pBt ){ + sqlite3BtreeClose(db->aDb[iDb].pBt); + db->aDb[iDb].pBt = 0; + db->aDb[iDb].pSchema = 0; + } + sqlite3ResetInternalSchema(db, 0); + db->nDb = iDb; + sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); + goto attach_error; + } + + return; + +attach_error: + /* Return an error if we get here */ + if( zErrDyn ){ + sqlite3_result_error(context, zErrDyn, -1); + sqliteFree(zErrDyn); + }else{ + zErr[sizeof(zErr)-1] = 0; + sqlite3_result_error(context, zErr, -1); + } +} + +/* +** An SQL user-function registered to do the work of an DETACH statement. The +** three arguments to the function come directly from a detach statement: +** +** DETACH DATABASE x +** +** SELECT sqlite_detach(x) +*/ +static void detachFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zName = (const char *)sqlite3_value_text(argv[0]); + sqlite3 *db = sqlite3_user_data(context); + int i; + Db *pDb = 0; + char zErr[128]; + + assert(zName); + for(i=0; i<db->nDb; i++){ + pDb = &db->aDb[i]; + if( pDb->pBt==0 ) continue; + if( sqlite3StrICmp(pDb->zName, zName)==0 ) break; + } + + if( i>=db->nDb ){ + sqlite3_snprintf(sizeof(zErr), zErr, "no such database: %s", zName); + goto detach_error; + } + if( i<2 ){ + sqlite3_snprintf(sizeof(zErr), zErr, "cannot detach database %s", zName); + goto detach_error; + } + if( !db->autoCommit ){ + strcpy(zErr, "cannot DETACH database within transaction"); + goto detach_error; + } + + sqlite3BtreeClose(pDb->pBt); + pDb->pBt = 0; + pDb->pSchema = 0; + sqlite3ResetInternalSchema(db, 0); + return; + +detach_error: + sqlite3_result_error(context, zErr, -1); +} + +/* +** This procedure generates VDBE code for a single invocation of either the +** sqlite_detach() or sqlite_attach() SQL user functions. +*/ +static void codeAttach( + Parse *pParse, /* The parser context */ + int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */ + const char *zFunc, /* Either "sqlite_attach" or "sqlite_detach */ + int nFunc, /* Number of args to pass to zFunc */ + Expr *pAuthArg, /* Expression to pass to authorization callback */ + Expr *pFilename, /* Name of database file */ + Expr *pDbname, /* Name of the database to use internally */ + Expr *pKey /* Database key for encryption extension */ +){ + int rc; + NameContext sName; + Vdbe *v; + FuncDef *pFunc; + sqlite3* db = pParse->db; + +#ifndef SQLITE_OMIT_AUTHORIZATION + assert( sqlite3MallocFailed() || pAuthArg ); + if( pAuthArg ){ + char *zAuthArg = sqlite3NameFromToken(&pAuthArg->span); + if( !zAuthArg ){ + goto attach_end; + } + rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0); + sqliteFree(zAuthArg); + if(rc!=SQLITE_OK ){ + goto attach_end; + } + } +#endif /* SQLITE_OMIT_AUTHORIZATION */ + + memset(&sName, 0, sizeof(NameContext)); + sName.pParse = pParse; + + if( + SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) || + SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) || + SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey)) + ){ + pParse->nErr++; + goto attach_end; + } + + v = sqlite3GetVdbe(pParse); + sqlite3ExprCode(pParse, pFilename); + sqlite3ExprCode(pParse, pDbname); + sqlite3ExprCode(pParse, pKey); + + assert( v || sqlite3MallocFailed() ); + if( v ){ + sqlite3VdbeAddOp(v, OP_Function, 0, nFunc); + pFunc = sqlite3FindFunction(db, zFunc, strlen(zFunc), nFunc, SQLITE_UTF8,0); + sqlite3VdbeChangeP3(v, -1, (char *)pFunc, P3_FUNCDEF); + + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this + ** statement only). For DETACH, set it to false (expire all existing + ** statements). + */ + sqlite3VdbeAddOp(v, OP_Expire, (type==SQLITE_ATTACH), 0); + } + +attach_end: + sqlite3ExprDelete(pFilename); + sqlite3ExprDelete(pDbname); + sqlite3ExprDelete(pKey); +} + +/* +** Called by the parser to compile a DETACH statement. +** +** DETACH pDbname +*/ +void sqlite3Detach(Parse *pParse, Expr *pDbname){ + codeAttach(pParse, SQLITE_DETACH, "sqlite_detach", 1, pDbname, 0, 0, pDbname); +} + +/* +** Called by the parser to compile an ATTACH statement. +** +** ATTACH p AS pDbname KEY pKey +*/ +void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){ + codeAttach(pParse, SQLITE_ATTACH, "sqlite_attach", 3, p, p, pDbname, pKey); +} + +/* +** Register the functions sqlite_attach and sqlite_detach. +*/ +void sqlite3AttachFunctions(sqlite3 *db){ + static const int enc = SQLITE_UTF8; + sqlite3CreateFunc(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0); + sqlite3CreateFunc(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0); +} + +/* +** Initialize a DbFixer structure. This routine must be called prior +** to passing the structure to one of the sqliteFixAAAA() routines below. +** +** The return value indicates whether or not fixation is required. TRUE +** means we do need to fix the database references, FALSE means we do not. +*/ +int sqlite3FixInit( + DbFixer *pFix, /* The fixer to be initialized */ + Parse *pParse, /* Error messages will be written here */ + int iDb, /* This is the database that must be used */ + const char *zType, /* "view", "trigger", or "index" */ + const Token *pName /* Name of the view, trigger, or index */ +){ + sqlite3 *db; + + if( iDb<0 || iDb==1 ) return 0; + db = pParse->db; + assert( db->nDb>iDb ); + pFix->pParse = pParse; + pFix->zDb = db->aDb[iDb].zName; + pFix->zType = zType; + pFix->pName = pName; + return 1; +} + +/* +** The following set of routines walk through the parse tree and assign +** a specific database to all table references where the database name +** was left unspecified in the original SQL statement. The pFix structure +** must have been initialized by a prior call to sqlite3FixInit(). +** +** These routines are used to make sure that an index, trigger, or +** view in one database does not refer to objects in a different database. +** (Exception: indices, triggers, and views in the TEMP database are +** allowed to refer to anything.) If a reference is explicitly made +** to an object in a different database, an error message is added to +** pParse->zErrMsg and these routines return non-zero. If everything +** checks out, these routines return 0. +*/ +int sqlite3FixSrcList( + DbFixer *pFix, /* Context of the fixation */ + SrcList *pList /* The Source list to check and modify */ +){ + int i; + const char *zDb; + struct SrcList_item *pItem; + + if( pList==0 ) return 0; + zDb = pFix->zDb; + for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ + if( pItem->zDatabase==0 ){ + pItem->zDatabase = sqliteStrDup(zDb); + }else if( sqlite3StrICmp(pItem->zDatabase,zDb)!=0 ){ + sqlite3ErrorMsg(pFix->pParse, + "%s %T cannot reference objects in database %s", + pFix->zType, pFix->pName, pItem->zDatabase); + return 1; + } +#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) + if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; + if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; +#endif + } + return 0; +} +#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) +int sqlite3FixSelect( + DbFixer *pFix, /* Context of the fixation */ + Select *pSelect /* The SELECT statement to be fixed to one database */ +){ + while( pSelect ){ + if( sqlite3FixExprList(pFix, pSelect->pEList) ){ + return 1; + } + if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){ + return 1; + } + if( sqlite3FixExpr(pFix, pSelect->pWhere) ){ + return 1; + } + if( sqlite3FixExpr(pFix, pSelect->pHaving) ){ + return 1; + } + pSelect = pSelect->pPrior; + } + return 0; +} +int sqlite3FixExpr( + DbFixer *pFix, /* Context of the fixation */ + Expr *pExpr /* The expression to be fixed to one database */ +){ + while( pExpr ){ + if( sqlite3FixSelect(pFix, pExpr->pSelect) ){ + return 1; + } + if( sqlite3FixExprList(pFix, pExpr->pList) ){ + return 1; + } + if( sqlite3FixExpr(pFix, pExpr->pRight) ){ + return 1; + } + pExpr = pExpr->pLeft; + } + return 0; +} +int sqlite3FixExprList( + DbFixer *pFix, /* Context of the fixation */ + ExprList *pList /* The expression to be fixed to one database */ +){ + int i; + struct ExprList_item *pItem; + if( pList==0 ) return 0; + for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){ + if( sqlite3FixExpr(pFix, pItem->pExpr) ){ + return 1; + } + } + return 0; +} +#endif + +#ifndef SQLITE_OMIT_TRIGGER +int sqlite3FixTriggerStep( + DbFixer *pFix, /* Context of the fixation */ + TriggerStep *pStep /* The trigger step be fixed to one database */ +){ + while( pStep ){ + if( sqlite3FixSelect(pFix, pStep->pSelect) ){ + return 1; + } + if( sqlite3FixExpr(pFix, pStep->pWhere) ){ + return 1; + } + if( sqlite3FixExprList(pFix, pStep->pExprList) ){ + return 1; + } + pStep = pStep->pNext; + } + return 0; +} +#endif Property changes on: Frontier/vendor/sqlite3/current/attach.c ___________________________________________________________________ Name: svn:eol-style + native Added: Frontier/vendor/sqlite3/current/auth.c =================================================================== --- Frontier/vendor/sqlite3/current/auth.c (rev 0) +++ Frontier/vendor/sqlite3/current/auth.c 2006-03-25 18:43:10 UTC (rev 1148) @@ -0,0 +1,232 @@ +/* +** 2003 January 11 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the sqlite3_set_authorizer() +** API. This facility is an optional feature of the library. Embedded +** systems that do not need this facility may omit it by recompiling +** the library with -DSQLITE_OMIT_AUTHORIZATION=1 +** +** $Id: auth.c,v 1.24 2006/01/13 13:55:45 drh Exp $ +*/ +#include "sqliteInt.h" + +/* +** All of the code in this file may be omitted by defining a single +** macro. +*/ +#ifndef SQLITE_OMIT_AUTHORIZATION + +/* +** Set or clear the access authorization function. +** +** The access authorization function is be called during the compilation +** phase to verify that the user has read and/or write access permission on +** various fields of the database. The first argument to the auth function +** is a copy of the 3rd argument to this routine. The second argument +** to the auth function is one of these constants: +** +** SQLITE_CREATE_INDEX +** SQLITE_CREATE_TABLE +** SQLITE_CREATE_TEMP_INDEX +** SQLITE_CREATE_TEMP_TABLE +** SQLITE_CREATE_TEMP_TRIGGER +** SQLITE_CREATE_TEMP_VIEW +** SQLITE_CREATE_TRIGGER +** SQLITE_CREATE_VIEW +** SQLITE_DELETE +** SQLITE_DROP_INDEX +** SQLITE_DROP_TABLE +** SQLITE_DROP_TEMP_INDEX +** SQLITE_DROP_TEMP_TABLE +** SQLITE_DROP_TEMP_TRIGGER +** SQLITE_DROP_TEMP_VIEW +** SQLITE_DROP_TRIGGER +** SQLITE_DROP_VIEW +** SQLITE_INSERT +** SQLITE_PRAGMA +** SQLITE_READ +** SQLITE_SELECT +** SQLITE_TRANSACTION +** SQLITE_UPDATE +** +** The third and fourth arguments to the auth function are the name of +** the table and the column that are being accessed. The auth function +** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE. If +** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY +** means that the SQL statement will never-run - the sqlite3_exec() call +** will return with an error. SQLITE_IGNORE means that the SQL statement +** should run but attempts to read the specified column will return NULL +** and attempts to write the column will be ignored. +** +** Setting the auth function to NULL disables this hook. The default +** setting of the auth function is NULL. +*/ +int sqlite3_set_authorizer( + sqlite3 *db, + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), + void *pArg +){ + db->xAuth = xAuth; + db->pAuthArg = pArg; + sqlite3ExpirePreparedStatements(db); + return SQLITE_OK; +} + +/* +** Write an error message into pParse->zErrMsg that explains that the +** user-supplied authorization function returned an illegal value. +*/ +static void sqliteAuthBadReturnCode(Parse *pParse, int rc){ + sqlite3ErrorMsg(pParse, "illegal return value (%d) from the " + "authorization function - should be SQLITE_OK, SQLITE_IGNORE, " + "or SQLITE_DENY", rc); + pParse->rc = SQLITE_ERROR; +} + +/* +** The pExpr should be a TK_COLUMN expression. The table referred to +** is in pTabList or else it is the NEW or OLD table of a trigger. +** Check to see if it is OK to read this particular column. +** +** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN +** instruction into a TK_NULL. If the auth function returns SQLITE_DENY, +** then generate an error. +*/ +void sqlite3AuthRead( + Parse *pParse, /* The parser context */ + Expr *pExpr, /* The expression to check authorization on */ + SrcList *pTabList /* All table that pExpr might refer to */ +){ + sqlite3 *db = pParse->db; + int rc; + Table *pTab; /* The table being read */ + const char *zCol; /* Name of the column of the table */ + int iSrc; /* Index in pTabList->a[] of table being read */ + const char *zDBase; /* Name of database being accessed */ + TriggerStack *pStack; /* The stack of current triggers */ + int iDb; /* The index of the database the expression refers to */ + + if( db->xAuth==0 ) return; + if( pExpr->op==TK_AS ) return; + assert( pExpr->op==TK_COLUMN ); + iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema); + if( iDb<0 ){ + /* An attempt to read a column out of a subquery or other + ** temporary table. */ + return; + } + for(iSrc=0; pTabList && iSrc<pTabList->nSrc; iSrc++){ + if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break; + } + if( iSrc>=0 && pTabList && iSrc<pTabList->nSrc ){ + pTab = pTabList->a[iSrc].pTab; + }else if( (pStack = pParse->trigStack)!=0 ){ + /* This must be an attempt to read the NEW or OLD pseudo-tables + ** of a trigger. + */ + assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx ); + pTab = pStack->pTab; + }else{ + return; + } + if( pTab==0 ) return; + if( pExpr->iColumn>=0 ){ + assert( pExpr->iColumn<pTab->nCol ); + zCol = pTab->aCol[pExpr->iColumn].zName; + }else if( pTab->iPKey>=0 ){ + assert( pTab->iPKey<pTab->nCol ); + zCol = pTab->aCol[pTab->iPKey].zName; + }else{ + zCol = "ROWID"; + } + assert( iDb>=0 && iDb<db->nDb ); + zDBase = db->aDb[iDb].zName; + rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, + pParse->zAuthContext); + if( rc==SQLITE_IGNORE ){ + pExpr->op = TK_NULL; + }else if( rc==SQLITE_DENY ){ + if( db->nDb>2 || iDb!=0 ){ + sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", + zDBase, pTab->zName, zCol); + }else{ + sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol); + } + pParse->rc = SQLITE_AUTH; + }else if( rc!=SQLITE_OK ){ + sqliteAuthBadReturnCode(pParse, rc); + } +} + +/* +** Do an authorization check using the code and arguments given. Return +** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY +** is returned, then the error count and error message in pParse are +** modified appropriately. +*/ +int sqlite3AuthCheck( + Parse *pParse, + int code, + const char *zArg1, + const char *zArg2, + const char *zArg3 +){ + sqlite3 *db = pParse->db; + int rc; + + /* Don't do any authorization checks if the database is initialising. */ + if( db->init.busy ){ + return SQLITE_OK; + } + + if( db->xAuth==0 ){ + return SQLITE_OK; + } + rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext); + if( rc==SQLITE_DENY ){ + sqlite3ErrorMsg(pParse, "not authorized"); + pParse->rc = SQLITE_AUTH; + }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){ + rc = SQLITE_DENY; + sqliteAuthBadReturnCode(pParse, rc); + } + return rc; +} + +/* +** Push an authorization context. After this routine is called, the +** zArg3 argument to authorization callbacks will be zContext until +** popped. Or if pParse==0, this routine is a no-op. +*/ +void sqlite3AuthContextPush( + Parse *pParse, + AuthContext *pContext, + const char *zContext +){ + pContext->pParse = pParse; + if( pParse ){ + pContext->zAuthContext = pParse->zAuthContext; + pParse->zAuthContext = zContext; + } +} + +/* +** Pop an authorization context that was previously pushed +** by sqlite3AuthContextPush +*/ +void sqlite3AuthContextPop(AuthContext *pContext){ + if( pContext->pParse ){ + pContext->pParse->zAuthContext = pContext->zAuthContext; + pContext->pParse = 0; + } +} + +#endif /* SQLITE_OMIT_AUTHORIZATION */ Property changes on: Frontier/vendor/sqlite3/current/auth.c ___________________________________________________________________ Name: svn:eol-style + native Added: Frontier/vendor/sqlite3/current/btree.c =================================================================== --- Frontier/vendor/sqlite3/current/btree.c (rev 0) +++ Frontier/vendor/sqlite3/current/btree.c 2006-03-25 18:43:10 UTC (rev 1148) @@ -0,0 +1,6639 @@ +/* +** 2004 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** $Id: btree.c,v 1.314 2006/02/11 01:25:51 drh Exp $ +** +** This file implements a external (disk-based) database using BTrees. +** For a detailed discussion of BTrees, refer to +** +** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: +** "Sorting And Searching", pages 473-480. Addison-Wesley +** Publishing Company, Reading, Massachusetts. +** +** The basic idea is that each page of the file contains N database +** entries and N+1 pointers to subpages. +** +** ---------------------------------------------------------------- +** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N) | Ptr(N+1) | +** ----------------------------------------------------------------... [truncated message content] |
|
From: <and...@us...> - 2006-03-25 18:40:51
|
Revision: 1147 Author: andreradke Date: 2006-03-25 10:40:36 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1147&view=rev Log Message: ----------- Add vendor branch for SQLite version 3.x Added Paths: ----------- Frontier/vendor/sqlite3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <and...@us...> - 2006-03-25 16:40:14
|
Revision: 1146 Author: andreradke Date: 2006-03-25 08:38:43 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1146&view=rev Log Message: ----------- Create directory for vendor branches (SQLite, OpenSSL, etc.) Added Paths: ----------- Frontier/vendor/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: David G. <dav...@us...> - 2006-03-24 01:36:18
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/Common/resources/Mac Modified Files: Tag: sqlite-embedded-experimental kernelverbs.r lang.r Log Message: Index: lang.r =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Mac/lang.r,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** lang.r 10 Mar 2006 09:58:49 -0000 1.11 --- lang.r 24 Mar 2006 01:35:45 -0000 1.11.2.1 *************** *** 719,722 **** --- 719,726 ---- /* [162] */ "Can't run shell command because the shell \042^0\042 was not found.", /* 2006-03-10 aradke */ + /* [163] */ + "Can't open database: ^0.", /* 2006-03-17 gewirtz */ + /* [164] */ + "Database error: ^0.", /* 2006-03-17 gewirtz */ } }; Index: kernelverbs.r =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Mac/kernelverbs.r,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** kernelverbs.r 12 Mar 2006 20:39:24 -0000 1.7 --- kernelverbs.r 24 Mar 2006 01:35:45 -0000 1.7.2.1 *************** *** 1136,1137 **** --- 1136,1147 ---- }; + resource 'EFP#' (idsqliteverbs, "sqlite") { /* 2006-03-15 gewirtz sqlite verbs */ + { + "sqlite", false, { + + "open", + "exec", + "close" + } + } + }; \ No newline at end of file |
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/Common/headers Modified Files: Tag: sqlite-embedded-experimental kernelverbdefs.h kernelverbs.h langinternal.h Log Message: Index: kernelverbs.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/kernelverbs.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** kernelverbs.h 10 Mar 2006 21:20:41 -0000 1.4 --- kernelverbs.h 24 Mar 2006 01:35:45 -0000 1.4.2.1 *************** *** 57,58 **** --- 57,60 ---- extern boolean cryptinitverbs (void); /* langcrypt.c */ + extern boolean sqliteinitverbs (void); /* langsqlite.c */ + Index: kernelverbdefs.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/kernelverbdefs.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** kernelverbdefs.h 10 Mar 2006 21:20:41 -0000 1.6 --- kernelverbdefs.h 24 Mar 2006 01:35:45 -0000 1.6.2.1 *************** *** 27,36 **** #define idopverbs 1000 ! #define idtableverbs 1001 #define idmenuverbs 1002 #define idwpverbs 1003 #define idpictverbs 1004 #define idlangverbs 1005 ! #define idstringverbs 1006 #define idfileverbs 1007 #define idrezverbs 1008 --- 27,36 ---- #define idopverbs 1000 ! #define idtableverbs 1001 #define idmenuverbs 1002 #define idwpverbs 1003 #define idpictverbs 1004 #define idlangverbs 1005 ! #define idstringverbs 1006 #define idfileverbs 1007 #define idrezverbs 1008 *************** *** 41,45 **** #define idsysverbs 1013 #define idlaunchverbs 1014 ! #define idclipboardverbs 1015 #define idfrontierverbs 1016 #define idcancoonverbs 1017 --- 41,45 ---- #define idsysverbs 1013 #define idlaunchverbs 1014 ! #define idclipboardverbs 1015 #define idfrontierverbs 1016 #define idcancoonverbs 1017 *************** *** 48,54 **** #define idxmlverbs 1020 #define idhtmlverbs 1021 ! #define idquicktimeverbs 1022 /*7.0b4 PBS: QuickTime Player window verbs*/ #define idregexpverbs 1023 /*2003-04-22 AR: regular expression verbs*/ #define idmathverbs 1024 /*2004-12-29 SMD: extended math verbs*/ ! #define idcryptverbs 1025 /* 2006-03-07 creedon: crypt verbs */ --- 48,55 ---- #define idxmlverbs 1020 #define idhtmlverbs 1021 ! #define idquicktimeverbs 1022 /*7.0b4 PBS: QuickTime Player window verbs*/ #define idregexpverbs 1023 /*2003-04-22 AR: regular expression verbs*/ #define idmathverbs 1024 /*2004-12-29 SMD: extended math verbs*/ ! #define idcryptverbs 1025 /* 2006-03-07 creedon: crypt verbs */ ! #define idsqliteverbs 1026 /* 2006-03-15 gewirtz sqlite verbs */ Index: langinternal.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/langinternal.h,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** langinternal.h 10 Mar 2006 09:58:08 -0000 1.8 --- langinternal.h 24 Mar 2006 01:35:45 -0000 1.8.2.1 *************** *** 203,206 **** --- 203,208 ---- #define replaceitemerror 161 /* 2005-09-26 creedon */ #define cmdshellnotfounderror 162 /* 2006-03-10 aradke */ + #define sqliteopenerror 163 /* 2006-03-17 gewirtz */ + #define sqlitedberror 164 /* 2006-03-17 gewirtz */ #define langstacklist 137 |
|
From: David G. <dav...@us...> - 2006-03-24 01:36:18
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/Common/resources/Win32 Modified Files: Tag: sqlite-embedded-experimental WinLand.rc kernelverbs.rc Log Message: Index: kernelverbs.rc =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Win32/kernelverbs.rc,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** kernelverbs.rc 12 Mar 2006 20:39:34 -0000 1.7 --- kernelverbs.rc 24 Mar 2006 01:35:45 -0000 1.7.2.1 *************** *** 1074,1075 **** --- 1074,1086 ---- END + 1026 /* sqliteverbs */ EFP DISCARDABLE + BEGIN + 1, // Number of "blocks" in this resource + "sqlite\0", // Function Processor name + false, // Window required + 3, // Count of verbs + "open\0", + "exec\0", + "close\0" + END + Index: WinLand.rc =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Win32/WinLand.rc,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -C2 -d -r1.20 -r1.20.2.1 *** WinLand.rc 10 Mar 2006 09:58:41 -0000 1.20 --- WinLand.rc 24 Mar 2006 01:35:45 -0000 1.20.2.1 *************** *** 1534,1537 **** --- 1534,1539 ---- 161 Lang_Errors DISCARDABLE BEGIN "An item named \042^0\042 already exists.\0" END // Replace it or create a duplicate?" /* 2005-09-26 creedon */ 162 Lang_Errors DISCARDABLE BEGIN "Can't run shell command because the shell \042^0\042 was not found.\0" END /* 2006-03-10 aradke */ + 163 Lang_Errors DISCARDABLE BEGIN "Can't open database: ^0.\0" END /* 2006-03-17 gewirtz */ + 164 Lang_Errors DISCARDABLE BEGIN "Database error: ^0.\0" END /* 2006-03-17 gewirtz */ 1 Mac_Errors DISCARDABLE BEGIN "The \042^0\042 folder is full.\0" END |
|
From: David G. <dav...@us...> - 2006-03-24 01:35:59
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/Common/source Modified Files: Tag: sqlite-embedded-experimental shell.c Log Message: Index: shell.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shell.c,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -C2 -d -r1.13 -r1.13.2.1 *** shell.c 10 Mar 2006 21:20:52 -0000 1.13 --- shell.c 24 Mar 2006 01:35:45 -0000 1.13.2.1 *************** *** 1336,1339 **** --- 1336,1341 ---- cryptinitverbs (); /* 2006-03-07 creedon: langcrypt.c */ + + sqliteinitverbs (); /* 2006-03-15 gewirtz: langsqlite.c */ if (keyboardescape ()) /*check again before landinit; after this, must do shellquit*/ |
|
From: David G. <dav...@us...> - 2006-03-24 01:35:59
|
Update of /cvsroot/frontierkernel/Frontier/build_VC2K3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/build_VC2K3 Modified Files: Tag: sqlite-embedded-experimental Frontier.vcproj Log Message: Index: Frontier.vcproj =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_VC2K3/Frontier.vcproj,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** Frontier.vcproj 12 Mar 2006 21:39:11 -0000 1.4 --- Frontier.vcproj 24 Mar 2006 01:35:45 -0000 1.4.2.1 *************** *** 231,235 **** Optimization="0" InlineFunctionExpansion="2" ! AdditionalIncludeDirectories="..\Common\headers,..\Common\SystemHeaders,..\Common\Paige\headers,..\Common\PCRE" PreprocessorDefinitions="_DEBUG;FRONTIERCOM=1;WIN95VERSION;_WINDOWS;WIN32;WIN32_COMPILE" RuntimeLibrary="1" --- 231,235 ---- Optimization="0" InlineFunctionExpansion="2" ! AdditionalIncludeDirectories="..\Common\headers;..\Common\SystemHeaders;..\Common\Paige\headers;..\Common\PCRE;..\Common\sqlite3" PreprocessorDefinitions="_DEBUG;FRONTIERCOM=1;WIN95VERSION;_WINDOWS;WIN32;WIN32_COMPILE" RuntimeLibrary="1" *************** *** 3689,3692 **** --- 3689,3695 ---- </File> <File + RelativePath="..\Common\source\langsqlite.c"> + </File> + <File RelativePath="..\Common\source\langstartup.c"> <FileConfiguration *************** *** 6867,6870 **** --- 6870,7024 ---- </File> </Filter> + <Filter + Name="sqlite" + Filter=""> + <File + RelativePath="..\Common\sqlite3\alter.c"> + </File> + <File + RelativePath="..\Common\sqlite3\analyze.c"> + </File> + <File + RelativePath="..\Common\sqlite3\attach.c"> + </File> + <File + RelativePath="..\Common\sqlite3\auth.c"> + </File> + <File + RelativePath="..\Common\sqlite3\btree.c"> + </File> + <File + RelativePath="..\Common\sqlite3\build.c"> + </File> + <File + RelativePath="..\Common\sqlite3\callback.c"> + </File> + <File + RelativePath="..\Common\sqlite3\complete.c"> + </File> + <File + RelativePath="..\Common\sqlite3\date.c"> + </File> + <File + RelativePath="..\Common\sqlite3\delete.c"> + </File> + <File + RelativePath="..\Common\sqlite3\expr.c"> + </File> + <File + RelativePath="..\Common\sqlite3\func.c"> + </File> + <File + RelativePath="..\Common\sqlite3\hash.c"> + </File> + <File + RelativePath="..\Common\sqlite3\insert.c"> + </File> + <File + RelativePath="..\Common\sqlite3\legacy.c"> + </File> + <File + RelativePath="..\Common\sqlite3\main.c"> + <FileConfiguration + Name="DbTracker|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="MemTracker|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath="..\Common\sqlite3\opcodes.c"> + </File> + <File + RelativePath="..\Common\sqlite3\os.c"> + </File> + <File + RelativePath="..\Common\sqlite3\os_unix.c"> + </File> + <File + RelativePath="..\Common\sqlite3\os_win.c"> + </File> + <File + RelativePath="..\Common\sqlite3\pager.c"> + </File> + <File + RelativePath="..\Common\sqlite3\parse.c"> + </File> + <File + RelativePath="..\Common\sqlite3\pragma.c"> + </File> + <File + RelativePath="..\Common\sqlite3\prepare.c"> + </File> + <File + RelativePath="..\Common\sqlite3\printf.c"> + </File> + <File + RelativePath="..\Common\sqlite3\random.c"> + </File> + <File + RelativePath="..\Common\sqlite3\select.c"> + </File> + <File + RelativePath="..\Common\sqlite3\table.c"> + </File> + <File + RelativePath="..\Common\sqlite3\tokenize.c"> + </File> + <File + RelativePath="..\Common\sqlite3\trigger.c"> + </File> + <File + RelativePath="..\Common\sqlite3\update.c"> + </File> + <File + RelativePath="..\Common\sqlite3\utf.c"> + </File> + <File + RelativePath="..\Common\sqlite3\util.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vacuum.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbe.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbe.h"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbeapi.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbeaux.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbefifo.c"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbemem.c"> + </File> + <File + RelativePath="..\Common\sqlite3\where.c"> + </File> + </Filter> </Filter> <Filter *************** *** 7051,7054 **** --- 7205,7211 ---- </File> <File + RelativePath="..\Common\headers\langsqlite.h"> + </File> + <File RelativePath="..\Common\headers\langsystem7.h"> </File> *************** *** 7317,7320 **** --- 7474,7514 ---- RelativePath="..\Common\headers\zoom.h"> </File> + <Filter + Name="sqlite" + Filter=""> + <File + RelativePath="..\Common\sqlite3\btree.h"> + </File> + <File + RelativePath="..\Common\sqlite3\hash.h"> + </File> + <File + RelativePath="..\Common\sqlite3\keywordhash.h"> + </File> + <File + RelativePath="..\Common\sqlite3\opcodes.h"> + </File> + <File + RelativePath="..\Common\sqlite3\os.h"> + </File> + <File + RelativePath="..\Common\sqlite3\os_common.h"> + </File> + <File + RelativePath="..\Common\sqlite3\pager.h"> + </File> + <File + RelativePath="..\Common\sqlite3\parse.h"> + </File> + <File + RelativePath="..\Common\sqlite3\sqlite3.h"> + </File> + <File + RelativePath="..\Common\sqlite3\sqliteInt.h"> + </File> + <File + RelativePath="..\Common\sqlite3\vdbeInt.h"> + </File> + </Filter> </Filter> </Files> |
|
From: David G. <dav...@us...> - 2006-03-24 01:35:58
|
Update of /cvsroot/frontierkernel/Frontier/build_VC2K5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3636/build_VC2K5 Modified Files: Tag: sqlite-embedded-experimental Frontier.vcproj Removed Files: Tag: sqlite-embedded-experimental Frontier.ncb Frontier.sln Frontier.suo Log Message: --- Frontier.ncb DELETED --- --- Frontier.suo DELETED --- --- Frontier.sln DELETED --- Index: Frontier.vcproj =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_VC2K5/Frontier.vcproj,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** Frontier.vcproj 15 Mar 2006 17:19:41 -0000 1.1 --- Frontier.vcproj 24 Mar 2006 01:35:45 -0000 1.1.2.1 *************** *** 5,8 **** --- 5,9 ---- Name="Frontier" ProjectGUID="{D834EFC1-8805-4046-9A49-F9925A0808EF}" + RootNamespace="Frontier" > <Platforms> *************** *** 357,361 **** WarningLevel="3" SuppressStartupBanner="true" ! DebugInformationFormat="3" CompileAs="0" /> --- 358,362 ---- WarningLevel="3" SuppressStartupBanner="true" ! DebugInformationFormat="1" CompileAs="0" /> *************** *** 380,384 **** AdditionalLibraryDirectories="..\Common\Paige" IgnoreAllDefaultLibraries="true" ! GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug/Frontier.pdb" GenerateMapFile="true" --- 381,385 ---- AdditionalLibraryDirectories="..\Common\Paige" IgnoreAllDefaultLibraries="true" ! GenerateDebugInformation="false" ProgramDatabaseFile=".\Debug/Frontier.pdb" GenerateMapFile="true" |