 
           @reset() if item is lastItem
 
+  readDirectory: (dirEntry, callback, error)->
+
+    callback.files  or= []
+    callback.i = 0
+
+    dirReader = dirEntry.createReader()
+    relative  = dirEntry.fullPath.replace(/^\//, "").replace /(.+?)\/?$/, "$1/"
+
+    dirReader.readEntries (entries)=>
+      for entry in entries
+        callback.i++
+        if entry.isFile
+          entry.file (file)->
+            file.relativePath = relative + file.name
+            callback.files.push file
+        else
+          @readDirectory entry, callback, error
+      if entries.length is callback.i
+        callback callback.files
+    , error
+
   setPath: (@path=@options.defaultPath)->
     {uploadToVM, title} = @getOptions()
     @updatePartial """

        <small>#{if uploadToVM then defaultPath else ''}</small>
      </div>
    """

  drop: (event)->
    super
    {files, items}  = event.originalEvent.dataTransfer
    # folders are not allowed
    if items.length
      for item in items
        itemEntry = item.webkitGetAsEntry?()
        if itemEntry.isDirectory
          return @notify "Folder uploads not available for now.", "error"

    if files.length >= 20
      @notify """

      filePath   = "[#{fsFile.vmName}]#{fsFile.path}"
      parentPath = "[#{fsFile.vmName}]#{fsFile.parentPath}"

      bindAbort = (nodeView)->
        nodeView.once "abortProgress", => fsFile.abort yes

      nodeView = @finder.treeController.nodes[filePath]
      if nodeView
      then bindAbort nodeView
      else
        @finder.treeController.on "NodeWasAdded", (nodeView)->
          if nodeView.getData().path is filePath
            bindAbort nodeView

        fsFile.save "", =>
          @finder.expandFolders FSHelper.getPathHierarchy parentPath

  viewAppended: ->
    super
