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:
@@ -64,3 +64,12 @@ describe "Directory", ->
|
||||
runs -> fs.remove(temporaryFilePath)
|
||||
waits 20
|
||||
runs -> expect(changeHandler.callCount).toBe 0
|
||||
|
||||
it "includes symlink information about entries", ->
|
||||
entries = directory.getEntries()
|
||||
for entry in entries
|
||||
name = entry.getBaseName()
|
||||
if name is 'symlink-to-dir' or name is 'symlink-to-file'
|
||||
expect(entry.symlink).toBeTruthy()
|
||||
else
|
||||
expect(entry.symlink).toBeFalsy()
|
||||
|
||||
1
spec/fixtures/symlink-to-file
vendored
Symbolic link
1
spec/fixtures/symlink-to-file
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
sample.js
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -14,19 +14,22 @@ class FileView extends View
|
||||
file: null
|
||||
|
||||
initialize: ({@file, @project} = {}) ->
|
||||
extension = fs.extension(@getPath())
|
||||
if fs.isReadmePath(@getPath())
|
||||
@fileName.addClass('readme-icon')
|
||||
else if fs.isCompressedExtension(extension)
|
||||
@fileName.addClass('compressed-icon')
|
||||
else if fs.isImageExtension(extension)
|
||||
@fileName.addClass('image-icon')
|
||||
else if fs.isPdfExtension(extension)
|
||||
@fileName.addClass('pdf-icon')
|
||||
else if fs.isBinaryExtension(extension)
|
||||
@fileName.addClass('binary-icon')
|
||||
if @file.symlink
|
||||
@fileName.addClass('symlink-icon')
|
||||
else
|
||||
@fileName.addClass('text-icon')
|
||||
extension = fs.extension(@getPath())
|
||||
if fs.isReadmePath(@getPath())
|
||||
@fileName.addClass('readme-icon')
|
||||
else if fs.isCompressedExtension(extension)
|
||||
@fileName.addClass('compressed-icon')
|
||||
else if fs.isImageExtension(extension)
|
||||
@fileName.addClass('image-icon')
|
||||
else if fs.isPdfExtension(extension)
|
||||
@fileName.addClass('pdf-icon')
|
||||
else if fs.isBinaryExtension(extension)
|
||||
@fileName.addClass('binary-icon')
|
||||
else
|
||||
@fileName.addClass('text-icon')
|
||||
|
||||
if git?
|
||||
@subscribe git, 'status-changed', (path, status) =>
|
||||
|
||||
Binary file not shown.
@@ -126,6 +126,11 @@
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.tree-view .file .symlink-icon:before {
|
||||
content: "\f09b";
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.tree-view .directory > .header .disclosure-arrow:before {
|
||||
content: "\f05a";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user