PageRenderTime 30ms CodeModel.GetById 16ms app.highlight 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Test/objectivec_implementation.m

http://github.com/fishman/ctags
Objective C | 125 lines | 100 code | 24 blank | 1 comment | 5 complexity | fbc1034d42a6250ee755ba275e373e54 MD5 | raw file
Possible License(s): GPL-2.0
  1
  2@implementation FileTree
  3- (FileSize)getDiskSize
  4{
  5    return diskSize;
  6}
  7
  8- (id)initWithName:(NSString*)treeName
  9           atPlace:(FolderTree*)parentFolder
 10{
 11    self = [super init];
 12
 13    diskSize = 0;
 14    name = treeName;
 15    parent = parentFolder;
 16    [name retain];
 17    representation = nil;
 18
 19    return self;
 20}
 21
 22- (id)initWithName:(NSString*)treeName
 23           andSize:(FileSize)size
 24           atPlace:(FolderTree*)parentFolder
 25{
 26    self = [super init];
 27
 28    diskSize = size;
 29    name = treeName;
 30    parent = parentFolder;
 31    [name retain];
 32    representation = nil;
 33
 34    return self;
 35}
 36
 37- (void)dealloc
 38{
 39    [name release];
 40    [representation release];
 41    [super dealloc];
 42}
 43
 44- (LayoutTree*)createLayoutTree
 45{
 46    return nil;
 47}
 48@end
 49
 50@implementation FolderTree
 51- (id)initWithName:(NSString*)treeName
 52           atPlace:(FolderTree*)parentFolder
 53{
 54    self = [super initWithName:treeName
 55                       atPlace:parentFolder];
 56
 57    children = [[NSMutableArray alloc] init];
 58    return self;
 59}
 60
 61- (void)dealloc
 62{
 63    [children release];
 64    [super dealloc];
 65}
 66
 67+ (void) createFileList: (NSString*)root atPlace:(FolderTree*)parentFolder
 68{
 69	NSFileManager *localFileManager = [[NSFileManager alloc] init];
 70	NSURL		  *rootUrl = [NSURL fileURLWithPath:root];
 71	NSDirectoryEnumerator *dirEnumerator = [localFileManager enumeratorAtURL:rootUrl
 72											
 73                                                  includingPropertiesForKeys:[NSArray arrayWithObjects:
 74                                                                              NSURLNameKey,
 75                                                                              NSURLIsDirectoryKey,
 76                                                                              nil]
 77											
 78                                                                     options:NSDirectoryEnumerationSkipsHiddenFiles
 79											
 80                                                                errorHandler:nil];
 81    
 82	for (NSURL *theURL in dirEnumerator)
 83	{
 84        [theURL getResourceValue:&fileName
 85						  forKey:NSURLNameKey
 86						   error:NULL];
 87        
 88        // Ignore files under the _extras directory
 89        if ([isDirectory boolValue]==YES)
 90        {
 91            [folder populateChildList:root];
 92        }
 93        else if ([isDirectory boolValue]==NO)
 94        {
 95            [parentFolder addChild:f];
 96        }		
 97    }
 98}
 99
100- (void) populateChildList:(NSString*)root
101{
102    NSString *thisRoot = [[root stringByAppendingString:@"/"]
103                                stringByAppendingString:name];
104    
105    [FolderTree createFileList:thisRoot
106                       atPlace:self];
107    
108    for ( FileTree *f in children )
109        diskSize += [f getDiskSize];
110}
111
112- (FolderTree*)addChild:(FileTree*)subTree
113{
114    [children addObject:subTree];
115    return self;
116}
117
118- (LayoutTree*)createLayoutTree
119{
120    return
121        [[LayoutTree alloc] initWithFileList:children
122                                andTotalSize:diskSize];
123}
124@end
125