More helper methods (that will be refactored into a commonJS style object)

This commit is contained in:
Corey Johnson
2011-08-26 11:38:46 -07:00
parent 7bbadd52e0
commit 1b7d4737cc

View File

@@ -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()