示例#1
0
func (s *SpecInfoGatherer) onFileModify(watcher *fsnotify.Watcher, file string) {
	if util.IsSpec(file) {
		s.onSpecFileModify(file)
	} else if util.IsConcept(file) {
		s.onConceptFileModify(file)
	}
}
示例#2
0
func (specInfoGatherer *SpecInfoGatherer) fileModified(watcher *fsnotify.Watcher, fileName string) {
	if util.IsSpec(fileName) {
		specInfoGatherer.addSpec(fileName)
	} else if util.IsConcept(fileName) {
		specInfoGatherer.addConcept(fileName)
	}
}
示例#3
0
func (s *SpecInfoGatherer) onFileRemove(watcher *fsnotify.Watcher, file string) {
	if util.IsSpec(file) {
		s.onSpecFileRemove(file)
	} else if util.IsConcept(file) {
		s.onConceptFileRemove(file)
	} else {
		s.removeWatcherOn(watcher, file)
	}
}
示例#4
0
func (specInfoGatherer *SpecInfoGatherer) fileRemoved(watcher *fsnotify.Watcher, fileName string) {
	if util.IsSpec(fileName) {
		specInfoGatherer.removeSpec(fileName)
	} else if util.IsConcept(fileName) {
		specInfoGatherer.removeConcept(fileName)
	} else {
		specInfoGatherer.removeWatcherOn(watcher, fileName)
	}
}
示例#5
0
func (s *SpecInfoGatherer) handleEvent(event fsnotify.Event, watcher *fsnotify.Watcher) {
	s.waitGroup.Wait()

	file, err := filepath.Abs(event.Name)
	if err != nil {
		logger.APILog.Error("Failed to get abs file path for %s: %s", event.Name, err)
		return
	}
	if util.IsSpec(file) || util.IsConcept(file) {
		switch event.Op {
		case fsnotify.Create:
			s.onFileAdd(watcher, file)
		case fsnotify.Write:
			s.onFileModify(watcher, file)
		case fsnotify.Rename:
			s.onFileRename(watcher, file)
		case fsnotify.Remove:
			s.onFileRemove(watcher, file)
		}
	}
}