【TODO】Atom源码阅读-pathwatcher

来源:互联网 发布:java单向链表 编辑:程序博客网 时间:2024/04/27 21:36

Atom项目基于许多子项目,这样方便维护与测试。今天来看看pathwatcher(atom/node-pathwatcher)这个项目。

既然nodejs本身提供了监控文件变化的方法,Atom还做了这样一个项目,是为了什么呢?官网的文档等于没有。。。所以还是得自己看。

File类

虽然是pathwatcher项目中的类,但是Atom的其他项目用的也是这个类,比如text-buffer这个项目,用的就是File类,其中的关键代码如下(text-buffer.coffee):

{File} = require 'pathwatcher'# Public: Set the path for the buffer's associated file.## * `filePath` A {String} representing the new file pathsetPath: (filePath) ->  return if filePath == @getPath()  if filePath    @file = new File(filePath)    @file.setEncoding(@getEncoding())    @subscribeToFile()  else    @file = null  @emitter.emit 'did-change-path', @getPath()

TODO

0 0
原创粉丝点击