       @trigger "removed"
 
   subscribeToNativeChangeEvents: ->
-    @watchSubscription = fs.watchPath @path, (eventType, path) =>
+    @watchSubscription = fsUtils.watchPath @path, (eventType, path) =>
       @handleNativeChangeEvent(eventType, path)
 
   unsubscribeFromNativeChangeEvents: ->

  cachedContents: null

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

  setPath: (@path) ->

  getPath: -> @path

  getBaseName: ->
    fs.base(@path)

  write: (text) ->
    previouslyExisted = @exists()
    @cachedContents = text
    fs.write(@getPath(), text)
    @subscribeToNativeChangeEvents() if not previouslyExisted and @subscriptionCount() > 0

  read: (flushCache)->
    if not @exists()
      @cachedContents = null
    else if not @cachedContents? or flushCache
      @cachedContents = fs.read(@getPath())
    else
      @cachedContents

  exists: ->
    fs.exists(@getPath())

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

EventEmitter = require 'event-emitter'

fs = require 'fs'
fsUtils = require 'fs-utils'
_ = require 'underscore'

module.exports =
