Skip to content

Commit

Permalink
Merge pull request #3 from guicho271828/master
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
ralt committed Nov 13, 2017
2 parents 9b21f38 + d0646a0 commit 1c47fdd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/fs-watcher.lisp
Expand Up @@ -13,14 +13,14 @@
(run-loop pathnames mtimes callback delay)))

(defun dir-contents (pathnames)
"Returns a list of all the contents in a directory"
(mapcar #'(lambda (pathname)
(when (directory-p pathname)
(walk-directory pathname
#'(lambda (pathname)
(push pathname pathnames))
:directories t)))
pathnames))
"For each directory, collect the file pathnames recursively. Results are appended and returned as a single list."
(let (acc)
(dolist (pathname pathnames acc)
(if (directory-p pathname)
(walk-directory pathname
#'(lambda (pathname)
(push pathname acc)))
(push pathname acc)))))

(defun run-loop (pathnames mtimes callback delay)
"The main loop constantly polling the filesystem"
Expand All @@ -29,8 +29,10 @@
(map nil
#'(lambda (pathname)
(let ((mtime (mtime pathname)))
(unless (eq mtime
(gethash pathname mtimes))
(unless (eql mtime
;; universal time or nil, so = is ng.
;; eq between integers is impl-dependent behavior
(gethash pathname mtimes))
(funcall callback pathname)
(if mtime
(setf (gethash pathname mtimes) mtime)
Expand Down

0 comments on commit 1c47fdd

Please sign in to comment.