Changeset 4382
- Timestamp:
- 09/25/06 20:16:54 (2 years ago)
- Files:
-
- Footagehead/trunk/FHRangeHandler.m (modified) (2 diffs)
- Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/FHRangeHandler.m
r3400 r4382 31 31 #import "FHRangeHandler.h" 32 32 33 @interface FHRangeHandler(Private) 34 35 + (NSArray *)_getLinksForURL:(WIURL *)url; 36 37 @end 38 39 40 @implementation FHRangeHandler(Private) 41 42 + (NSArray *)_getLinksForURL:(WIURL *)url { 43 NSMutableArray *links; 44 NSArray *array; 45 NSString *string, *prefix, *suffix, *rangeString; 46 NSRange prefixRange, suffixRange; 47 unsigned int i, length, start, stop; 48 49 string = [url humanReadableString]; 50 prefixRange = [string rangeOfString:@"["]; 51 52 if(prefixRange.location == NSNotFound) 53 return NULL; 54 55 prefix = [string substringWithRange:NSMakeRange(0, prefixRange.location)]; 56 57 suffixRange = [string rangeOfString:@"]"]; 58 59 if(suffixRange.location == NSNotFound) 60 return NULL; 61 62 suffix = [string substringWithRange:NSMakeRange(suffixRange.location + 1, [string length] - suffixRange.location - 1)]; 63 64 rangeString = [string substringWithRange:NSMakeRange(prefixRange.location + 1, suffixRange.location - prefixRange.location - 1)]; 65 array = [rangeString componentsSeparatedByString:@"-"]; 66 67 if([array count] != 2) 68 return NULL; 69 70 start = [[array objectAtIndex:0] unsignedIntValue]; 71 stop = [[array objectAtIndex:1] unsignedIntValue]; 72 73 if(start == 0 && stop == 0) 74 return NULL; 75 76 links = [NSMutableArray arrayWithCapacity:stop - start + 1]; 77 length = [[array objectAtIndex:0] length]; 78 79 for(i = start; i <= stop; i++) 80 [links addObject:[NSSWF:@"%@%0.*u%@", prefix, length, i, suffix]]; 81 82 return links; 83 } 84 85 @end 86 87 33 88 @implementation FHRangeHandler 34 89 35 90 + (BOOL)handlesURL:(WIURL *)url isPrimary:(BOOL)primary { 36 NSString *string;37 38 91 if(primary && ![url isFileURL]) { 39 string = [url path]; 40 41 if(![[NSImage FHImageFileTypes] containsObject:[string pathExtension]]) 92 if(![[NSImage FHImageFileTypes] containsObject:[url pathExtension]]) 42 93 return NO; 43 94 44 if(([string containsSubstring:@"["] && [string containsSubstring:@"]"]) || 45 ([string containsSubstring:@"%5B"] && [string containsSubstring:@"%5D"])) 46 return YES; 95 if(![self _getLinksForURL:url]) 96 return NO; 97 98 return YES; 47 99 } 48 100 … … 55 107 56 108 - (id)initHandlerWithURL:(WIURL *)url { 57 NSArray *array;58 NSString *string, *preString, *postString, *rangeString;59 NSRange preRange, postRange;60 unsigned int i, length, start, stop;61 62 109 self = [super initHandlerWithURL:url]; 63 110 64 string = [[self URL] humanReadableString];111 _links = [[[self class] _getLinksForURL:url] retain]; 65 112 66 preRange = [string rangeOfString:@"["]; 67 preString = [string substringWithRange:NSMakeRange(0, preRange.location)]; 68 69 postRange = [string rangeOfString:@"]"]; 70 postString = [string substringWithRange:NSMakeRange(postRange.location + 1, [string length] - postRange.location - 1)]; 71 72 rangeString = [string substringWithRange:NSMakeRange(preRange.location + 1, postRange.location - preRange.location - 1)]; 73 74 array = [rangeString componentsSeparatedByString:@"-"]; 75 76 if([array count] != 2) { 113 if(!_links) { 77 114 [self release]; 78 115 79 116 return NULL; 80 117 } 81 82 start = [[array objectAtIndex:0] unsignedIntValue];83 stop = [[array objectAtIndex:1] unsignedIntValue];84 85 if(start == 0 && stop == 0) {86 [self release];87 88 return NULL;89 }90 91 _links = [[NSMutableArray alloc] initWithCapacity:stop - start + 1];92 length = [(NSString *) [array objectAtIndex:0] length];93 94 for(i = start; i <= stop; i++)95 [_links addObject:[NSSWF:@"%@%0.*u%@", preString, length, i, postString]];96 118 97 119 return self; Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj
r4263 r4382 998 998 }, 999 999 ); 1000 projectRoot = ""; 1000 1001 targets = ( 1001 1002 8D1107260486CEB800E47090 /* Footagehead */,
