diff --git a/plugins/project/project.coffee b/plugins/project/project.coffee
index 15fdbc2fd..6d26fdac5 100644
--- a/plugins/project/project.coffee
+++ b/plugins/project/project.coffee
@@ -1,7 +1,8 @@
$ = require 'jquery'
_ = require 'underscore'
-{Chrome, Dir, File, Process} = require 'osx'
+{Chrome, Process} = require 'osx'
+File = require 'fs'
Editor = require 'editor'
bindKey = Editor.bindKey
@@ -40,10 +41,10 @@ exports.reload = ->
$('#project li').remove()
- files = Dir.list dir
+ files = File.list dir
listItems = _.map files, (path) ->
filename = path.replace(dir, "").substring 1
- type = if Dir.isDir(path) then 'dir' else 'file'
+ type = if File.isDir(path) then 'dir' else 'file'
"
#{filename}"
$('#project .files').append listItems.join '\n'
diff --git a/plugins/tabs/tabs.coffee b/plugins/tabs/tabs.coffee
index 1e903b09a..f9d036fad 100644
--- a/plugins/tabs/tabs.coffee
+++ b/plugins/tabs/tabs.coffee
@@ -1,7 +1,8 @@
$ = require 'jquery'
_ = require 'underscore'
-{Chrome, File, Dir, Process} = require 'osx'
+{Chrome, Process} = require 'osx'
+File = require 'fs'
{bindKey} = require 'editor'
diff --git a/src/editor.coffee b/src/editor.coffee
index a064499cc..acf445971 100644
--- a/src/editor.coffee
+++ b/src/editor.coffee
@@ -3,7 +3,7 @@
$ = require 'jquery'
_ = require 'underscore'
-{Chrome, Process, Dir} = require 'osx'
+{Chrome, Process} = require 'osx'
File = require 'fs'
ace = require 'ace/ace'
@@ -24,7 +24,7 @@ save = ->
exports.open = open = (path) ->
filename = path
- if Dir.isDir filename
+ if File.isDir filename
Process.cwd filename
Chrome.title _.last filename.split '/'
editor.getSession().setValue ""
diff --git a/src/fs.coffee b/src/fs.coffee
index 78e1214e6..60fa2e426 100644
--- a/src/fs.coffee
+++ b/src/fs.coffee
@@ -12,6 +12,14 @@ module.exports =
else
path
+ # Returns true if the file specified by path exists and is a
+ # directory.
+ isDirectory: (path) ->
+ isDir = new jscocoa.outArgument
+ exists = OSX.NSFileManager.defaultManager.
+ fileExistsAtPath_isDirectory path, isDir
+ exists and isDir.valueOf()
+
# Returns true if the file specified by path exists and is a
# regular file.
isFile: (path) ->
@@ -20,6 +28,24 @@ module.exports =
fileExistsAtPath_isDirectory path, isDir
exists and not isDir.valueOf()
+ # Returns an array with all the names of files contained
+ # in the directory path.
+ list: (path, recursive) ->
+ path = File.absolute path
+ fm = OSX.NSFileManager.defaultManager
+ if recursive
+ paths = fm.subpathsAtPath path
+ else
+ paths = fm.contentsOfDirectoryAtPath_error path, null
+ _.map paths, (entry) -> "#{path}/#{entry}"
+
+ # Return an array with all directories below (and including)
+ # the given path, as discovered by depth-first traversal. Entries
+ # are in lexically sorted order within directories. Symbolic links
+ # to directories are not traversed into.
+ listDirectoryTree: (path) ->
+ @list path, true
+
# Open, read, and close a file, returning the file's contents.
read: (path) ->
OSX.NSString.stringWithContentsOfFile(@absolute path).toString()
diff --git a/src/osx.coffee b/src/osx.coffee
index bc401d22f..92785a89b 100644
--- a/src/osx.coffee
+++ b/src/osx.coffee
@@ -87,22 +87,6 @@ Chrome =
appRoot: ->
OSX.NSBundle.mainBundle.resourcePath
-# Handles the file system
-Dir =
- list: (path, recursive) ->
- path = File.absolute path
- fm = OSX.NSFileManager.defaultManager
- if recursive
- paths = fm.subpathsAtPath path
- else
- paths = fm.contentsOfDirectoryAtPath_error path, null
- _.map paths, (entry) -> "#{path}/#{entry}"
- isDir: (path) ->
- isDir = new jscocoa.outArgument
- exists = OSX.NSFileManager.defaultManager.
- fileExistsAtPath_isDirectory path, isDir
- exists and isDir.valueOf()
-
Process =
cwd: (path) ->
if path?
diff --git a/src/plugins.coffee b/src/plugins.coffee
index abe2261d0..4942c8cba 100644
--- a/src/plugins.coffee
+++ b/src/plugins.coffee
@@ -1,10 +1,10 @@
$ = require 'jquery'
_ = require 'underscore'
-{Chrome, Dir} = require 'osx'
+{Chrome} = require 'osx'
File = require 'fs'
-_.map Dir.list(Chrome.appRoot() + "/plugins"), (plugin) ->
+_.map File.list(Chrome.appRoot() + "/plugins"), (plugin) ->
require plugin
if css = File.read "~/.atomicity/twilight.css"
@@ -15,5 +15,5 @@ if css = File.read "~/.atomicity/twilight.css"
style.appendChild rules
head.appendChild style
-_.map Dir.list("~/.atomicity/"), (path) ->
+_.map File.list("~/.atomicity/"), (path) ->
require path