From 1b7d4737cc0aeabf2a98dcfb05ca027e800e6ff5 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 26 Aug 2011 11:38:46 -0700 Subject: [PATCH] More helper methods (that will be refactored into a commonJS style object) --- HTML/lib/osx.coffee | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/HTML/lib/osx.coffee b/HTML/lib/osx.coffee index 73ead721d..ec6f76948 100644 --- a/HTML/lib/osx.coffee +++ b/HTML/lib/osx.coffee @@ -29,6 +29,7 @@ Chrome = # Returns null or a file path. openPanel: -> panel = OSX.NSOpenPanel.openPanel + panel.setCanChooseDirectories(true) if panel.runModal isnt OSX.NSFileHandlingPanelOKButton return null panel.filenames.lastObject @@ -120,15 +121,27 @@ File = OSX.NSString.stringWithString(path).stringByExpandingTildeInPath else path + isFile: (path) -> + isDir = new outArgument + exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir) + exists and not isDir.valueOf() + Dir = list: (path) -> path = File.expand path _.map OSX.NSFileManager.defaultManager.subpathsAtPath(path), (entry) -> "#{path}/#{entry}" + isDir: (path) -> + isDir = new outArgument + exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir) + exists and isDir.valueOf() Process = - cwd: -> - OSX.NSFileManager.defaultManager.currentDirectoryPath() + cwd: (path) -> + if dir? + OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath(path) + else + OSX.NSFileManager.defaultManager.currentDirectoryPath() env: -> OSX.NSProcess.processInfo.environment()