Show symlink file icon in tree view

This commit is contained in:
Kevin Sawicki
2013-03-25 16:49:19 -04:00
parent 502d3c2957
commit 513ed3b4b1
7 changed files with 47 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
_ = require 'underscore'
fs = require 'fs-utils'
fs = require 'fs'
fsUtils = require 'fs-utils'
File = require 'file'
EventEmitter = require 'event-emitter'
@@ -7,21 +8,27 @@ module.exports =
class Directory
path: null
constructor: (@path) ->
constructor: (@path, @symlink=false) ->
getBaseName: ->
fs.base(@path)
fsUtils.base(@path)
getPath: -> @path
getEntries: ->
directories = []
files = []
for path in fs.list(@path)
if fs.isDirectory(path)
directories.push(new Directory(path))
else if fs.isFile(path)
files.push(new File(path))
for path in fsUtils.list(@path)
try
stat = fs.lstatSync(path)
symlink = stat.isSymbolicLink()
stat = fs.statSync(path) if symlink
catch e
continue
if stat.isDirectory()
directories.push(new Directory(path, symlink))
else if stat.isFile()
files.push(new File(path, symlink))
directories.concat(files)
@@ -32,7 +39,7 @@ class Directory
@unsubscribeFromNativeChangeEvents() if @subscriptionCount() == 0
subscribeToNativeChangeEvents: ->
@watchSubscription = fs.watchPath @path, (eventType) =>
@watchSubscription = fsUtils.watchPath @path, (eventType) =>
@trigger "contents-changed" if eventType is "contents-change"
unsubscribeFromNativeChangeEvents: ->

View File

@@ -8,7 +8,7 @@ class File
path: null
cachedContents: null
constructor: (@path) ->
constructor: (@path, @symlink=false) ->
if @exists() and not fs.isFile(@path)
throw new Error("#{@path} is a directory")