From d91603f842f120751bb2364333daa7188037d057 Mon Sep 17 00:00:00 2001 From: Nicholas Shanks Date: Sat, 27 Apr 2002 18:17:47 +0000 Subject: [PATCH] Update NovaTools. --- Cocoa/Categories/NSEvent-ModifierKeys.h | 11 + Cocoa/Categories/NSEvent-ModifierKeys.m | 25 + Cocoa/Classes/ApplicationDelegate.h | 3 + Cocoa/Classes/ApplicationDelegate.m | 18 +- Cocoa/Classes/InfoWindowController.m | 9 +- Cocoa/Classes/OutlineViewDelegate.m | 8 +- Cocoa/Classes/ResourceDocument.h | 1 + Cocoa/Classes/ResourceDocument.m | 39 +- Cocoa/Classes/ResourceNameCell.m | 3 +- .../English.lproj/Application.nib/classes.nib | 2 +- Cocoa/English.lproj/Application.nib/info.nib | 8 +- .../English.lproj/Application.nib/objects.nib | Bin 7057 -> 7050 bytes .../Plug-Ins/Hex Editor/HexWindowController.m | 6 +- External/MoreFilesX/MoreFilesX.c | 2783 ++++++++++++++++- NovaTools/NovaWindowController.h | 3 + NovaTools/NovaWindowController.m | 64 +- NovaTools/boom/BoomWindowController.m | 6 +- .../boom/English.lproj/boom.nib/info.nib | 4 + .../boom/English.lproj/boom.nib/objects.nib | Bin 3221 -> 3218 bytes NovaTools/char/CharWindowController.h | 25 + NovaTools/char/CharWindowController.m | 54 + .../char/English.lproj/char.nib/classes.nib | 10 + .../char/English.lproj/char.nib/info.nib | 4 +- .../char/English.lproj/char.nib/objects.nib | Bin 11457 -> 12041 bytes NovaTools/colr/ColrWindowController.m | 12 + NovaTools/cron/CronWindowController.m | 15 + .../cron/English.lproj/cron.nib/classes.nib | 2 +- .../cron/English.lproj/cron.nib/objects.nib | Bin 16714 -> 15984 bytes NovaTools/desc/DescSplitViewDelegate.h | 8 + NovaTools/desc/DescSplitViewDelegate.m | 40 + NovaTools/desc/DescWindowController.m | 12 + .../desc/English.lproj/desc.nib/classes.nib | 3 + .../desc/English.lproj/desc.nib/info.nib | 6 +- .../desc/English.lproj/desc.nib/objects.nib | Bin 3340 -> 3392 bytes ResKnife.pbproj/project.pbxproj | 148 +- 35 files changed, 3187 insertions(+), 145 deletions(-) create mode 100644 Cocoa/Categories/NSEvent-ModifierKeys.h create mode 100644 Cocoa/Categories/NSEvent-ModifierKeys.m create mode 100644 NovaTools/desc/DescSplitViewDelegate.h create mode 100644 NovaTools/desc/DescSplitViewDelegate.m diff --git a/Cocoa/Categories/NSEvent-ModifierKeys.h b/Cocoa/Categories/NSEvent-ModifierKeys.h new file mode 100644 index 0000000..f5d7724 --- /dev/null +++ b/Cocoa/Categories/NSEvent-ModifierKeys.h @@ -0,0 +1,11 @@ +#import +#import + +@interface NSEvent (ModifierKeys) + ++ (BOOL) isControlKeyDown; ++ (BOOL) isOptionKeyDown; ++ (BOOL) isCommandKeyDown; ++ (BOOL) isShiftKeyDown; + +@end \ No newline at end of file diff --git a/Cocoa/Categories/NSEvent-ModifierKeys.m b/Cocoa/Categories/NSEvent-ModifierKeys.m new file mode 100644 index 0000000..8291474 --- /dev/null +++ b/Cocoa/Categories/NSEvent-ModifierKeys.m @@ -0,0 +1,25 @@ +#import "NSEvent-ModifierKeys.h" + +@implementation NSEvent (ModifierKeys) + ++ (BOOL) isControlKeyDown +{ + return (GetCurrentKeyModifiers() & controlKey) != 0; +} + ++ (BOOL) isOptionKeyDown +{ + return (GetCurrentKeyModifiers() & optionKey) != 0; +} + ++ (BOOL) isCommandKeyDown +{ + return (GetCurrentKeyModifiers() & cmdKey) != 0; +} + ++ (BOOL) isShiftKeyDown +{ + return (GetCurrentKeyModifiers() & shiftKey) != 0; +} + +@end \ No newline at end of file diff --git a/Cocoa/Classes/ApplicationDelegate.h b/Cocoa/Classes/ApplicationDelegate.h index 52c8179..c1f52c9 100644 --- a/Cocoa/Classes/ApplicationDelegate.h +++ b/Cocoa/Classes/ApplicationDelegate.h @@ -2,6 +2,7 @@ @interface ApplicationDelegate : NSObject { + NSMutableDictionary *icons; } - (IBAction)showAbout:(id)sender; @@ -12,6 +13,8 @@ - (IBAction)showPrefs:(id)sender; - (void)initUserDefaults; +- (NSDictionary *)icons; + @end @interface NSSavePanel (PackageBrowser) diff --git a/Cocoa/Classes/ApplicationDelegate.m b/Cocoa/Classes/ApplicationDelegate.m index c03a382..d96a1e7 100644 --- a/Cocoa/Classes/ApplicationDelegate.m +++ b/Cocoa/Classes/ApplicationDelegate.m @@ -22,8 +22,19 @@ int launchCount = [[NSUserDefaults standardUserDefaults] integerForKey:@"LaunchCount"]; [[NSUserDefaults standardUserDefaults] setInteger:launchCount + 1 forKey:@"LaunchCount"]; + // save a number of icons + icons = [[NSMutableDictionary alloc] init]; + [icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"PICT"] forKey:@"PICT"]; + [icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"icns"] forKey:@"icns"]; + [self initUserDefaults]; -} +} + +- (void)dealloc +{ + [icons release]; + [super dealloc]; +} - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { @@ -113,6 +124,11 @@ [defaults synchronize]; } +- (NSDictionary *)icons +{ + return icons; +} + @end @implementation NSSavePanel (PackageBrowser) diff --git a/Cocoa/Classes/InfoWindowController.m b/Cocoa/Classes/InfoWindowController.m index 6bba689..c4be081 100644 --- a/Cocoa/Classes/InfoWindowController.m +++ b/Cocoa/Classes/InfoWindowController.m @@ -77,8 +77,8 @@ [[filePropertyForm cellAtIndex:1] setStringValue:[currentDocument type]]; // [[filePropertyForm cellAtIndex:2] setObjectValue:[NSNumber numberWithUnsignedLongLong:dataLogicalSize]]; // [[filePropertyForm cellAtIndex:3] setObjectValue:[NSNumber numberWithUnsignedLongLong:rsrcLogicalSize]]; - [[filePropertyForm cellAtIndex:2] setStringValue:[NSString stringWithUnsignedLongLong:dataLogicalSize]]; - [[filePropertyForm cellAtIndex:3] setStringValue:[NSString stringWithUnsignedLongLong:rsrcLogicalSize]]; + [[filePropertyForm cellAtIndex:2] setStringValue:[[NSNumber numberWithUnsignedLongLong:dataLogicalSize] description]]; + [[filePropertyForm cellAtIndex:3] setStringValue:[[NSNumber numberWithUnsignedLongLong:rsrcLogicalSize] description]]; [placeholderView setContentView:documentView]; } } @@ -127,12 +127,9 @@ + (id)sharedInfoWindowController { static InfoWindowController *sharedInfoWindowController = nil; - if( !sharedInfoWindowController ) - { sharedInfoWindowController = [[InfoWindowController allocWithZone:[self zone]] init]; - } return sharedInfoWindowController; } -@end +@end \ No newline at end of file diff --git a/Cocoa/Classes/OutlineViewDelegate.m b/Cocoa/Classes/OutlineViewDelegate.m index 83f1106..8cb1788 100644 --- a/Cocoa/Classes/OutlineViewDelegate.m +++ b/Cocoa/Classes/OutlineViewDelegate.m @@ -1,6 +1,7 @@ #import "OutlineViewDelegate.h" #import "ResourceNameCell.h" #import "Resource.h" +#import "ApplicationDelegate.h" @implementation OutlineViewDelegate @@ -16,6 +17,7 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { + int row = [outlineView rowForItem:item]; NSString *identifier = [tableColumn identifier]; if( [identifier isEqualToString:@"name"] ) [cell setFormatter:nameFormatter]; else if( [identifier isEqualToString:@"size"] ) [cell setFormatter:sizeFormatter]; @@ -25,8 +27,12 @@ if( [identifier isEqualToString:@"name"] ) { // [(ResourceNameCell *)cell setImage:[NSImage imageNamed:@"Resource file"]]; - [(ResourceNameCell *)cell setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[(Resource *)item type]]]; +// [(ResourceNameCell *)cell setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[(Resource *)item type]]]; + [(ResourceNameCell *)cell setImage:[[(ApplicationDelegate *)[NSApp delegate] icons] valueForKey:[(Resource *)item type]]]; } + + if( row % 2 == 0 ) [cell setBackgroundColor:[NSColor whiteColor]]; + else [cell setBackgroundColor:[NSColor colorWithCalibratedRed:0.93 green:0.95 blue:1.0 alpha:1.0]]; } @end \ No newline at end of file diff --git a/Cocoa/Classes/ResourceDocument.h b/Cocoa/Classes/ResourceDocument.h index 7ef1ca6..79e7c63 100644 --- a/Cocoa/Classes/ResourceDocument.h +++ b/Cocoa/Classes/ResourceDocument.h @@ -18,6 +18,7 @@ - (void)setupToolbar:(NSWindowController *)windowController; - (IBAction)showCreateResourceSheet:(id)sender; +- (IBAction)showSelectTemplateSheet:(id)sender; - (IBAction)openResources:(id)sender; - (IBAction)openResourcesInTemplate:(id)sender; - (IBAction)openResourcesAsHex:(id)sender; diff --git a/Cocoa/Classes/ResourceDocument.m b/Cocoa/Classes/ResourceDocument.m index 2b5eb24..02fd2f4 100644 --- a/Cocoa/Classes/ResourceDocument.m +++ b/Cocoa/Classes/ResourceDocument.m @@ -96,6 +96,8 @@ NSString *DocumentInfoDidChangeNotification = @"DocumentInfoDidChangeNotificat // resource menu else if( [item action] == @selector(openResources:) ) return selectedRows > 0; + else if( [item action] == @selector(openResourcesInTemplate:) ) return selectedRows > 0; + else if( [item action] == @selector(openResourcesWithOtherTemplate:) ) return selectedRows > 0; else if( [item action] == @selector(openResourcesAsHex:) ) return selectedRows > 0; else if( [item action] == @selector(playSound:) ) return selectedRows == 1 && [[resource type] isEqualToString:@"snd "]; else if( [item action] == @selector(revertResourceToSaved:) ) return selectedRows == 1 && [resource isDirty]; @@ -137,7 +139,7 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh { NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease]; - if( [itemIdentifier isEqual:RKCreateItemIdentifier] ) + if( [itemIdentifier isEqualToString:RKCreateItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Create", nil)]; [item setPaletteLabel:NSLocalizedString(@"Create", nil)]; @@ -147,7 +149,7 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh [item setAction:@selector(showCreateResourceSheet:)]; return item; } - else if( [itemIdentifier isEqual:RKDeleteItemIdentifier] ) + else if( [itemIdentifier isEqualToString:RKDeleteItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Delete", nil)]; [item setPaletteLabel:NSLocalizedString(@"Delete", nil)]; @@ -157,27 +159,27 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh [item setAction:@selector(clear:)]; return item; } - else if( [itemIdentifier isEqual:RKEditItemIdentifier] ) + else if( [itemIdentifier isEqualToString:RKEditItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Edit", nil)]; [item setPaletteLabel:NSLocalizedString(@"Edit", nil)]; [item setToolTip:NSLocalizedString(@"Edit Resource In Default Editor", nil)]; [item setImage:[NSImage imageNamed:@"Edit"]]; [item setTarget:self]; - [item setAction:@selector(openResource:)]; + [item setAction:@selector(openResources:)]; return item; } - else if( [itemIdentifier isEqual:RKEditHexItemIdentifier] ) + else if( [itemIdentifier isEqualToString:RKEditHexItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Edit Hex", nil)]; [item setPaletteLabel:NSLocalizedString(@"Edit Hex", nil)]; [item setToolTip:NSLocalizedString(@"Edit Resource As Hexadecimal", nil)]; [item setImage:[NSImage imageNamed:@"Edit Hex"]]; [item setTarget:self]; - [item setAction:@selector(openResourceAsHex:)]; + [item setAction:@selector(openResourcesAsHex:)]; return item; } - else if( [itemIdentifier isEqual:RKSaveItemIdentifier] ) + else if( [itemIdentifier isEqualToString:RKSaveItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Save", nil)]; [item setPaletteLabel:NSLocalizedString(@"Save", nil)]; @@ -187,7 +189,7 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh [item setAction:@selector(saveDocument:)]; return item; } - else if( [itemIdentifier isEqual:RKShowInfoItemIdentifier] ) + else if( [itemIdentifier isEqualToString:RKShowInfoItemIdentifier] ) { [item setLabel:NSLocalizedString(@"Show Info", nil)]; [item setPaletteLabel:NSLocalizedString(@"Show Info", nil)]; @@ -236,6 +238,13 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh [sheetController showCreateResourceSheet:self]; } +- (IBAction)showSelectTemplateSheet:(id)sender +{ + // bug: ResourceDocument allocs a sheet controller, but it's never disposed of +// SelectTemplateSheetController *sheetController = [[CreateResourceSheetController alloc] initWithWindowNibName:@"SelectTemplateSheet"]; +// [sheetController showSelectTemplateSheet:self]; +} + - (IBAction)openResources:(id)sender { Resource *resource; @@ -271,13 +280,15 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh NSBundle *editor = [NSBundle bundleWithPath:[[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"NovaTools.plugin"]]; // open the resources, passing in the template to use - if( editor /* && [[editor principalClass] respondsToSelector:@selector(initWithResource:)] */ ) + if( editor /*&& [[editor principalClass] respondsToSelector:@selector(initWithResource:)]*/ ) { // bug: I alloc a plug instance here, but have no idea where I should dealloc it, perhaps the plug ought to call [self autorelease] when it's last window is closed? - [(id )[[editor principalClass] alloc] initWithResource:resource]; + id plug = [(id )[[editor principalClass] alloc] initWithResource:resource]; + if( plug ) return; } + // if no editor exists, or the editor is broken, open using template - else [self openResource:resource usingTemplate:[resource type]]; + [self openResource:resource usingTemplate:[resource type]]; } - (void)openResource:(Resource *)resource usingTemplate:(NSString *)templateName @@ -292,10 +303,12 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh if( tmpl && [[templateEditor principalClass] respondsToSelector:@selector(initWithResources:)] ) { // bug: I alloc a plug instance here, but have no idea where I should dealloc it, perhaps the plug ought to call [self autorelease] when it's last window is closed? - [(id )[[templateEditor principalClass] alloc] initWithResources:resource, tmpl, nil]; + id plug = [(id )[[templateEditor principalClass] alloc] initWithResources:resource, tmpl, nil]; + if( plug ) return; } + // if no template exists, or template editor is broken, open as hex - else [self openResourceAsHex:resource]; + [self openResourceAsHex:resource]; } - (void)openResourceAsHex:(Resource *)resource diff --git a/Cocoa/Classes/ResourceNameCell.m b/Cocoa/Classes/ResourceNameCell.m index 728dbc5..2d3528e 100644 --- a/Cocoa/Classes/ResourceNameCell.m +++ b/Cocoa/Classes/ResourceNameCell.m @@ -43,10 +43,11 @@ - (void)setImage:(NSImage *)newImage { // save image and set to 16x16 pixels - [image autorelease]; + id old = image; image = [newImage retain]; [image setScalesWhenResized:YES]; [image setSize:NSMakeSize(16,16)]; + [old autorelease]; } - (NSRect)imageFrameForCellFrame:(NSRect)cellFrame diff --git a/Cocoa/English.lproj/Application.nib/classes.nib b/Cocoa/English.lproj/Application.nib/classes.nib index 5ce1ae8..de7a0f3 100644 --- a/Cocoa/English.lproj/Application.nib/classes.nib +++ b/Cocoa/English.lproj/Application.nib/classes.nib @@ -16,7 +16,6 @@ openResources = id; openResourcesAsHex = id; openResourcesInTemplate = id; - openResourcesWithOtherTemplate = id; playSound = id; revertResourceToSaved = id; scrollToSelection = id; @@ -25,6 +24,7 @@ showFind = id; showInfo = id; showPrefs = id; + showSelectTemplateSheet = id; }; CLASS = FirstResponder; LANGUAGE = ObjC; diff --git a/Cocoa/English.lproj/Application.nib/info.nib b/Cocoa/English.lproj/Application.nib/info.nib index 28b9a71..759799f 100644 --- a/Cocoa/English.lproj/Application.nib/info.nib +++ b/Cocoa/English.lproj/Application.nib/info.nib @@ -7,15 +7,11 @@ IBEditorPositions 29 - -25 387 347 44 0 0 1024 746 + 59 443 347 44 0 0 1152 848 IBFramework Version 248.0 - IBOpenObjects - - 29 - IBSystem Version - 5Q45 + 5Q110 diff --git a/Cocoa/English.lproj/Application.nib/objects.nib b/Cocoa/English.lproj/Application.nib/objects.nib index 0825b703098f745a2672fe554f66ebf5f63081ef..65a000dbe65e908aa382706f4fa303ac3599a3e3 100644 GIT binary patch literal 7050 zcmb_heQ;FO6~F5yF$wt)!I+UL-7!-gtOJb}s*oA71T@i-#B4NEDVAmTC0W_*+wQ(4 z;I!3CH*Y%AKWsC}9f_+=Q>%Ef$cUw-g%(nM~6fBh%l-jZ_Efq#O3{&mz+_&%T zZo(#YM$OE9d(Q8C+;h&o_uNa#EMs$23&xF@<{#khvq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#6Dpg@ zvq_IiNV-rt>Mtnu6mNPK$(go{=yQl}b?kPt?(f#LT$Z1Aq}3CQqqUvr)!6`3=jL$k zB~GoiOxbS8k4d5q;C=$!j!l*2+Rc-Cxo!`@-@KG;RN81wZ2RJkakR^hwg(7MsmDTE zj5;KTevIhVq3k5daZNFr-|$)vi&6Iu+9+c7Gm9p%Y^gz z=J3xdeq24TVbRrtCcQD*rKg4X+2pXjo0uG{33Gda|1_B@5cZA3QMii0a|*z%(MhQJ zgqqn)S6w?L9Stjp=PuAd4_f^roIRSnsUiG2XWx`5&YqPEbjjIC&W>R?&)Eg}HfOu! zTFzdT2RZwpJj2;{z&gg+5xE~pE1}|-@*U0|llOD>7rBhH6LR50@(^cF0{3V9VE74V z&&!V4a>iHj%YQh#EEoIb63&jx&78e1uX6Tvxupxd=Qw*D!$0sNPjj|gp5SbcbhXH4 z&RzlIGG~`C?7jnkeeXW}^*(3+#_&_leuUvTXGdjiue{zN(|6j#_-V1V!Epv@eeu@ik|~@&m;08 zXJ3;QUy+->AYsh6WFu#9N`&KWc?2c_^D1Y*mzbF2`$Z^{%Q+jz_is6SNnYa2#P_?L zy(4SdrEd;?`4wk}G5nXa_vAUaBIo&J<{tS1XQR@+UY=hG=2IV&50+y*%h_vk90#17 z-zMun3d$Rt{Z+Pbc1rH$>=z(pIJ<%Y;s@llRvF^#53=sFayEoz*_Xk2p0j;&l(V1V z`(@64jo}r}ej|?}Byz|l*VlpqH{X(rIQyXIDqq0M3t^)-_FfP!Ft&1$wkTo&F8!f3e^>TL1t6 diff --git a/Cocoa/Plug-Ins/Hex Editor/HexWindowController.m b/Cocoa/Plug-Ins/Hex Editor/HexWindowController.m index 836cbcc..d453239 100644 --- a/Cocoa/Plug-Ins/Hex Editor/HexWindowController.m +++ b/Cocoa/Plug-Ins/Hex Editor/HexWindowController.m @@ -161,8 +161,8 @@ NSString *ResourceDidChangeNotification = @"ResourceDidChangeNotification"; [[ascii textStorage] addAttributes:dictionary range:NSMakeRange(0, [[ascii textStorage] length])]; // restore selections (this is the dumbest way to do it, but it'll do for now) - [hex setSelectedRange:hexSelection]; - [ascii setSelectedRange:asciiSelection]; + [hex setSelectedRange:NSIntersectionRange(hexSelection, [hex selectedRange])]; + [ascii setSelectedRange:NSIntersectionRange(asciiSelection, [ascii selectedRange])]; // restore delegates [hex setDelegate:oldDelegate]; @@ -184,4 +184,4 @@ NSString *ResourceDidChangeNotification = @"ResourceDidChangeNotification"; return bytesPerRow; } -@end +@end \ No newline at end of file diff --git a/External/MoreFilesX/MoreFilesX.c b/External/MoreFilesX/MoreFilesX.c index 901ef56..9642752 100644 --- a/External/MoreFilesX/MoreFilesX.c +++ b/External/MoreFilesX/MoreFilesX.c @@ -1 +1,2782 @@ -/* 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 Copyright: © 1992-2002 by Apple Computer, Inc., all rights reserved. You may incorporate this sample code into your applications without restriction, though the sample code has been provided "AS IS" and the responsibility for its operation is 100% yours. However, what you are not permitted to do is to redistribute the source as "DSC Sample Code" after having made changes. If you're going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple Sample Code, but that you've made changes. File Ownership: DRI: Apple Macintosh Developer Technical Support Other Contact: 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): <1> 1/25/02 JL MoreFilesX 1.0 */ #if 0 #include #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #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 DeleteLevel( 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: DestinationFSAllocateForkFailed: 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 */ StrLength(hfsName) = 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); StrLength(hfsName) = (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; long tempItemsDirID; Str31 uniqueTempDirName; long uniqueTempDirID; FSRef uniqueTempDirRef; /* 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 lot of steps if we're not renaming */ if ( NULL != name ) { /* find the Temporary Items Folder on sourcevRefNum */ result = FindFolder(vRefNum, kTemporaryFolderType, kCreateFolder, &vRefNum, &tempItemsDirID); require_noerr(result, NoTemporaryFolder); /* Create a new uniquely named folder in the temporary items folder. */ /* This is done to avoid the case where 'realName' or 'copyName' already */ /* exists in the temporary items folder. */ /* Start with 'A' plus the current tick count as uniqueTempDirName */ NumToString(TickCount(), &uniqueTempDirName[1]); uniqueTempDirName[0] = uniqueTempDirName[1] + 1; uniqueTempDirName[1] = 'A'; do { result = DirCreate(vRefNum, tempItemsDirID, uniqueTempDirName, &uniqueTempDirID); if ( dupFNErr == result ) { /* Duplicate name - change the first character to the next ASCII character */ ++uniqueTempDirName[1]; } } while ( (dupFNErr == result) && (uniqueTempDirName[1] < 'Z') ); /* 26 new weirdly named directories per 1/60th second - not likely! */ require_noerr(result, CouldNotCreateUniqueTempDir); /* get FSRef to UniqueTempDir */ result = FSMakeFSRef(vRefNum, uniqueTempDirID, NULL, &uniqueTempDirRef); require_noerr(result, FSMakeFSRef); /* Move the object to the folder with uniqueTempDirRef for renaming */ result = FSMoveObject(ref, &uniqueTempDirRef, newRef); require_noerr(result, FSMoveObjectBeforeRenameFailed); /* Rename the object */ result = FSRenameUnicode(newRef, nameLength, name, textEncodingHint, newRef); require_noerr(result, FSRenameUnicode); /* Move object to its new home */ result = FSMoveObject(newRef, destDirectory, newRef); require_noerr(result, FSMoveObjectAfterRenameFailed); /* Done with ourTempDir, so delete it - ignore errors */ verify_noerr(HDelete(vRefNum, uniqueTempDirID, NULL)); } else { /* Move object to its new home */ result = FSMoveObject(newRef, destDirectory, newRef); require_noerr(result, FSMoveObjectNoRenameFailed); } return ( result ); /*************/ /* * failure handling code when renaming */ FSMoveObjectAfterRenameFailed: /* Error handling: rename object back to original name - ignore errors */ verify_noerr(FSRenameUnicode(newRef, originalName.length, originalName.unicode, originalTextEncodingHint, newRef)); FSRenameUnicode: /* Error handling: move object back to original location - ignore errors */ verify_noerr(FSMoveObject(newRef, &originalDirectory, newRef)); FSMoveObjectBeforeRenameFailed: FSMakeFSRef: /* Done with ourTempDir, so delete it - ignore errors */ verify_noerr(HDelete(vRefNum, uniqueTempDirID, NULL)); CouldNotCreateUniqueTempDir: NoTemporaryFolder: /* * 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[16] = "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 */ result = FSSetCatalogInfo(&sourceCurrentRef, kSetCatinformationMask, &destCatalogInfo); require_noerr(result, FSSetCatalogInfo1Failed); /* give dest file the source file's catalog information except for mod dates */ result = FSSetCatalogInfo(&destCurrentRef, kSetCatinformationMask, &sourceCatalogInfo); require_noerr(result, FSSetCatalogInfo2Failed); /* rename source file with dest file's name */ result = FSRenameUnicode(&sourceCurrentRef, destName.length, destName.unicode, destCatalogInfo.textEncodingHint, newSourceRef); require_noerr(result, FSRenameUnicode3Failed); BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); /* rename dest file with source file's name */ result = FSRenameUnicode(&destCurrentRef, sourceName.length, sourceName.unicode, sourceCatalogInfo.textEncodingHint, newDestRef); require_noerr(result, FSRenameUnicode4Failed); /* we're done with no errors, so swap newSourceRef and newDestRef */ BlockMoveData(newDestRef, newSourceRef, sizeof(FSRef)); BlockMoveData(&sourceCurrentRef, newDestRef, sizeof(FSRef)); } return ( result ); /**********************/ /* If there are any failures while emulating FSExchangeObjects, attempt to reverse any steps */ /* already taken. In any case, newSourceRef and newDestRef will refer to the files in whatever */ /* state and location they ended up in so that both files can be found by the calling code. */ FSRenameUnicode4Failed: /* attempt to rename source file to sourceUniqueName */ if ( noErr == FSRenameUnicode(&sourceCurrentRef, sourceUniqueName.length, sourceUniqueName.unicode, kTextEncodingUnknown, newSourceRef) ) { BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); } FSRenameUnicode3Failed: /* attempt to restore dest file's catalog information */ verify_noerr(FSSetCatalogInfo(&destCurrentRef, kFSCatInfoSettableInfo, &destCatalogInfo)); FSSetCatalogInfo2Failed: /* attempt to restore source file's catalog information */ verify_noerr(FSSetCatalogInfo(&sourceCurrentRef, kFSCatInfoSettableInfo, &sourceCatalogInfo)); FSSetCatalogInfo1Failed: if ( !sameParentDirs ) { /* attempt to move dest file back to dest directory */ if ( noErr == FSMoveObject(&destCurrentRef, &destParentRef, newDestRef) ) { BlockMoveData(newDestRef, &destCurrentRef, sizeof(FSRef)); } } FSMoveObject2Failed: if ( !sameParentDirs ) { /* attempt to move source file back to source directory */ if ( noErr == FSMoveObject(&sourceCurrentRef, &sourceParentRef, newSourceRef) ) { BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); } } FSMoveObject1Failed: /* attempt to rename dest file to original name */ verify_noerr(FSRenameUnicode(&destCurrentRef, destName.length, destName.unicode, destCatalogInfo.textEncodingHint, newDestRef)); FSRenameUnicode2Failed: /* attempt to rename source file to original name */ verify_noerr(FSRenameUnicode(&sourceCurrentRef, sourceName.length, sourceName.unicode, sourceCatalogInfo.textEncodingHint, newSourceRef)); FSRenameUnicode1Failed: GenerateUniqueHFSUniStr2Failed: GenerateUniqueHFSUniStr1Failed: NotAFile: NotSameVolume: DestFSGetCatalogInfoFailed: SourceFSGetCatalogInfoFailed: FSGetVolParmsFailed: DetermineSourceVRefNumFailed: BadParameter: return ( result ); } /*****************************************************************************/ #pragma mark ----- Shared Environment Routines ----- /*****************************************************************************/ OSErr FSLockRange( SInt16 refNum, SInt32 rangeLength, SInt32 rangeStart) { OSErr result; ParamBlockRec pb; pb.ioParam.ioRefNum = refNum; pb.ioParam.ioReqCount = rangeLength; pb.ioParam.ioPosMode = fsFromStart; pb.ioParam.ioPosOffset = rangeStart; result = PBLockRangeSync(&pb); require_noerr(result, PBLockRangeSync); PBLockRangeSync: return ( result ); } /*****************************************************************************/ OSErr FSUnlockRange( SInt16 refNum, SInt32 rangeLength, SInt32 rangeStart) { OSErr result; ParamBlockRec pb; pb.ioParam.ioRefNum = refNum; pb.ioParam.ioReqCount = rangeLength; pb.ioParam.ioPosMode = fsFromStart; pb.ioParam.ioPosOffset = rangeStart; result = PBUnlockRangeSync(&pb); require_noerr(result, PBUnlockRangeSync); PBUnlockRangeSync: return ( result ); } /*****************************************************************************/ OSErr FSGetDirAccess( const FSRef *ref, SInt32 *ownerID, /* can be NULL */ SInt32 *groupID, /* can be NULL */ SInt32 *accessRights) /* can be NULL */ { OSErr result; FSSpec spec; HParamBlockRec pb; /* get FSSpec from FSRef */ result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); require_noerr(result, FSGetCatalogInfo); /* get directory access info for FSSpec */ pb.accessParam.ioNamePtr = (StringPtr)spec.name; pb.accessParam.ioVRefNum = spec.vRefNum; pb.fileParam.ioDirID = spec.parID; result = PBHGetDirAccessSync(&pb); require_noerr(result, PBHGetDirAccessSync); /* return the IDs and access rights */ if ( NULL != ownerID ) { *ownerID = pb.accessParam.ioACOwnerID; } if ( NULL != groupID ) { *groupID = pb.accessParam.ioACGroupID; } if ( NULL != accessRights ) { *accessRights = pb.accessParam.ioACAccess; } PBHGetDirAccessSync: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSSetDirAccess( const FSRef *ref, SInt32 ownerID, SInt32 groupID, SInt32 accessRights) { OSErr result; FSSpec spec; HParamBlockRec pb; enum { /* Just the bits that can be set */ kSetDirAccessSettableMask = (kioACAccessBlankAccessMask + kioACAccessEveryoneWriteMask + kioACAccessEveryoneReadMask + kioACAccessEveryoneSearchMask + kioACAccessGroupWriteMask + kioACAccessGroupReadMask + kioACAccessGroupSearchMask + kioACAccessOwnerWriteMask + kioACAccessOwnerReadMask + kioACAccessOwnerSearchMask) }; /* get FSSpec from FSRef */ result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); require_noerr(result, FSGetCatalogInfo); /* set directory access info for FSSpec */ pb.accessParam.ioNamePtr = (StringPtr)spec.name; pb.accessParam.ioVRefNum = spec.vRefNum; pb.fileParam.ioDirID = spec.parID; pb.accessParam.ioACOwnerID = ownerID; pb.accessParam.ioACGroupID = groupID; pb.accessParam.ioACAccess = accessRights & kSetDirAccessSettableMask; result = PBHSetDirAccessSync(&pb); require_noerr(result, PBHSetDirAccessSync); PBHSetDirAccessSync: FSGetCatalogInfo: return ( result ); } /*****************************************************************************/ OSErr FSGetVolMountInfoSize( FSVolumeRefNum volRefNum, SInt16 *size) { OSErr result; ParamBlockRec pb; /* check parameters */ require_action(NULL != size, BadParameter, result = paramErr); pb.ioParam.ioNamePtr = NULL; pb.ioParam.ioVRefNum = volRefNum; pb.ioParam.ioBuffer = (Ptr)size; result = PBGetVolMountInfoSize(&pb); require_noerr(result, PBGetVolMountInfoSize); PBGetVolMountInfoSize: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSGetVolMountInfo( FSVolumeRefNum volRefNum, void *volMountInfo) { OSErr result; ParamBlockRec pb; /* check parameters */ require_action(NULL != volMountInfo, BadParameter, result = paramErr); pb.ioParam.ioNamePtr = NULL; pb.ioParam.ioVRefNum = volRefNum; pb.ioParam.ioBuffer = (Ptr)volMountInfo; result = PBGetVolMountInfo(&pb); require_noerr(result, PBGetVolMountInfo); PBGetVolMountInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSVolumeMount( const void *volMountInfo, FSVolumeRefNum *volRefNum) { OSErr result; ParamBlockRec pb; /* check parameters */ require_action(NULL != volRefNum, BadParameter, result = paramErr); pb.ioParam.ioBuffer = (Ptr)volMountInfo; result = PBVolumeMount(&pb); require_noerr(result, PBVolumeMount); /* return the volume reference number */ *volRefNum = pb.ioParam.ioVRefNum; PBVolumeMount: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSMapID( FSVolumeRefNum volRefNum, SInt32 ugID, SInt16 objType, Str31 name) { OSErr result; HParamBlockRec pb; /* check parameters */ require_action(NULL != name, BadParameter, result = paramErr); pb.objParam.ioNamePtr = NULL; pb.objParam.ioVRefNum = volRefNum; pb.objParam.ioObjType = objType; pb.objParam.ioObjNamePtr = name; pb.objParam.ioObjID = ugID; result = PBHMapIDSync(&pb); require_noerr(result, PBHMapIDSync); PBHMapIDSync: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSMapName( FSVolumeRefNum volRefNum, ConstStr255Param name, SInt16 objType, SInt32 *ugID) { OSErr result; HParamBlockRec pb; /* check parameters */ require_action(NULL != ugID, BadParameter, result = paramErr); pb.objParam.ioNamePtr = NULL; pb.objParam.ioVRefNum = volRefNum; pb.objParam.ioObjType = objType; pb.objParam.ioObjNamePtr = (StringPtr)name; result = PBHMapNameSync(&pb); require_noerr(result, PBHMapNameSync); /* return the user or group ID */ *ugID = pb.objParam.ioObjID; PBHMapNameSync: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSCopyFile( const FSRef *srcFileRef, const FSRef *dstDirectoryRef, UniCharCount nameLength, const UniChar *copyName, /* can be NULL (no rename during copy) */ TextEncoding textEncodingHint, FSRef *newRef) /* can be NULL */ { OSErr result; FSSpec srcFileSpec; FSCatalogInfo catalogInfo; HParamBlockRec pb; Str31 hfsName; GetVolParmsInfoBuffer volParmsInfo; UInt32 infoSize; /* get source FSSpec from source FSRef */ result = FSGetCatalogInfo(srcFileRef, kFSCatInfoNone, NULL, NULL, &srcFileSpec, NULL); require_noerr(result, FSGetCatalogInfo_srcFileRef); /* Make sure the volume supports CopyFile */ result = FSGetVolParms(srcFileSpec.vRefNum, sizeof(GetVolParmsInfoBuffer), &volParmsInfo, &infoSize); require_action((noErr == result) && VolHasCopyFile(&volParmsInfo), NoCopyFileSupport, result = paramErr); /* get destination volume reference number and destination directory ID from destination FSRef */ result = FSGetCatalogInfo(dstDirectoryRef, kFSCatInfoVolume + kFSCatInfoNodeID, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo_dstDirectoryRef); /* tell the server to copy the object */ pb.copyParam.ioVRefNum = srcFileSpec.vRefNum; pb.copyParam.ioDirID = srcFileSpec.parID; pb.copyParam.ioNamePtr = (StringPtr)srcFileSpec.name; pb.copyParam.ioDstVRefNum = catalogInfo.volume; pb.copyParam.ioNewDirID = (long)catalogInfo.nodeID; pb.copyParam.ioNewName = NULL; if ( NULL != copyName ) { result = UnicodeNameGetHFSName(nameLength, copyName, textEncodingHint, false, hfsName); require_noerr(result, UnicodeNameGetHFSName); pb.copyParam.ioCopyName = hfsName; } else { pb.copyParam.ioCopyName = NULL; } result = PBHCopyFileSync(&pb); require_noerr(result, PBHCopyFileSync); if ( NULL != newRef ) { verify_noerr(FSMakeFSRef(pb.copyParam.ioDstVRefNum, pb.copyParam.ioNewDirID, pb.copyParam.ioCopyName, newRef)); } PBHCopyFileSync: UnicodeNameGetHFSName: FSGetCatalogInfo_dstDirectoryRef: NoCopyFileSupport: FSGetCatalogInfo_srcFileRef: return ( result ); } /*****************************************************************************/ OSErr FSMoveRename( const FSRef *srcFileRef, const FSRef *dstDirectoryRef, UniCharCount nameLength, const UniChar *moveName, /* can be NULL (no rename during move) */ TextEncoding textEncodingHint, FSRef *newRef) /* can be NULL */ { OSErr result; FSSpec srcFileSpec; FSCatalogInfo catalogInfo; HParamBlockRec pb; Str31 hfsName; GetVolParmsInfoBuffer volParmsInfo; UInt32 infoSize; /* get source FSSpec from source FSRef */ result = FSGetCatalogInfo(srcFileRef, kFSCatInfoNone, NULL, NULL, &srcFileSpec, NULL); require_noerr(result, FSGetCatalogInfo_srcFileRef); /* Make sure the volume supports MoveRename */ result = FSGetVolParms(srcFileSpec.vRefNum, sizeof(GetVolParmsInfoBuffer), &volParmsInfo, &infoSize); require_action((noErr == result) && VolHasMoveRename(&volParmsInfo), NoMoveRenameSupport, result = paramErr); /* get destination volume reference number and destination directory ID from destination FSRef */ result = FSGetCatalogInfo(dstDirectoryRef, kFSCatInfoVolume + kFSCatInfoNodeID, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo_dstDirectoryRef); /* make sure the source and destination are on the same volume */ require_action(srcFileSpec.vRefNum == catalogInfo.volume, NotSameVolume, result = diffVolErr); /* tell the server to move and rename the object */ pb.copyParam.ioVRefNum = srcFileSpec.vRefNum; pb.copyParam.ioDirID = srcFileSpec.parID; pb.copyParam.ioNamePtr = (StringPtr)srcFileSpec.name; pb.copyParam.ioNewDirID = (long)catalogInfo.nodeID; pb.copyParam.ioNewName = NULL; if ( NULL != moveName ) { result = UnicodeNameGetHFSName(nameLength, moveName, textEncodingHint, false, hfsName); require_noerr(result, UnicodeNameGetHFSName); pb.copyParam.ioCopyName = hfsName; } else { pb.copyParam.ioCopyName = NULL; } result = PBHMoveRenameSync(&pb); require_noerr(result, PBHMoveRenameSync); if ( NULL != newRef ) { verify_noerr(FSMakeFSRef(pb.copyParam.ioVRefNum, pb.copyParam.ioNewDirID, pb.copyParam.ioCopyName, newRef)); } PBHMoveRenameSync: UnicodeNameGetHFSName: NotSameVolume: FSGetCatalogInfo_dstDirectoryRef: NoMoveRenameSupport: FSGetCatalogInfo_srcFileRef: return ( result ); } /*****************************************************************************/ #pragma mark ----- File ID Routines ----- /*****************************************************************************/ OSErr FSResolveFileIDRef( FSVolumeRefNum volRefNum, SInt32 fileID, FSRef *ref) { OSErr result; FIDParam pb; Str255 tempStr; /* check parameters */ require_action(NULL != ref, BadParameter, result = paramErr); /* resolve the file ID reference */ StrLength(tempStr) = 0; pb.ioNamePtr = tempStr; pb.ioVRefNum = volRefNum; pb.ioFileID = fileID; result = PBResolveFileIDRefSync((HParmBlkPtr)&pb); require_noerr(result, PBResolveFileIDRefSync); /* and then make an FSRef to the file */ result = FSMakeFSRef(volRefNum, pb.ioSrcDirID, tempStr, ref); require_noerr(result, FSMakeFSRef); FSMakeFSRef: PBResolveFileIDRefSync: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSCreateFileIDRef( const FSRef *ref, SInt32 *fileID) { OSErr result; FSSpec spec; FIDParam pb; /* check parameters */ require_action(NULL != fileID, BadParameter, result = paramErr); /* Get an FSSpec from the FSRef */ result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); require_noerr(result, FSGetCatalogInfo); /* Create (or get) the file ID reference using the FSSpec */ pb.ioNamePtr = (StringPtr)spec.name; pb.ioVRefNum = spec.vRefNum; pb.ioSrcDirID = spec.parID; result = PBCreateFileIDRefSync((HParmBlkPtr)&pb); require((noErr == result) || (fidExists == result) || (afpIDExists == result), PBCreateFileIDRefSync); /* return the file ID reference */ *fileID = pb.ioFileID; PBCreateFileIDRefSync: FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ #pragma mark ----- Utility Routines ----- /*****************************************************************************/ Ptr GetTempBuffer( ByteCount buffReqSize, ByteCount *buffActSize) { enum { kSlopMemory = 0x00008000 /* 32K - Amount of free memory to leave when allocating buffers */ }; Ptr tempPtr; /* check parameters */ require_action(NULL != buffActSize, BadParameter, tempPtr = NULL); /* Make request a multiple of 4K bytes */ buffReqSize = buffReqSize & 0xfffff000; if ( buffReqSize < 0x00001000 ) { /* Request was smaller than 4K bytes - make it 4K */ buffReqSize = 0x00001000; } /* Attempt to allocate the memory */ tempPtr = NewPtr(buffReqSize); /* If request failed, go to backup plan */ if ( (tempPtr == NULL) && (buffReqSize > 0x00001000) ) { /* ** Try to get largest 4K byte block available ** leaving some slop for the toolbox if possible */ long freeMemory = (FreeMem() - kSlopMemory) & 0xfffff000; buffReqSize = MaxBlock() & 0xfffff000; if ( buffReqSize > freeMemory ) { buffReqSize = freeMemory; } if ( buffReqSize == 0 ) { buffReqSize = 0x00001000; } tempPtr = NewPtr(buffReqSize); } /* Return bytes allocated */ if ( tempPtr != NULL ) { *buffActSize = buffReqSize; } else { *buffActSize = 0; } BadParameter: return ( tempPtr ); } /*****************************************************************************/ OSErr FileRefNumGetFSRef( short refNum, FSRef *ref) { return ( FSGetForkCBInfo(refNum, 0, NULL, NULL, NULL, ref, NULL) ); } /*****************************************************************************/ OSErr FSSetDefault( const FSRef *newDefault, FSRef *oldDefault) { OSErr result; FSVolumeRefNum vRefNum; long dirID; FSCatalogInfo catalogInfo; /* check parameters */ require_action((NULL != newDefault) && (NULL != oldDefault), BadParameter, result = paramErr); /* Get nodeFlags, vRefNum and dirID (nodeID) of newDefault */ result = FSGetCatalogInfo(newDefault, kFSCatInfoNodeFlags + kFSCatInfoVolume + kFSCatInfoNodeID, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); /* Make sure newDefault is a directory */ require_action(0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags), NewDefaultNotDirectory, result = dirNFErr); /* Get the current working directory. */ result = HGetVol(NULL, &vRefNum, &dirID); require_noerr(result, HGetVol); /* Return the oldDefault FSRef */ result = FSMakeFSRef(vRefNum, dirID, NULL, oldDefault); require_noerr(result, FSMakeFSRef); /* Set the new current working directory */ result = HSetVol(NULL, catalogInfo.volume, catalogInfo.nodeID); require_noerr(result, HSetVol); HSetVol: FSMakeFSRef: HGetVol: NewDefaultNotDirectory: FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ OSErr FSRestoreDefault( const FSRef *oldDefault) { OSErr result; FSCatalogInfo catalogInfo; /* check parameters */ require_action(NULL != oldDefault, BadParameter, result = paramErr); /* Get nodeFlags, vRefNum and dirID (nodeID) of oldDefault */ result = FSGetCatalogInfo(oldDefault, kFSCatInfoNodeFlags + kFSCatInfoVolume + kFSCatInfoNodeID, &catalogInfo, NULL, NULL, NULL); require_noerr(result, FSGetCatalogInfo); /* Make sure oldDefault is a directory */ require_action(0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags), OldDefaultNotDirectory, result = dirNFErr); /* Set the current working directory to oldDefault */ result = HSetVol(NULL, catalogInfo.volume, catalogInfo.nodeID); require_noerr(result, HSetVol); HSetVol: OldDefaultNotDirectory: FSGetCatalogInfo: BadParameter: return ( result ); } /*****************************************************************************/ \ No newline at end of file +/* + 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 + + Copyright: © 1992-2002 by Apple Computer, Inc., all rights reserved. + + You may incorporate this sample code into your applications without + restriction, though the sample code has been provided "AS IS" and the + responsibility for its operation is 100% yours. However, what you are + not permitted to do is to redistribute the source as "DSC Sample Code" + after having made changes. If you're going to re-distribute the source, + we require that you make it clear in the source that the code was + descended from Apple Sample Code, but that you've made changes. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: 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): + + <1> 1/25/02 JL MoreFilesX 1.0 +*/ + +#if 1 + #include +#else + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#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 +DeleteLevel( + 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: +DestinationFSAllocateForkFailed: +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 */ + StrLength(hfsName) = 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); + + StrLength(hfsName) = (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; + long tempItemsDirID; + Str31 uniqueTempDirName; + long uniqueTempDirID; + FSRef uniqueTempDirRef; + + /* 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 lot of steps if we're not renaming */ + if ( NULL != name ) + { + /* find the Temporary Items Folder on sourcevRefNum */ + result = FindFolder(vRefNum, kTemporaryFolderType, kCreateFolder, &vRefNum, &tempItemsDirID); + require_noerr(result, NoTemporaryFolder); + + /* Create a new uniquely named folder in the temporary items folder. */ + /* This is done to avoid the case where 'realName' or 'copyName' already */ + /* exists in the temporary items folder. */ + + /* Start with 'A' plus the current tick count as uniqueTempDirName */ + NumToString(TickCount(), &uniqueTempDirName[1]); + uniqueTempDirName[0] = uniqueTempDirName[1] + 1; + uniqueTempDirName[1] = 'A'; + do + { + result = DirCreate(vRefNum, tempItemsDirID, uniqueTempDirName, &uniqueTempDirID); + if ( dupFNErr == result ) + { + /* Duplicate name - change the first character to the next ASCII character */ + ++uniqueTempDirName[1]; + } + } while ( (dupFNErr == result) && (uniqueTempDirName[1] < 'Z') ); /* 26 new weirdly named directories per 1/60th second - not likely! */ + require_noerr(result, CouldNotCreateUniqueTempDir); + + /* get FSRef to UniqueTempDir */ + result = FSMakeFSRef(vRefNum, uniqueTempDirID, NULL, &uniqueTempDirRef); + require_noerr(result, FSMakeFSRef); + + /* Move the object to the folder with uniqueTempDirRef for renaming */ + result = FSMoveObject(ref, &uniqueTempDirRef, newRef); + require_noerr(result, FSMoveObjectBeforeRenameFailed); + + /* Rename the object */ + result = FSRenameUnicode(newRef, nameLength, name, textEncodingHint, newRef); + require_noerr(result, FSRenameUnicode); + + /* Move object to its new home */ + result = FSMoveObject(newRef, destDirectory, newRef); + require_noerr(result, FSMoveObjectAfterRenameFailed); + + /* Done with ourTempDir, so delete it - ignore errors */ + verify_noerr(HDelete(vRefNum, uniqueTempDirID, NULL)); + } + else + { + /* Move object to its new home */ + result = FSMoveObject(newRef, destDirectory, newRef); + require_noerr(result, FSMoveObjectNoRenameFailed); + } + + return ( result ); + + /*************/ + +/* + * failure handling code when renaming + */ +FSMoveObjectAfterRenameFailed: + + /* Error handling: rename object back to original name - ignore errors */ + verify_noerr(FSRenameUnicode(newRef, originalName.length, originalName.unicode, originalTextEncodingHint, newRef)); + +FSRenameUnicode: + + /* Error handling: move object back to original location - ignore errors */ + verify_noerr(FSMoveObject(newRef, &originalDirectory, newRef)); + +FSMoveObjectBeforeRenameFailed: +FSMakeFSRef: + + /* Done with ourTempDir, so delete it - ignore errors */ + verify_noerr(HDelete(vRefNum, uniqueTempDirID, NULL)); + +CouldNotCreateUniqueTempDir: +NoTemporaryFolder: + +/* + * 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[16] = "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 */ + result = FSSetCatalogInfo(&sourceCurrentRef, kSetCatinformationMask, &destCatalogInfo); + require_noerr(result, FSSetCatalogInfo1Failed); + + /* give dest file the source file's catalog information except for mod dates */ + result = FSSetCatalogInfo(&destCurrentRef, kSetCatinformationMask, &sourceCatalogInfo); + require_noerr(result, FSSetCatalogInfo2Failed); + + /* rename source file with dest file's name */ + result = FSRenameUnicode(&sourceCurrentRef, destName.length, destName.unicode, destCatalogInfo.textEncodingHint, newSourceRef); + require_noerr(result, FSRenameUnicode3Failed); + BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); + + /* rename dest file with source file's name */ + result = FSRenameUnicode(&destCurrentRef, sourceName.length, sourceName.unicode, sourceCatalogInfo.textEncodingHint, newDestRef); + require_noerr(result, FSRenameUnicode4Failed); + + /* we're done with no errors, so swap newSourceRef and newDestRef */ + BlockMoveData(newDestRef, newSourceRef, sizeof(FSRef)); + BlockMoveData(&sourceCurrentRef, newDestRef, sizeof(FSRef)); + } + + return ( result ); + + /**********************/ + +/* If there are any failures while emulating FSExchangeObjects, attempt to reverse any steps */ +/* already taken. In any case, newSourceRef and newDestRef will refer to the files in whatever */ +/* state and location they ended up in so that both files can be found by the calling code. */ + +FSRenameUnicode4Failed: + + /* attempt to rename source file to sourceUniqueName */ + if ( noErr == FSRenameUnicode(&sourceCurrentRef, sourceUniqueName.length, sourceUniqueName.unicode, kTextEncodingUnknown, newSourceRef) ) + { + BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); + } + +FSRenameUnicode3Failed: + + /* attempt to restore dest file's catalog information */ + verify_noerr(FSSetCatalogInfo(&destCurrentRef, kFSCatInfoSettableInfo, &destCatalogInfo)); + +FSSetCatalogInfo2Failed: + + /* attempt to restore source file's catalog information */ + verify_noerr(FSSetCatalogInfo(&sourceCurrentRef, kFSCatInfoSettableInfo, &sourceCatalogInfo)); + +FSSetCatalogInfo1Failed: + + if ( !sameParentDirs ) + { + /* attempt to move dest file back to dest directory */ + if ( noErr == FSMoveObject(&destCurrentRef, &destParentRef, newDestRef) ) + { + BlockMoveData(newDestRef, &destCurrentRef, sizeof(FSRef)); + } + } + +FSMoveObject2Failed: + + if ( !sameParentDirs ) + { + /* attempt to move source file back to source directory */ + if ( noErr == FSMoveObject(&sourceCurrentRef, &sourceParentRef, newSourceRef) ) + { + BlockMoveData(newSourceRef, &sourceCurrentRef, sizeof(FSRef)); + } + } + +FSMoveObject1Failed: + + /* attempt to rename dest file to original name */ + verify_noerr(FSRenameUnicode(&destCurrentRef, destName.length, destName.unicode, destCatalogInfo.textEncodingHint, newDestRef)); + +FSRenameUnicode2Failed: + + /* attempt to rename source file to original name */ + verify_noerr(FSRenameUnicode(&sourceCurrentRef, sourceName.length, sourceName.unicode, sourceCatalogInfo.textEncodingHint, newSourceRef)); + +FSRenameUnicode1Failed: +GenerateUniqueHFSUniStr2Failed: +GenerateUniqueHFSUniStr1Failed: +NotAFile: +NotSameVolume: +DestFSGetCatalogInfoFailed: +SourceFSGetCatalogInfoFailed: +FSGetVolParmsFailed: +DetermineSourceVRefNumFailed: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +#pragma mark ----- Shared Environment Routines ----- + +/*****************************************************************************/ + +OSErr +FSLockRange( + SInt16 refNum, + SInt32 rangeLength, + SInt32 rangeStart) +{ + OSErr result; + ParamBlockRec pb; + + pb.ioParam.ioRefNum = refNum; + pb.ioParam.ioReqCount = rangeLength; + pb.ioParam.ioPosMode = fsFromStart; + pb.ioParam.ioPosOffset = rangeStart; + result = PBLockRangeSync(&pb); + require_noerr(result, PBLockRangeSync); + +PBLockRangeSync: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSUnlockRange( + SInt16 refNum, + SInt32 rangeLength, + SInt32 rangeStart) +{ + OSErr result; + ParamBlockRec pb; + + pb.ioParam.ioRefNum = refNum; + pb.ioParam.ioReqCount = rangeLength; + pb.ioParam.ioPosMode = fsFromStart; + pb.ioParam.ioPosOffset = rangeStart; + result = PBUnlockRangeSync(&pb); + require_noerr(result, PBUnlockRangeSync); + +PBUnlockRangeSync: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSGetDirAccess( + const FSRef *ref, + SInt32 *ownerID, /* can be NULL */ + SInt32 *groupID, /* can be NULL */ + SInt32 *accessRights) /* can be NULL */ +{ + OSErr result; + FSSpec spec; + HParamBlockRec pb; + + /* get FSSpec from FSRef */ + result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); + require_noerr(result, FSGetCatalogInfo); + + /* get directory access info for FSSpec */ + pb.accessParam.ioNamePtr = (StringPtr)spec.name; + pb.accessParam.ioVRefNum = spec.vRefNum; + pb.fileParam.ioDirID = spec.parID; + result = PBHGetDirAccessSync(&pb); + require_noerr(result, PBHGetDirAccessSync); + + /* return the IDs and access rights */ + if ( NULL != ownerID ) + { + *ownerID = pb.accessParam.ioACOwnerID; + } + if ( NULL != groupID ) + { + *groupID = pb.accessParam.ioACGroupID; + } + if ( NULL != accessRights ) + { + *accessRights = pb.accessParam.ioACAccess; + } + +PBHGetDirAccessSync: +FSGetCatalogInfo: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSSetDirAccess( + const FSRef *ref, + SInt32 ownerID, + SInt32 groupID, + SInt32 accessRights) +{ + OSErr result; + FSSpec spec; + HParamBlockRec pb; + + enum + { + /* Just the bits that can be set */ + kSetDirAccessSettableMask = (kioACAccessBlankAccessMask + + kioACAccessEveryoneWriteMask + kioACAccessEveryoneReadMask + kioACAccessEveryoneSearchMask + + kioACAccessGroupWriteMask + kioACAccessGroupReadMask + kioACAccessGroupSearchMask + + kioACAccessOwnerWriteMask + kioACAccessOwnerReadMask + kioACAccessOwnerSearchMask) + }; + + /* get FSSpec from FSRef */ + result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); + require_noerr(result, FSGetCatalogInfo); + + /* set directory access info for FSSpec */ + pb.accessParam.ioNamePtr = (StringPtr)spec.name; + pb.accessParam.ioVRefNum = spec.vRefNum; + pb.fileParam.ioDirID = spec.parID; + pb.accessParam.ioACOwnerID = ownerID; + pb.accessParam.ioACGroupID = groupID; + pb.accessParam.ioACAccess = accessRights & kSetDirAccessSettableMask; + result = PBHSetDirAccessSync(&pb); + require_noerr(result, PBHSetDirAccessSync); + +PBHSetDirAccessSync: +FSGetCatalogInfo: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSGetVolMountInfoSize( + FSVolumeRefNum volRefNum, + SInt16 *size) +{ + OSErr result; + ParamBlockRec pb; + + /* check parameters */ + require_action(NULL != size, BadParameter, result = paramErr); + + pb.ioParam.ioNamePtr = NULL; + pb.ioParam.ioVRefNum = volRefNum; + pb.ioParam.ioBuffer = (Ptr)size; + result = PBGetVolMountInfoSize(&pb); + require_noerr(result, PBGetVolMountInfoSize); + +PBGetVolMountInfoSize: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSGetVolMountInfo( + FSVolumeRefNum volRefNum, + void *volMountInfo) +{ + OSErr result; + ParamBlockRec pb; + + /* check parameters */ + require_action(NULL != volMountInfo, BadParameter, result = paramErr); + + pb.ioParam.ioNamePtr = NULL; + pb.ioParam.ioVRefNum = volRefNum; + pb.ioParam.ioBuffer = (Ptr)volMountInfo; + result = PBGetVolMountInfo(&pb); + require_noerr(result, PBGetVolMountInfo); + +PBGetVolMountInfo: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSVolumeMount( + const void *volMountInfo, + FSVolumeRefNum *volRefNum) +{ + OSErr result; + ParamBlockRec pb; + + /* check parameters */ + require_action(NULL != volRefNum, BadParameter, result = paramErr); + + pb.ioParam.ioBuffer = (Ptr)volMountInfo; + result = PBVolumeMount(&pb); + require_noerr(result, PBVolumeMount); + + /* return the volume reference number */ + *volRefNum = pb.ioParam.ioVRefNum; + +PBVolumeMount: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSMapID( + FSVolumeRefNum volRefNum, + SInt32 ugID, + SInt16 objType, + Str31 name) +{ + OSErr result; + HParamBlockRec pb; + + /* check parameters */ + require_action(NULL != name, BadParameter, result = paramErr); + + pb.objParam.ioNamePtr = NULL; + pb.objParam.ioVRefNum = volRefNum; + pb.objParam.ioObjType = objType; + pb.objParam.ioObjNamePtr = name; + pb.objParam.ioObjID = ugID; + result = PBHMapIDSync(&pb); + require_noerr(result, PBHMapIDSync); + +PBHMapIDSync: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSMapName( + FSVolumeRefNum volRefNum, + ConstStr255Param name, + SInt16 objType, + SInt32 *ugID) +{ + OSErr result; + HParamBlockRec pb; + + /* check parameters */ + require_action(NULL != ugID, BadParameter, result = paramErr); + + pb.objParam.ioNamePtr = NULL; + pb.objParam.ioVRefNum = volRefNum; + pb.objParam.ioObjType = objType; + pb.objParam.ioObjNamePtr = (StringPtr)name; + result = PBHMapNameSync(&pb); + require_noerr(result, PBHMapNameSync); + + /* return the user or group ID */ + *ugID = pb.objParam.ioObjID; + +PBHMapNameSync: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSCopyFile( + const FSRef *srcFileRef, + const FSRef *dstDirectoryRef, + UniCharCount nameLength, + const UniChar *copyName, /* can be NULL (no rename during copy) */ + TextEncoding textEncodingHint, + FSRef *newRef) /* can be NULL */ +{ + OSErr result; + FSSpec srcFileSpec; + FSCatalogInfo catalogInfo; + HParamBlockRec pb; + Str31 hfsName; + GetVolParmsInfoBuffer volParmsInfo; + UInt32 infoSize; + + /* get source FSSpec from source FSRef */ + result = FSGetCatalogInfo(srcFileRef, kFSCatInfoNone, NULL, NULL, &srcFileSpec, NULL); + require_noerr(result, FSGetCatalogInfo_srcFileRef); + + /* Make sure the volume supports CopyFile */ + result = FSGetVolParms(srcFileSpec.vRefNum, sizeof(GetVolParmsInfoBuffer), + &volParmsInfo, &infoSize); + require_action((noErr == result) && VolHasCopyFile(&volParmsInfo), + NoCopyFileSupport, result = paramErr); + + /* get destination volume reference number and destination directory ID from destination FSRef */ + result = FSGetCatalogInfo(dstDirectoryRef, kFSCatInfoVolume + kFSCatInfoNodeID, + &catalogInfo, NULL, NULL, NULL); + require_noerr(result, FSGetCatalogInfo_dstDirectoryRef); + + /* tell the server to copy the object */ + pb.copyParam.ioVRefNum = srcFileSpec.vRefNum; + pb.copyParam.ioDirID = srcFileSpec.parID; + pb.copyParam.ioNamePtr = (StringPtr)srcFileSpec.name; + pb.copyParam.ioDstVRefNum = catalogInfo.volume; + pb.copyParam.ioNewDirID = (long)catalogInfo.nodeID; + pb.copyParam.ioNewName = NULL; + if ( NULL != copyName ) + { + result = UnicodeNameGetHFSName(nameLength, copyName, textEncodingHint, false, hfsName); + require_noerr(result, UnicodeNameGetHFSName); + + pb.copyParam.ioCopyName = hfsName; + } + else + { + pb.copyParam.ioCopyName = NULL; + } + result = PBHCopyFileSync(&pb); + require_noerr(result, PBHCopyFileSync); + + if ( NULL != newRef ) + { + verify_noerr(FSMakeFSRef(pb.copyParam.ioDstVRefNum, pb.copyParam.ioNewDirID, + pb.copyParam.ioCopyName, newRef)); + } + +PBHCopyFileSync: +UnicodeNameGetHFSName: +FSGetCatalogInfo_dstDirectoryRef: +NoCopyFileSupport: +FSGetCatalogInfo_srcFileRef: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSMoveRename( + const FSRef *srcFileRef, + const FSRef *dstDirectoryRef, + UniCharCount nameLength, + const UniChar *moveName, /* can be NULL (no rename during move) */ + TextEncoding textEncodingHint, + FSRef *newRef) /* can be NULL */ +{ + OSErr result; + FSSpec srcFileSpec; + FSCatalogInfo catalogInfo; + HParamBlockRec pb; + Str31 hfsName; + GetVolParmsInfoBuffer volParmsInfo; + UInt32 infoSize; + + /* get source FSSpec from source FSRef */ + result = FSGetCatalogInfo(srcFileRef, kFSCatInfoNone, NULL, NULL, &srcFileSpec, NULL); + require_noerr(result, FSGetCatalogInfo_srcFileRef); + + /* Make sure the volume supports MoveRename */ + result = FSGetVolParms(srcFileSpec.vRefNum, sizeof(GetVolParmsInfoBuffer), + &volParmsInfo, &infoSize); + require_action((noErr == result) && VolHasMoveRename(&volParmsInfo), + NoMoveRenameSupport, result = paramErr); + + /* get destination volume reference number and destination directory ID from destination FSRef */ + result = FSGetCatalogInfo(dstDirectoryRef, kFSCatInfoVolume + kFSCatInfoNodeID, + &catalogInfo, NULL, NULL, NULL); + require_noerr(result, FSGetCatalogInfo_dstDirectoryRef); + + /* make sure the source and destination are on the same volume */ + require_action(srcFileSpec.vRefNum == catalogInfo.volume, NotSameVolume, result = diffVolErr); + + /* tell the server to move and rename the object */ + pb.copyParam.ioVRefNum = srcFileSpec.vRefNum; + pb.copyParam.ioDirID = srcFileSpec.parID; + pb.copyParam.ioNamePtr = (StringPtr)srcFileSpec.name; + pb.copyParam.ioNewDirID = (long)catalogInfo.nodeID; + pb.copyParam.ioNewName = NULL; + if ( NULL != moveName ) + { + result = UnicodeNameGetHFSName(nameLength, moveName, textEncodingHint, false, hfsName); + require_noerr(result, UnicodeNameGetHFSName); + + pb.copyParam.ioCopyName = hfsName; + } + else + { + pb.copyParam.ioCopyName = NULL; + } + result = PBHMoveRenameSync(&pb); + require_noerr(result, PBHMoveRenameSync); + + if ( NULL != newRef ) + { + verify_noerr(FSMakeFSRef(pb.copyParam.ioVRefNum, pb.copyParam.ioNewDirID, + pb.copyParam.ioCopyName, newRef)); + } + +PBHMoveRenameSync: +UnicodeNameGetHFSName: +NotSameVolume: +FSGetCatalogInfo_dstDirectoryRef: +NoMoveRenameSupport: +FSGetCatalogInfo_srcFileRef: + + return ( result ); +} + +/*****************************************************************************/ + +#pragma mark ----- File ID Routines ----- + +/*****************************************************************************/ + +OSErr +FSResolveFileIDRef( + FSVolumeRefNum volRefNum, + SInt32 fileID, + FSRef *ref) +{ + OSErr result; + FIDParam pb; + Str255 tempStr; + + /* check parameters */ + require_action(NULL != ref, BadParameter, result = paramErr); + + /* resolve the file ID reference */ + StrLength(tempStr) = 0; + pb.ioNamePtr = tempStr; + pb.ioVRefNum = volRefNum; + pb.ioFileID = fileID; + result = PBResolveFileIDRefSync((HParmBlkPtr)&pb); + require_noerr(result, PBResolveFileIDRefSync); + + /* and then make an FSRef to the file */ + result = FSMakeFSRef(volRefNum, pb.ioSrcDirID, tempStr, ref); + require_noerr(result, FSMakeFSRef); + +FSMakeFSRef: +PBResolveFileIDRefSync: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSCreateFileIDRef( + const FSRef *ref, + SInt32 *fileID) +{ + OSErr result; + FSSpec spec; + FIDParam pb; + + /* check parameters */ + require_action(NULL != fileID, BadParameter, result = paramErr); + + /* Get an FSSpec from the FSRef */ + result = FSGetCatalogInfo(ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); + require_noerr(result, FSGetCatalogInfo); + + /* Create (or get) the file ID reference using the FSSpec */ + pb.ioNamePtr = (StringPtr)spec.name; + pb.ioVRefNum = spec.vRefNum; + pb.ioSrcDirID = spec.parID; + result = PBCreateFileIDRefSync((HParmBlkPtr)&pb); + require((noErr == result) || (fidExists == result) || (afpIDExists == result), + PBCreateFileIDRefSync); + + /* return the file ID reference */ + *fileID = pb.ioFileID; + +PBCreateFileIDRefSync: +FSGetCatalogInfo: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +#pragma mark ----- Utility Routines ----- + +/*****************************************************************************/ + +Ptr +GetTempBuffer( + ByteCount buffReqSize, + ByteCount *buffActSize) +{ + enum + { + kSlopMemory = 0x00008000 /* 32K - Amount of free memory to leave when allocating buffers */ + }; + + Ptr tempPtr; + + /* check parameters */ + require_action(NULL != buffActSize, BadParameter, tempPtr = NULL); + + /* Make request a multiple of 4K bytes */ + buffReqSize = buffReqSize & 0xfffff000; + + if ( buffReqSize < 0x00001000 ) + { + /* Request was smaller than 4K bytes - make it 4K */ + buffReqSize = 0x00001000; + } + + /* Attempt to allocate the memory */ + tempPtr = NewPtr(buffReqSize); + + /* If request failed, go to backup plan */ + if ( (tempPtr == NULL) && (buffReqSize > 0x00001000) ) + { + /* + ** Try to get largest 4K byte block available + ** leaving some slop for the toolbox if possible + */ + long freeMemory = (FreeMem() - kSlopMemory) & 0xfffff000; + + buffReqSize = MaxBlock() & 0xfffff000; + + if ( buffReqSize > freeMemory ) + { + buffReqSize = freeMemory; + } + + if ( buffReqSize == 0 ) + { + buffReqSize = 0x00001000; + } + + tempPtr = NewPtr(buffReqSize); + } + + /* Return bytes allocated */ + if ( tempPtr != NULL ) + { + *buffActSize = buffReqSize; + } + else + { + *buffActSize = 0; + } + +BadParameter: + + return ( tempPtr ); +} + +/*****************************************************************************/ + +OSErr +FileRefNumGetFSRef( + short refNum, + FSRef *ref) +{ + return ( FSGetForkCBInfo(refNum, 0, NULL, NULL, NULL, ref, NULL) ); +} + +/*****************************************************************************/ + +OSErr +FSSetDefault( + const FSRef *newDefault, + FSRef *oldDefault) +{ + OSErr result; + FSVolumeRefNum vRefNum; + long dirID; + FSCatalogInfo catalogInfo; + + /* check parameters */ + require_action((NULL != newDefault) && (NULL != oldDefault), BadParameter, result = paramErr); + + /* Get nodeFlags, vRefNum and dirID (nodeID) of newDefault */ + result = FSGetCatalogInfo(newDefault, + kFSCatInfoNodeFlags + kFSCatInfoVolume + kFSCatInfoNodeID, + &catalogInfo, NULL, NULL, NULL); + require_noerr(result, FSGetCatalogInfo); + + /* Make sure newDefault is a directory */ + require_action(0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags), NewDefaultNotDirectory, + result = dirNFErr); + + /* Get the current working directory. */ + result = HGetVol(NULL, &vRefNum, &dirID); + require_noerr(result, HGetVol); + + /* Return the oldDefault FSRef */ + result = FSMakeFSRef(vRefNum, dirID, NULL, oldDefault); + require_noerr(result, FSMakeFSRef); + + /* Set the new current working directory */ + result = HSetVol(NULL, catalogInfo.volume, catalogInfo.nodeID); + require_noerr(result, HSetVol); + +HSetVol: +FSMakeFSRef: +HGetVol: +NewDefaultNotDirectory: +FSGetCatalogInfo: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ + +OSErr +FSRestoreDefault( + const FSRef *oldDefault) +{ + OSErr result; + FSCatalogInfo catalogInfo; + + /* check parameters */ + require_action(NULL != oldDefault, BadParameter, result = paramErr); + + /* Get nodeFlags, vRefNum and dirID (nodeID) of oldDefault */ + result = FSGetCatalogInfo(oldDefault, + kFSCatInfoNodeFlags + kFSCatInfoVolume + kFSCatInfoNodeID, + &catalogInfo, NULL, NULL, NULL); + require_noerr(result, FSGetCatalogInfo); + + /* Make sure oldDefault is a directory */ + require_action(0 != (kFSNodeIsDirectoryMask & catalogInfo.nodeFlags), OldDefaultNotDirectory, + result = dirNFErr); + + /* Set the current working directory to oldDefault */ + result = HSetVol(NULL, catalogInfo.volume, catalogInfo.nodeID); + require_noerr(result, HSetVol); + +HSetVol: +OldDefaultNotDirectory: +FSGetCatalogInfo: +BadParameter: + + return ( result ); +} + +/*****************************************************************************/ diff --git a/NovaTools/NovaWindowController.h b/NovaTools/NovaWindowController.h index 019405a..5c6b6ad 100644 --- a/NovaTools/NovaWindowController.h +++ b/NovaTools/NovaWindowController.h @@ -7,4 +7,7 @@ { id resource; } + +- (IBAction)toggleResID:(id)sender; + @end diff --git a/NovaTools/NovaWindowController.m b/NovaTools/NovaWindowController.m index 52fc91a..5494cd1 100644 --- a/NovaTools/NovaWindowController.m +++ b/NovaTools/NovaWindowController.m @@ -9,45 +9,16 @@ - (id)initWithResource:(id)newResource { - NSString *asciiType = NSLocalizedStringFromTable( [resource type], @"Resource Types", nil ); - - resource = [newResource retain]; - - NSLog( @"%s", [[resource type] lossyCString] ); - NSLog( [[[resource type] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] description] ); - if( [asciiType isEqualToString:@"boom"] ) - { - id oldSelf = self; - self = [[BoomWindowController alloc] initWithResource:newResource]; - [oldSelf release]; - } - if( [asciiType isEqualToString:@"char"] ) - { - id oldSelf = self; - self = [[CharWindowController alloc] initWithResource:newResource]; - [oldSelf release]; - } - if( [asciiType isEqualToString:@"colr"] ) - { - id oldSelf = self; - self = [[ColrWindowController alloc] initWithResource:newResource]; - [oldSelf release]; - } - if( [asciiType isEqualToString:@"cron"] ) - { - id oldSelf = self; - self = [[CronWindowController alloc] initWithResource:newResource]; - [oldSelf release]; - } - if( [asciiType isEqualToString:@"desc"] ) - { - id oldSelf = self; - self = [[DescWindowController alloc] initWithResource:newResource]; - [oldSelf release]; - } + id oldSelf = self; + NSData *classData = [[(id )newResource type] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + NSString *className = [[[NSString stringWithCString:[classData bytes] length:[classData length]] capitalizedString] stringByAppendingString:@"WindowController"]; + if( [className isEqualToString:@"Yea(R)WindowController"] ) className = @"YearWindowController"; + self = [[NSClassFromString(className) alloc] initWithResource:newResource]; + [oldSelf release]; if( !self ) return nil; // do global stuff here + resource = [newResource retain]; return self; } @@ -57,4 +28,25 @@ return nil; } +- (void)windowDidLoad +{ + [super windowDidLoad]; + + // insert the resources' data into the text fields +// [self refreshData:[resource data]]; + + // we don't want this notification until we have a window! + // bug: only registers for notifications on the resource we're editing, need dependant resources too (pass nil for object?) +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource]; + + // finally, show the window + [self showWindow:self]; +} + +- (IBAction)toggleResID:(id)sender +{ + // toggles between resource IDs and index numbers + NSLog( @"%@", [resource type] ); +} + @end diff --git a/NovaTools/boom/BoomWindowController.m b/NovaTools/boom/BoomWindowController.m index 2136f25..29ff51e 100644 --- a/NovaTools/boom/BoomWindowController.m +++ b/NovaTools/boom/BoomWindowController.m @@ -5,12 +5,12 @@ - (id)initWithResource:(id)newResource { self = [self initWithWindowNibName:@"boom"]; - if( !self ) return self; + if( !self ) return nil; // load the window from the nib file and set it's title [self window]; // implicitly loads nib - if( ![[resource name] isEqualToString:@""] ) - [[self window] setTitle:[NSString stringWithFormat:@"Explosion: %@", [resource name]]]; + if( [newResource name] && ![[newResource name] isEqualToString:@""] ) + [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; return self; } diff --git a/NovaTools/boom/English.lproj/boom.nib/info.nib b/NovaTools/boom/English.lproj/boom.nib/info.nib index dee09fa..8ced291 100644 --- a/NovaTools/boom/English.lproj/boom.nib/info.nib +++ b/NovaTools/boom/English.lproj/boom.nib/info.nib @@ -6,6 +6,10 @@ 220 152 356 240 0 0 1152 848 IBFramework Version 248.0 + IBOpenObjects + + 5 + IBSystem Version 5Q110 diff --git a/NovaTools/boom/English.lproj/boom.nib/objects.nib b/NovaTools/boom/English.lproj/boom.nib/objects.nib index 377c51f921c6218adc2d2d43e8d0422534e182dc..4b1b2ad92d6bb7d15aeaf4cf79c8fa4b9c21f010 100644 GIT binary patch literal 3218 zcmb_eU2NOd6~0%J75PVL>^N=X44Z(Z+0viXaj`8hwnnktG(uX%wT$(l>jOc(lqwNxl_g8PiY;)3nOy6a6E)o_|>_WcArmyIX8Bq)o#Bs18S74GCX`Z9FJu*iR4cYe zSP!?x?eYu42trfQDZ`NF31fTGnc%VN#dr*0_eBZL&OOUmXFAjL@aQ|0x>xQYgw$FC%q~k!< zJIp#>dFI>lt5Lum!2iZ3d4bFjnW!X7B=S5la4+Clfj*jxGb)n?ZIDL9v2B*V9_EmG{q`x2#2V+Vo`flnA0zS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ga_t{-+-&?ACU*7ZXuXs1=-tA?-!}CKk zjcLJ~!*at!o}4ORVy*DbTLkxa{Fta_(D%sT zai$kBuof^R8)jGa>Ro(=tc)9mKCTtT?g=&{g8aOot)!7l<|K(J*>g%kWqDSx4*sk# z$}sm8EX-I!B5j;g{{FgOYKWTn@Sxy2&d~*FZK5$CubH*Ur*c{kx7MJ{N)IgK^l6=8 zwiHvPRMI1roSd|DhPk5w9XbwO-7UUIWSP!R!={k_{?+p$-0>+nz01MGe+)yu_T*#1 z?6$yvG?;4*?)3!Ed^5O`2<|)*e6=^Y(H7j^9xSy7^?1D>j2hSyg-7UeFy}@}J ne6}aJyE9nX5!~MuEO+|*d?G4p$H?H2p&E*0_$kAD)ph>^g5?VC diff --git a/NovaTools/char/CharWindowController.h b/NovaTools/char/CharWindowController.h index 097696c..361b63b 100644 --- a/NovaTools/char/CharWindowController.h +++ b/NovaTools/char/CharWindowController.h @@ -1,7 +1,32 @@ #import #import "NovaWindowController.h" +#define prefixField [timeForm cellAtIndex:0] +#define suffixField [timeForm cellAtIndex:1] + @interface CharWindowController : NovaWindowController { + IBOutlet NSTextField *dayField; + IBOutlet NSTextField *monthField; + IBOutlet NSTextField *yearField; + IBOutlet NSStepper *dayStepper; + IBOutlet NSStepper *monthStepper; + IBOutlet NSStepper *yearStepper; + IBOutlet NSForm *timeForm; + + // Initial Goodies + NSDecimalNumber *ship; + NSDecimalNumber *cash; + NSDecimalNumber *kills; + + // Beginning Of Time + NSCalendarDate *date; + NSString *prefix; + NSString *suffix; } + +- (void)update; +- (IBAction)stepDate:(id)sender; +- (IBAction)editDate:(id)sender; + @end diff --git a/NovaTools/char/CharWindowController.m b/NovaTools/char/CharWindowController.m index 903bac2..a7f91e7 100644 --- a/NovaTools/char/CharWindowController.m +++ b/NovaTools/char/CharWindowController.m @@ -2,4 +2,58 @@ @implementation CharWindowController +- (id)initWithResource:(id)newResource +{ + self = [self initWithWindowNibName:@"char"]; + if( !self ) return nil; + + // load data from resource + ship = [[NSDecimalNumber alloc] initWithShort:128]; + cash = [[NSDecimalNumber alloc] initWithLong:10000]; + kills = [[NSDecimalNumber alloc] initWithUnsignedLong:0]; + + date = [[NSCalendarDate date] retain]; + prefix = [[NSString alloc] init]; + suffix = [[NSString alloc] init]; + + // load the window from the nib file and set it's title + [self window]; // implicitly loads nib + if( [newResource name] && ![[newResource name] isEqualToString:@""] ) + [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; + [self update]; + return self; +} + +- (void)update +{ + // update some stuff in the catchall box + + + // update Beginning Of Time + [dayField setIntValue:[date dayOfMonth]]; + [monthField setIntValue:[date monthOfYear]]; + [yearField setIntValue:[date yearOfCommonEra]]; + [dayStepper setIntValue:[date dayOfMonth]]; + [monthStepper setIntValue:[date monthOfYear]]; + [yearStepper setIntValue:[date yearOfCommonEra]]; + [prefixField setStringValue:prefix]; + [suffixField setStringValue:suffix]; +} + +- (IBAction)stepDate:(id)sender +{ + id old = date; + date = [[NSCalendarDate alloc] initWithYear:[yearStepper intValue] month:[monthStepper intValue] day:[dayStepper intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (IBAction)editDate:(id)sender +{ + id old = date; + date = [[NSCalendarDate alloc] initWithYear:[yearField intValue] month:[monthField intValue] day:[dayField intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + @end diff --git a/NovaTools/char/English.lproj/char.nib/classes.nib b/NovaTools/char/English.lproj/char.nib/classes.nib index da40001..748a16b 100644 --- a/NovaTools/char/English.lproj/char.nib/classes.nib +++ b/NovaTools/char/English.lproj/char.nib/classes.nib @@ -1,8 +1,18 @@ { IBClasses = ( { + ACTIONS = {editDate = id; stepDate = id; }; CLASS = CharWindowController; LANGUAGE = ObjC; + OUTLETS = { + dayField = NSTextField; + dayStepper = NSStepper; + monthField = NSTextField; + monthStepper = NSStepper; + timeForm = NSForm; + yearField = NSTextField; + yearStepper = NSStepper; + }; SUPERCLASS = NovaWindowController; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, diff --git a/NovaTools/char/English.lproj/char.nib/info.nib b/NovaTools/char/English.lproj/char.nib/info.nib index 26c9ef9..39dd71b 100644 --- a/NovaTools/char/English.lproj/char.nib/info.nib +++ b/NovaTools/char/English.lproj/char.nib/info.nib @@ -5,7 +5,7 @@ IBDocumentLocation 30 118 356 240 0 0 1152 848 IBFramework Version - 248.0 + 263.2 IBGroupedObjects 2 @@ -21,6 +21,6 @@ IBLastGroupID 3 IBSystem Version - 5Q110 + 5Q125 diff --git a/NovaTools/char/English.lproj/char.nib/objects.nib b/NovaTools/char/English.lproj/char.nib/objects.nib index 565f6d05ff9a95b4e2060662dc5b1032081fffd0..9e2434b222e0b857fe5b9651876fdbce49dc9dfe 100644 GIT binary patch literal 12041 zcmb_i4{%h+dEdP|NgxRs@ox}>i6-FKV8@jNX|M)^j4*J3h1$cx9@lM8cTaH5>F#_w z85oaU_WbV6I0>=yB3^U^lNbvO7-I}Jsj1xp0b?eu-6^fx)KIDdF>d2F({>JL(xU#p z-FJ8IPA4HWoJP0rzTNljx4-@N`@a2lJynS~X;l8Hx7G2kC+I-%nYdii# z3nZ5L6Mn(|Mc2o*`4okvOx2{dr#lhtQpCBvx~qj=MKfO_9*S(>y*j^VO6x{{e0?Yq zjBaX;MiTL8IIP8ul%ey`DhsX4+kD>)X`ANidR3e6_qFa=G!oR}te1KyYx6CQZl1Tp z)OVPvG}EhF@aeQaN`i-b68?^`_Fz2j-@Jp=hL43x{iEm-O^t@8F<^gC}@Rni z4E^LGH<0RlZppj@uW>{EKFYa~D#S!eB5_TXz@vP5NDBwEV<34`0QJ=Z6%_0z^E#k{ z9XSPjg>|UaXq~n>A#3aQ6aMwkduak@)U2vyY*lS``4jq37A(iy8?=NW%MuoP!IxJJ8a?PC$LikDP*5O|-R&+T}ItD1%B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a/NovaTools/colr/ColrWindowController.m +++ b/NovaTools/colr/ColrWindowController.m @@ -2,4 +2,16 @@ @implementation ColrWindowController +- (id)initWithResource:(id)newResource +{ + self = [self initWithWindowNibName:@"colr"]; + if( !self ) return nil; + + // load the window from the nib file and set it's title + [self window]; // implicitly loads nib + if( [newResource name] && ![[newResource name] isEqualToString:@""] ) + [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; + return self; +} + @end diff --git a/NovaTools/cron/CronWindowController.m b/NovaTools/cron/CronWindowController.m index dbeae77..f55f167 100644 --- a/NovaTools/cron/CronWindowController.m +++ b/NovaTools/cron/CronWindowController.m @@ -2,4 +2,19 @@ @implementation CronWindowController +- (id)initWithResource:(id)newResource +{ + self = [self initWithWindowNibName:@"cron"]; + if( !self ) return nil; + + // load the window from the nib file and set it's title + [self window]; // implicitly loads nib + if( [newResource name] && ![[newResource name] isEqualToString:@""] ) + [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; + return self; +} + +// date format for start and end: +// %e/%1m/%Y == 1/1/2000 + @end diff --git a/NovaTools/cron/English.lproj/cron.nib/classes.nib b/NovaTools/cron/English.lproj/cron.nib/classes.nib index 0cbf7b6..4d5e42c 100644 --- a/NovaTools/cron/English.lproj/cron.nib/classes.nib +++ b/NovaTools/cron/English.lproj/cron.nib/classes.nib @@ -7,7 +7,7 @@ }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, { - ACTIONS = {incrementDate = id; synchroniseDates = id; }; + ACTIONS = {toggleResID = id; }; CLASS = NovaWindowController; LANGUAGE = ObjC; SUPERCLASS = NSWindowController; diff --git a/NovaTools/cron/English.lproj/cron.nib/objects.nib b/NovaTools/cron/English.lproj/cron.nib/objects.nib index ed71eb05e25a442f60b4271808352639d443028a..bb13d90a4fa4f3992681a2c724874afd00f38349 100644 GIT binary patch literal 15984 zcmc&*dvsORncq9PghN6g;ibGZ@=!oQ3GV( zPP>+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0RyDTUkkoh;&z`rQ-r)S!LCE>75r^^S@37% zcH|)gTJq$5m@NFoWB-mAnmHjcf zN$^cF6;6U&tns(VLKqC`YQc*k?hx#MB)Yg7>4y+{mV2@!V2!w(EZG0bS+Fb8*r~W6 zFg!)FSnvlWd~&AzK=8knLooKT2%AGWQt&6_Y{8$DcVO57FA?m&AjaZ#I5cgu;QJ-E zP>bd6Ve&S?TTt{EIwuDTUXS!a!H+_?(Rv8DFq0U@Qpqu5$nc;=vSYYBBKR9}sNj!F zc&A66$d{iCmDoo#NI3N>0JrtSSGwRYpw26p2yyi|wqX#91Rp5-p&LlUQO3$Kg0GW< zF*Nf0&B)s$_#ucfg8fm#%hn+MFa`l42Q#LGH{Fl)gM!}%)oAXs5_VZ6FAS0J#P#xY ze~B6bfYidU5EBIZZ`oh)pu{fuA?bo=;KsKF-wtsUUMfp55b{)^TqpQn$r`~0?t;m) zA&4@DK;}rG4}o5h@R}-lv*5Fl@eCeZh}Q)F4p1+{d~!HE9chd}4g_9Cyaq8^urDF- zV3t5Ufk^@4MZtdnu@c1)@Kox(ftMPg@si-}5IY6mf=o0#UE*=Cm6( + +@interface DescSplitViewDelegate : NSObject +{ + +} + +@end \ No newline at end of file diff --git a/NovaTools/desc/DescSplitViewDelegate.m b/NovaTools/desc/DescSplitViewDelegate.m new file mode 100644 index 0000000..0db4b06 --- /dev/null +++ b/NovaTools/desc/DescSplitViewDelegate.m @@ -0,0 +1,40 @@ +#import "DescSplitViewDelegate.h" + +@implementation DescSplitViewDelegate +/* +- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize +{ + +} +*/ +- (float)splitView:(NSSplitView *)sender constrainMinCoordinate:(float)proposedCoord ofSubviewAt:(int)offset +{ + return proposedCoord < 20.0? 20.0 : proposedCoord; +} +/* +- (float)splitView:(NSSplitView *)sender constrainMaxCoordinate:(float)proposedCoord ofSubviewAt:(int)offset +{ + +} + +- (void)splitViewWillResizeSubviews:(NSNotification *)notification +{ + +} + +- (void)splitViewDidResizeSubviews:(NSNotification *)notification +{ + +} + +- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview +{ + return YES; +} + +- (float)splitView:(NSSplitView *)splitView constrainSplitPosition:(float)proposedPosition ofSubviewAt:(int)index +{ + +} +*/ +@end \ No newline at end of file diff --git a/NovaTools/desc/DescWindowController.m b/NovaTools/desc/DescWindowController.m index 7322863..db13771 100644 --- a/NovaTools/desc/DescWindowController.m +++ b/NovaTools/desc/DescWindowController.m @@ -2,4 +2,16 @@ @implementation DescWindowController +- (id)initWithResource:(id)newResource +{ + self = [self initWithWindowNibName:@"desc"]; + if( !self ) return nil; + + // load the window from the nib file and set it's title + [self window]; // implicitly loads nib + if( [newResource name] && ![[newResource name] isEqualToString:@""] ) + [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; + return self; +} + @end diff --git a/NovaTools/desc/English.lproj/desc.nib/classes.nib b/NovaTools/desc/English.lproj/desc.nib/classes.nib index 5c50574..652f7e0 100644 --- a/NovaTools/desc/English.lproj/desc.nib/classes.nib +++ b/NovaTools/desc/English.lproj/desc.nib/classes.nib @@ -1,12 +1,15 @@ { IBClasses = ( + {CLASS = DescSplitViewDelegate; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, { CLASS = DescWindowController; LANGUAGE = ObjC; SUPERCLASS = NovaWindowController; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = NSObject; LANGUAGE = ObjC; }, { + ACTIONS = {toggleResID = id; }; CLASS = NovaWindowController; LANGUAGE = ObjC; SUPERCLASS = NSWindowController; diff --git a/NovaTools/desc/English.lproj/desc.nib/info.nib b/NovaTools/desc/English.lproj/desc.nib/info.nib index f698510..4821e4b 100644 --- a/NovaTools/desc/English.lproj/desc.nib/info.nib +++ b/NovaTools/desc/English.lproj/desc.nib/info.nib @@ -3,10 +3,10 @@ IBDocumentLocation - 58 289 356 240 0 0 1152 848 + 75 569 356 240 0 0 1152 848 IBFramework Version - 248.0 + 263.2 IBSystem Version - 5Q110 + 5Q125 diff --git a/NovaTools/desc/English.lproj/desc.nib/objects.nib b/NovaTools/desc/English.lproj/desc.nib/objects.nib index 10ac3e29f0080f10c01a8c10a45d6f476f44faf6..daa54415e1ca51e8f421c89a559ee343e63e2fc2 100644 GIT binary patch literal 3392 zcmb7HU1%KF6~1?OC0Ujf%Z@BJrVpZV9m`46+DTnognDfmC8D+LWK9hXp^Ro{t!Y*} z>g*`8OCCJyJNG#Z(sVcei7X*^;|dImA#P|P(AEg2s6=I61ZqO)g9=8ZeJWH){mz|P zDT-5YXW5;ZGk4BC=R4pB?H8gL$K?X#UcW(1~~Yu-ESK%0AKX`U^+&HyRmZd+}XcXFq16OlKy`GL5~= zZ2T5*Z9py0wF$1XDL%!fQquFVV-H+a&cdnF8oavrLm`@BQshdv+UqB#F@~#_fy`@0 zal|TQ4V#VoVwyl|fP2=(gSejdy$TbpWO^<>@Ekaw9(6QWf5Nu4OH7ESflPEcUP+M# z0F==QHrmEzpHKVMN@>?+#@-jVD@j_h9ronS5qjP;?ax+9?4#%@kHd7%xagcShDY+6 zW4Qdj+Lczu4&^eSC2cagf3NaQ0DSmp1aL^ti+fXzA{iw}W9CxPF@_~_rBjbWc2d*dykJ|Sg{(3` zVtKN5<@mwdzu}T{2Z8P#wTqU$bG(-N4_Vtz63TN#*BZ5TqkBAnLO9VstX)9DmCJ2Z zEhwMpO(~VNjBy!!1DnN1g7Z*Fw9=`bFBl@mgJC9JF-&NOiFH-Vbe&x8`+4~_yLLu1!Yg~TMWpfm0I{Q`Z zOu_zxe?JPkXrNRzx8o=Y=ur--^0J5dP0GZ5kgBYKx?j0$;YBFJuTlj!?lI0hvFm9Q zM^8_W(nckazPi4i;N(49=;Yfnb<_Kljn2 z?>C;d-ZG8&ZOWL&yB|VrYn)P1BK=N&;B8gBuwj??bxQk8BcH9Cq+%}pTjW3Z<(xK1 z1)5UD{w;zS;GmqR{l!ZC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36DhQw#WV|a6o#J7AyE41>*^Y zf5|cIM@36|ZWMj{w)fA+1_jmt6z{rNB0;$&(@i4bl53-aK-Wh7g%~Z7|9X)vZoDEs z+<2vxDp;melBpeBiepSd(k0^~dvsjnimD9d--%lE*g@O|jeIegAaM*JGauJRM4e2@ zICvVuM9r0Pu%hBXR#=pINj5Qc*F}GIy_ABF;CU<07!JxiBCCK0G!nyD+-&YZ#x%=D zMH@4!$3`s8E*?ko!ci|=@}Wy!Z{7V>g^S3P5Zlrza~xnGk{KczSrR!Ert%q-FuZTt z`3XTQ8vu66-!m@xmn!!1z6Ns}LJW1Ll~ci*7>!}nP}rZ5A&3lprAhblRcs{_XE=Vt z^H#w2#Gk~seH>{6txpV{G+nw%z?GQvGcjCHBx)YJclH0nC8M^3#Exo&hM->m`M+QP z^qtGh1no#F4J5ubNUv9z)hFDsaDs=Pl4Ud=4R1q+NPwmuo@{$N#Z~@B>?21M_Eb;g67m2 zH+gJ^qIG)BCI1oZN);gh4G0fbX>fNnm=A-6Fu1iGEG-7t=7T%S!MpRp@?y}D38tq4 zx)P*Ug6^}yR2XE^!3Rsh$4kLV7%VP?TY_bXL#L^V`rf^eh=I7*jDH8B$Ui&REp)aQjk0kP?Kj7u7w%+W6Zjb2B=-QU(-LB}?j;Q1FQFl6;?}$F$9-XDpoxUjjRCM=q(FZ-z>aJ+z oGtuIc(ZUnao-agGneb`RNjIC_!-GSXZfS>YWRnTYeu?w{0%##Xb^rhX diff --git a/ResKnife.pbproj/project.pbxproj b/ResKnife.pbproj/project.pbxproj index 6badd92..0a9d2ad 100644 --- a/ResKnife.pbproj/project.pbxproj +++ b/ResKnife.pbproj/project.pbxproj @@ -3,8 +3,14 @@ archiveVersion = 1; classes = { }; - objectVersion = 34; + objectVersion = 38; objects = { + F51C71F60269C7E701A8010C = { + fileRef = F54E622B021D192201A80001; + isa = PBXBuildFile; + settings = { + }; + }; F51FB38E0256057F01A80001 = { children = ( F58F6BA9025BDBA701A8010C, @@ -13,7 +19,6 @@ F5EDC618025BFB8601A8010C, F5EDC61B025BFB8E01A8010C, F5EDC61E025BFBB501A8010C, - F55F7F8B025BF4BA01A8010C, ); isa = PBXGroup; name = Resources; @@ -115,7 +120,6 @@ F535444F0226B5F501A80001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5354439022674B401A80001 = { buildActionMask = 2147483647; @@ -124,7 +128,6 @@ F5D0CBD402278F8B01A80001, ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F535443A022674B401A80001 = { buildActionMask = 2147483647; @@ -133,7 +136,6 @@ F53544500226B5F501A80001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F535443B022674B401A80001 = { buildActionMask = 2147483647; @@ -141,14 +143,12 @@ F53544460226907801A80001, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F535443C022674B401A80001 = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F535443D0226752901A80001 = { isa = PBXFileReference; @@ -245,6 +245,39 @@ settings = { }; }; + F543B8790274842E01A8010C = { + isa = PBXFileReference; + name = ShipDataSource.m; + path = NovaTools/ship/ShipDataSource.m; + refType = 2; + }; + F543B87A0274842E01A8010C = { + isa = PBXFileReference; + name = ShipDataSource.h; + path = NovaTools/ship/ShipDataSource.h; + refType = 2; + }; + F543B87B0274842E01A8010C = { + fileRef = F543B8790274842E01A8010C; + isa = PBXBuildFile; + settings = { + }; + }; + F543B87C0274842E01A8010C = { + fileRef = F543B87A0274842E01A8010C; + isa = PBXBuildFile; + settings = { + }; + }; + F543B87D0274845501A8010C = { + children = ( + F543B87A0274842E01A8010C, + F543B8790274842E01A8010C, + ); + isa = PBXGroup; + name = "Data Sources"; + refType = 4; + }; F54E6220021B6A0801A80001 = { isa = PBXFileReference; path = FindSheetController.h; @@ -329,28 +362,6 @@ path = Categories; refType = 4; }; - F55F7F8B025BF4BA01A8010C = { - children = ( - F55F7F8C025BF4BA01A8010C, - ); - isa = PBXVariantGroup; - name = "Resource Types.strings"; - path = ""; - refType = 4; - }; - F55F7F8C025BF4BA01A8010C = { - fileEncoding = 10; - isa = PBXFileReference; - name = English; - path = "English.lproj/Resource Types.strings"; - refType = 4; - }; - F55F7F8D025BF4BA01A8010C = { - fileRef = F55F7F8B025BF4BA01A8010C; - isa = PBXBuildFile; - settings = { - }; - }; F5730B930159528A01000001 = { isa = PBXFileReference; path = defaults.plist; @@ -466,7 +477,6 @@ F58F6BB0025BE22201A8010C, ); isa = PBXCopyFilesBuildPhase; - name = "Copy Files"; }; F57CEE0B0189C95101A8010B = { children = ( @@ -553,7 +563,6 @@ F54E6224021B6A0901A80001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F57CEE100189C95101A8010B = { buildActionMask = 2147483647; @@ -563,7 +572,6 @@ F54E6225021B6A0901A80001, ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F57CEE110189C95101A8010B = { buildActionMask = 2147483647; @@ -574,7 +582,6 @@ F54E6226021B6A0901A80001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F57CEE120189C95101A8010B = { buildActionMask = 2147483647; @@ -582,14 +589,45 @@ F5502C3301C5586301C57124, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F57CEE130189C95101A8010B = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; + }; + F58A183F0278353501A8010C = { + children = ( + F58A18410278355D01A8010C, + F58A18400278355D01A8010C, + ); + isa = PBXGroup; + name = "Aux Support"; + refType = 4; + }; + F58A18400278355D01A8010C = { + isa = PBXFileReference; + name = DescSplitViewDelegate.m; + path = desc/DescSplitViewDelegate.m; + refType = 4; + }; + F58A18410278355D01A8010C = { + isa = PBXFileReference; + name = DescSplitViewDelegate.h; + path = desc/DescSplitViewDelegate.h; + refType = 4; + }; + F58A18420278355D01A8010C = { + fileRef = F58A18400278355D01A8010C; + isa = PBXBuildFile; + settings = { + }; + }; + F58A18430278355D01A8010C = { + fileRef = F58A18410278355D01A8010C; + isa = PBXBuildFile; + settings = { + }; }; F58F6B7E025BC3A501A8010C = { isa = PBXFileReference; @@ -976,7 +1014,6 @@ F5DF1BFD0254AD8801A80001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5B588150156D30301000001 = { buildActionMask = 2147483647; @@ -998,9 +1035,9 @@ F577A8FF0211E4D401A80001, F577A8F50211D05E01A80001, F577A8F90211DC1E01A80001, + F51C71F60269C7E701A8010C, ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5B588160156D30301000001 = { buildActionMask = 2147483647; @@ -1022,7 +1059,6 @@ F5DF1C070254AD8801A80001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5B588170156D30301000001 = { buildActionMask = 2147483647; @@ -1031,14 +1067,12 @@ F5B588730156D40B01000001, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5B588180156D30301000001 = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5B5881A0156D40B01000001 = { children = ( @@ -1590,7 +1624,7 @@ F5B5887A0156D5CB01000001, ); buildSettings = { - LIBRARY_SEARCH_PATHS = /Volumes/DeskStar/nicholas/Projects/ResKnife/Carbon; + LIBRARY_SEARCH_PATHS = Carbon; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; @@ -1696,7 +1730,6 @@ F5B588B90156D6D901000001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5B588770156D5CB01000001 = { buildActionMask = 2147483647; @@ -1704,7 +1737,6 @@ F5B588BC0156D6D901000001, ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5B588780156D5CB01000001 = { buildActionMask = 2147483647; @@ -1726,7 +1758,6 @@ F5B588CB0156D6D901000001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5B588790156D5CB01000001 = { buildActionMask = 2147483647; @@ -1734,7 +1765,6 @@ F53B5F3201C984F301A8010C, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5B5887A0156D5CB01000001 = { buildActionMask = 2147483647; @@ -1743,7 +1773,6 @@ F5B588D00156D6D901000001, ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5B5887C0156D6D901000001 = { children = ( @@ -2298,14 +2327,12 @@ F535442F0225D46C01A80001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5B588D40156D78201000001 = { buildActionMask = 2147483647; files = ( ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5B588D50156D78201000001 = { buildActionMask = 2147483647; @@ -2316,7 +2343,6 @@ F5B588EB0156D9D401000001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5B588D60156D78201000001 = { buildActionMask = 2147483647; @@ -2324,14 +2350,12 @@ F5B588EC0156DA1601000001, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5B588D70156D78201000001 = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5B588D80156D9D401000001 = { children = ( @@ -2531,14 +2555,12 @@ F53544320226550001A80001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5B588F00156DAF301000001 = { buildActionMask = 2147483647; files = ( ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5B588F10156DAF301000001 = { buildActionMask = 2147483647; @@ -2547,7 +2569,6 @@ F5B589080156DC2201000001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5B588F20156DAF301000001 = { buildActionMask = 2147483647; @@ -2555,7 +2576,6 @@ F5B589090156DC2201000001, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5B588F30156DAF301000001 = { buildActionMask = 2147483647; @@ -2563,7 +2583,6 @@ F5B5890A0156DC2201000001, ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5B588F40156DC2201000001 = { children = ( @@ -2771,7 +2790,6 @@ F5B5890F0156DC2201000001, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5B5890D0156DC2201000001 = { fileRef = F5B588FF0156DC2201000001; @@ -2796,7 +2814,6 @@ files = ( ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5B589110156DC2201000001 = { buildActionMask = 2147483647; @@ -2805,7 +2822,6 @@ F5B589130156DC2201000001, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5B589120156DC2201000001 = { fileRef = F5B589000156DC2201000001; @@ -2825,7 +2841,6 @@ F5B589150156DC2201000001, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5B589150156DC2201000001 = { fileRef = F5B5884A0156D40B01000001; @@ -2838,7 +2853,6 @@ files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5CDEBAB01FC893201A80001 = { isa = PBXFileReference; @@ -3137,15 +3151,15 @@ F58F6B94025BD97701A8010C, F58F6BAC025BE14801A8010C, F58F6BAD025BE14801A8010C, + F543B87C0274842E01A8010C, + F58A18430278355D01A8010C, ); isa = PBXHeadersBuildPhase; - name = Headers; }; F5DF1C0B0254C6BA01A80001 = { buildActionMask = 2147483647; files = ( F58F6BAB025BDBA801A8010C, - F55F7F8D025BF4BA01A8010C, F5EDC614025BFB7301A8010C, F5EDC617025BFB7C01A8010C, F5EDC61A025BFB8601A8010C, @@ -3153,7 +3167,6 @@ F5EDC620025BFBB501A8010C, ); isa = PBXResourcesBuildPhase; - name = "Bundle Resources"; }; F5DF1C0C0254C6BA01A80001 = { buildActionMask = 2147483647; @@ -3164,9 +3177,10 @@ F58F6B8D025BC7C001A8010C, F58F6B91025BCF5901A8010C, F58F6B95025BD97801A8010C, + F543B87B0274842E01A8010C, + F58A18420278355D01A8010C, ); isa = PBXSourcesBuildPhase; - name = Sources; }; F5DF1C0D0254C6BA01A80001 = { buildActionMask = 2147483647; @@ -3174,14 +3188,12 @@ F58F6BAE025BE1E001A8010C, ); isa = PBXFrameworksBuildPhase; - name = "Frameworks & Libraries"; }; F5DF1C0E0254C6BA01A80001 = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; - name = "ResourceManager Resources"; }; F5DF1C0F0254C78801A80001 = { children = ( @@ -3197,6 +3209,8 @@ F58F6B8F025BCF5901A8010C, F58F6B93025BD97701A8010C, F58F6B92025BD97701A8010C, + F543B87D0274845501A8010C, + F58A183F0278353501A8010C, F51FB38E0256057F01A80001, ); isa = PBXGroup;