Changeset 871

Show
Ignore:
Timestamp:
07/03/04 08:56:32 (4 years ago)
Author:
morris
Message:

add folders and parent logic

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Footagehead/trunk/FHHTMLHandler.m

    r866 r871  
    1 /* $Id: FHHTMLHandler.m,v 1.1 2004/06/14 23:36:06 morris Exp $ */ 
     1/* $Id: FHHTMLHandler.m,v 1.2 2004/07/03 06:56:32 morris Exp $ */ 
    22 
    33/* 
     
    100100        NSScanner               *scanner; 
    101101        FHFile                  *file; 
     102        BOOL                    isDirectory; 
    102103         
    103104        if(_files) 
     
    130131                        if([scanner scanUpToString:token intoString:NULL]) { 
    131132                                // --- scan next link 
    132                                 [scanner scanString:token intoString:NULL]; 
    133                                 [scanner scanUpToCharactersFromSet:tokenSet intoString:&link]; 
    134                                  
    135                                 // --- is it an image? 
    136                                 if(![types containsObject:[link pathExtension]])  
     133                                if(![scanner scanString:token intoString:NULL]) 
    137134                                        continue; 
    138135                                 
    139                                 // --- bump number of images 
    140                                 _numberOfImages++; 
     136                                if(![scanner scanUpToCharactersFromSet:tokenSet intoString:&link]) 
     137                                        continue; 
     138                                 
     139                                if([link hasSuffix:@"/"]) { 
     140                                        // --- is it a dir? 
     141                                        if([link hasPrefix:@"/"]) 
     142                                                continue; 
     143                                         
     144                                        isDirectory = YES; 
     145                                } else { 
     146                                        // --- is it an image? 
     147                                        if(![types containsObject:[link pathExtension]])  
     148                                                continue; 
     149                                         
     150                                        _numberOfImages++; 
     151 
     152                                        isDirectory = NO; 
     153                                } 
    141154 
    142155                                // --- create file 
    143156                                file = [[FHFile alloc] initWithURL: 
    144157                                        [[NSURL URLWithString:link relativeToURL:[self URL]] absoluteURL] 
    145                                                                            isDirectory:NO]; 
     158                                                                           isDirectory:isDirectory]; 
    146159                                [_files addObject:file]; 
    147160                                [file release]; 
     
    176189 
    177190- (NSURL *)parentURL { 
    178         return [self URL]; 
     191        NSString                *string; 
     192        NSRange                 range; 
     193         
     194        string = [_url absoluteString]; 
     195         
     196        while([string hasSuffix:@"/"]) 
     197                string = [string substringToIndex:[string length] - 1]; 
     198         
     199        range = [string rangeOfString:@"/" options:NSBackwardsSearch]; 
     200         
     201        if(range.location == NSNotFound) 
     202                return [self URL]; 
     203         
     204        string = [string substringToIndex:range.location + 1]; 
     205         
     206        if([string hasSuffix:@"://"]) 
     207                return [self URL]; 
     208         
     209        return [NSURL URLWithString:string]; 
    179210} 
    180211