Ported absolute and isFile to Objective-c.

This took fileFinder loading from .8 seconds to .35 seconds.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-03 17:50:43 -08:00
parent 982d5a4426
commit 7ba7ba2c81
2 changed files with 21 additions and 12 deletions

View File

@@ -155,6 +155,25 @@
});
}
- (BOOL)isFile:(NSString *)path {
BOOL isDir;
BOOL exists;
exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
return exists && !isDir;
}
- (NSString *)absolute:(NSString *)path {
path = [path stringByStandardizingPath];
if ([path characterAtIndex:0] == '/') {
return path;
}
NSString *resolvedPath = [[NSFileManager defaultManager] currentDirectoryPath];
resolvedPath = [[resolvedPath stringByAppendingPathComponent:path] stringByStandardizingPath];
return resolvedPath;
}
#pragma mark NSWindowDelegate
- (BOOL)windowShouldClose:(id)sender {
[self close];