diff --git a/Atom/Classes/AtomController.m b/Atom/Classes/AtomController.m index c544b5aff..cb10a444f 100644 --- a/Atom/Classes/AtomController.m +++ b/Atom/Classes/AtomController.m @@ -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]; diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index 31898dfcc..ea9053275 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -9,13 +9,7 @@ module.exports = # Make the given path absolute by resolving it against the # current working directory. absolute: (path) -> - path = OSX.NSString.stringWithString(path).stringByStandardizingPath - return path if path.toString()[0] == "/" - - resolvedString = OSX.NSString.stringWithString(@workingDirectory()) - resolvedString = resolvedString.stringByAppendingPathComponent(path).stringByStandardizingPath - - resolvedString.toString() + $atomController.absolute(path).toString() # Return the basename of the given path. That is the path with # any leading directory components removed. If specified, also @@ -48,11 +42,7 @@ module.exports = # Returns true if the file specified by path exists and is a # regular file. isFile: (path) -> - path = @absolute path - isDir = new jscocoa.outArgument - exists = OSX.NSFileManager.defaultManager. - fileExistsAtPath_isDirectory path, isDir - exists and not isDir.valueOf() + $atomController.isFile path # Returns an array with all the names of files contained # in the directory path.