Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 69 lines (51 sloc) 1.584 kB
dc5be1c Initial check-in.
uli authored
1 /* =============================================================================
2 PROJECT: Filie
3 FILE: NSString+CarbonUtilities.m
4
5 COPYRIGHT: (c) 2002 by Nathan Day, all rights reserved.
6
7 AUTHORS: Nathan Day - ND
8
9 LICENSES: GNU GPL, Modified BSD
10
11 REVISIONS:
12 2002-08-03 ND Created.
13 ========================================================================== */
14
15 // -----------------------------------------------------------------------------
16 // Headers:
17 // -----------------------------------------------------------------------------
18
19 #import "NSString+CarbonUtilities.h"
20
21 /*
22 * class implementation NSString (CarbonUtilities)
23 */
24 @implementation NSString (CarbonUtilities)
25
26 /*
27 * +stringWithFSRef:
28 */
29 + (NSString *)stringWithFSRef:(const FSRef *)aFSRef
30 {
31 if( !aFSRef )
32 return nil;
33 UInt8 thePath[PATH_MAX + 1]; // plus 1 for \0 terminator
34
35 return (FSRefMakePath ( aFSRef, thePath, PATH_MAX ) == noErr) ? [NSString stringWithUTF8String: (char*) thePath] : nil;
36 }
37
38 /*
39 * -getFSRef:
40 */
41 - (BOOL)getFSRef:(FSRef *)aFSRef
42 {
43 return FSPathMakeRef( (UInt8*) [self UTF8String], aFSRef, NULL ) == noErr;
44 }
45
46 /*
47 * -resolveAliasFile
48 */
49 - (NSString *)resolveAliasFile
50 {
51 FSRef theRef;
52 Boolean theIsTargetFolder,
53 theWasAliased;
54 NSString * theResolvedAlias = nil;;
55
56 [self getFSRef:&theRef];
57
58 if( (FSResolveAliasFile ( &theRef, YES, &theIsTargetFolder, &theWasAliased ) == noErr) )
59 {
60 theResolvedAlias = (theWasAliased) ? [NSString stringWithFSRef:&theRef] : self;
61 }
62
63 return theResolvedAlias;
64 }
65
66 @end
67
68
Something went wrong with that request. Please try again.