-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenPanelDelegate.m
49 lines (42 loc) · 1.1 KB
/
OpenPanelDelegate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// OpenPanelDelegate.m
// FeatureViewer
//
// Created by Grogee on 10/2/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "OpenPanelDelegate.h"
@implementation OpenPanelDelegate
@synthesize basePath;
@synthesize extension;
@synthesize extensions;
-(BOOL)panel:(id)sender shouldEnableURL: (NSURL*)url
{
NSString *path = [url path];
NSArray *fileComps = [[path lastPathComponent] componentsSeparatedByString:@"."];
if( basePath != NULL )
{
NSRange range = [path rangeOfString:basePath];
if( range.location == NSNotFound)
{
return NO;
}
}
if( [fileComps count] > 1)
{
//next compare the second last path component to see if its a cluster
//if ([[fileComps objectAtIndex:1 /*[fileComps count]-2]*/] isEqualToString:extension])
NSInteger count = [fileComps count];
if( ([extensions containsObject: [fileComps objectAtIndex:count-2]] ) || ([extensions containsObject: [fileComps lastObject]]))
{
return YES;
}
else
{
return NO;
}
}
else
return NO;
}
@end