When project's constructor is given a file as its path, it sets its path to the parent directory of the given file

This commit is contained in:
Corey Johnson
2012-05-01 09:18:12 -07:00
parent acae9d63ca
commit 28f39cbdab
4 changed files with 29 additions and 5 deletions

View File

@@ -7,6 +7,8 @@ module.exports =
class Directory
@idCounter = 0
path: null
constructor: (@path) ->
@id = ++Directory.idCounter

View File

@@ -6,10 +6,20 @@ Directory = require 'directory'
module.exports =
class Project
path: null
rootDirectory: null
buffers: null
constructor: (@path) ->
constructor: (path) ->
@setPath(path)
@buffers = []
getPath: ->
@path
setPath: (path) ->
@path = if fs.isDirectory(path) then path else fs.directory(path)
@rootDirectory.off() if @rootDirectory
@rootDirectory = new Directory(@path)
getRootDirectory: ->

View File

@@ -35,14 +35,13 @@ class RootView extends View
@setTitle(@project?.path)
@on 'active-editor-path-change', (e, path) =>
@project.path ?= fs.directory(path) if path
@project.setPath(path) unless @project.getPath()
@setTitle(path)
@commandPanel = new CommandPanel({rootView: this})
if pathToOpen?
@project = new Project(fs.directory(pathToOpen))
@project = new Project(pathToOpen)
@open(pathToOpen) if fs.isFile(pathToOpen)
else
@project = new Project(projectPath)