       return if oldContents == newContents
       @trigger 'contents-changed'
 
+  # Private:
   detectResurrectionAfterDelay: ->
     _.delay (=> @detectResurrection()), 50
 
+  # Private:
   detectResurrection: ->
     if @exists()
       @subscribeToNativeChangeEvents()

    else
      @cachedContents

  # Checks to see if a file exists.
  #
  # Returns a {Boolean}.
  exists: ->
    fsUtils.exists(@getPath())

  ### Internal ###

  afterSubscribe: ->
    @subscribeToNativeChangeEvents() if @exists() and @subscriptionCount() == 1

  afterUnsubscribe: ->
    @unsubscribeFromNativeChangeEvents() if @subscriptionCount() == 0

  handleNativeChangeEvent: (eventType, path) ->
    if eventType is "delete"
      @unsubscribeFromNativeChangeEvents()


# Public: Represents an individual file in the editor.
#
# This class shouldn't be created directly, instead you should create a 
# {Directory} and access the {File} objects that it creates.
module.exports =
class File
  _.extend @prototype, EventEmitter
