The R Project SVN R-packages

Rev

Rev 5095 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5095 Rev 5707
Line 62... Line 62...
62
    {
62
    {
63
        NSArray *a = [[NSFileManager defaultManager] directoryContentsAtPath:dir];
63
        NSArray *a = [[NSFileManager defaultManager] directoryContentsAtPath:dir];
64
        if (a==nil) return nil;
64
        if (a==nil) return nil;
65
	NSMutableArray *ca = [NSMutableArray arrayWithCapacity: 8];
65
	NSMutableArray *ca = [NSMutableArray arrayWithCapacity: 8];
66
        { 
66
        { 
67
            int i=0, firstMatch=-1, matches=0;
67
            int i=0, matches=0;
68
            NSString *common=nil;
68
            NSString *common=nil;
69
            while (i<[a count]) {
69
            while (i<[a count]) {
70
                NSString *sx = (NSString*) [a objectAtIndex:i];
70
                NSString *sx = (NSString*) [a objectAtIndex:i];
71
                if (voidFn || [sx hasPrefix: fn]) {
71
                if (voidFn || [sx hasPrefix: fn]) {
72
					BOOL isDir;
72
					BOOL isDir;
73
					if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", dir, sx] isDirectory:&isDir] && isDir)
73
					if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", dir, sx] isDirectory:&isDir] && isDir)
74
						sx = [sx stringByAppendingString:@"/"];
74
						sx = [sx stringByAppendingString:@"/"];
75
					if (homeCompletion) sx = [@"~" stringByAppendingString:sx];
75
					if (homeCompletion) sx = [@"~" stringByAppendingString:sx];
76
                    if (matches==0) {
76
                    if (matches==0)
77
                        firstMatch=i;
-
 
78
                        common=[[NSString alloc] initWithString: sx];
77
                            common = [[NSString alloc] initWithString: sx];
79
                    } else {
78
                    else {
80
                        NSString *cpref=[[NSString alloc] initWithString:[common commonPrefixWithString:sx options:0]];
79
                        NSString *cpref=[[NSString alloc] initWithString:[common commonPrefixWithString:sx options:0]];
81
                        [common release];
80
                        [common release];
82
                        common=cpref;
81
                        common=cpref;
83
                    }
82
                    }
84
					[ca addObject: [sx substringFromIndex:prefix]];
83
					[ca addObject: [sx substringFromIndex:prefix]];