Changeset 903
- Timestamp:
- 12/03/04 15:56:07 (4 years ago)
- Files:
-
- Footagehead/trunk/FHHTMLHandler.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/FHHTMLHandler.m
r901 r903 1 /* $Id: FHHTMLHandler.m,v 1. 6 2004/12/03 12:29:49morris Exp $ */1 /* $Id: FHHTMLHandler.m,v 1.7 2004/12/03 14:56:07 morris Exp $ */ 2 2 3 3 /* … … 99 99 FHFile *file; 100 100 BOOL isDirectory; 101 unsigned int length; 102 int i = 0; 101 103 102 104 if(!_loadedFiles) { 103 // --- create objects 104 types = [NSImage FHImageFileTypes]; 105 tokenSet = [NSCharacterSet characterSetWithCharactersInString:@" =\r\n\t\"\'<>"]; 106 107 // --- select token 108 switch([FHSettings intForKey:FHExtract]) { 109 case FHExtractImages: 110 token = @"SRC"; 111 break; 105 length = [[[self URL] path] length]; 106 types = [NSImage FHImageFileTypes]; 107 tokenSet = [NSCharacterSet characterSetWithCharactersInString:@" =\r\n\t\"\'<>"]; 112 108 113 case FHExtractLinks: 114 default: 115 token = @"HREF"; 116 } 117 118 if(_html) { 119 // --- create scanner 120 scanner = [NSScanner scannerWithString:_html]; 121 [scanner setCaseSensitive:NO]; 122 [scanner setCharactersToBeSkipped:tokenSet]; 109 switch([FHSettings intForKey:FHExtract]) { 110 case FHExtractImages: 111 token = @"SRC"; 112 break; 113 114 case FHExtractLinks: 115 default: 116 token = @"HREF"; 117 } 123 118 124 // --- scan HTML 125 while(![scanner isAtEnd]) { 126 if([scanner scanUpToString:token intoString:NULL]) { 127 // --- scan next link 128 if(![scanner scanString:token intoString:NULL]) 129 continue; 130 131 if(![scanner scanUpToCharactersFromSet:tokenSet intoString:&link]) 132 continue; 133 134 if([link hasSuffix:@"/"]) { 135 // --- is it a dir? 136 isDirectory = YES; 137 } else { 138 // --- is it an image? 139 if(![types containsObject:[link pathExtension]]) 119 if(_html) { 120 scanner = [NSScanner scannerWithString:_html]; 121 [scanner setCaseSensitive:NO]; 122 [scanner setCharactersToBeSkipped:tokenSet]; 123 124 while(![scanner isAtEnd]) { 125 if([scanner scanUpToString:token intoString:NULL]) { 126 if(![scanner scanString:token intoString:NULL]) 140 127 continue; 128 129 if(![scanner scanUpToCharactersFromSet:tokenSet intoString:&link]) 130 continue; 131 132 if([link hasSuffix:@"/"]) { 133 // --- looks like a directory 134 isDirectory = YES; 135 } else { 136 // --- is it an image? 137 if(![types containsObject:[link pathExtension]]) 138 continue; 141 139 142 isDirectory = NO; 140 isDirectory = NO; 141 } 142 143 url = [[NSURL URLWithString:link relativeToURL:[self URL]] absoluteURL]; 144 145 if([[url path] isEqualToString:@"/"]) 146 continue; 147 148 if(isDirectory) { 149 if([[url path] length] < length) 150 continue; 151 } 152 153 file = [[FHFile alloc] initWithURL:url isDirectory:isDirectory index:i++]; 154 [_files addObject:file]; 155 [file release]; 143 156 } 144 145 // --- create url146 url = [[NSURL URLWithString:link relativeToURL:[self URL]] absoluteURL];147 148 if([[url path] isEqualToString:@"/"])149 continue;150 151 // --- create file152 file = [[FHFile alloc] initWithURL:url isDirectory:isDirectory];153 [_files addObject:file];154 [file release];155 157 } 156 158 } 157 } 158 159 _loadedFiles = YES; 159 160 _loadedFiles = YES; 160 161 } 161 162
