mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Show symlink file icon in tree view
This commit is contained in:
@@ -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: ->
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user