]> code.delx.au - gnu-emacs/commitdiff
Implement w32notify-valid-p
authorEli Zaretskii <eliz@gnu.org>
Mon, 14 Sep 2015 07:02:04 +0000 (10:02 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 14 Sep 2015 07:02:04 +0000 (10:02 +0300)
* src/w32notify.c (Fw32notify_valid_p): New function.  (Bug#21432)

* lisp/filenotify.el (w32notify-valid-p): No longer an alias for
'identity'.

lisp/filenotify.el
src/w32notify.c

index 9a48c5ee97956cfecc604f0261e616dd62cb7448..002c5a5d584c4f4d6cf25d797cd12c43c6d877e5 100644 (file)
@@ -359,7 +359,6 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'."
 
 ;; Temporary declarations.
 (defalias 'gfile-valid-p 'identity)
-(defalias 'w32notify-valid-p 'identity)
 
 (defun file-notify-valid-p (descriptor)
   "Check a watch specified by its DESCRIPTOR.
index ab6cd12ab938e6305e811aadf3fe43609f76e4b4..fa4ad01636b3033bde7c0f156ffb0285067c56d4 100644 (file)
@@ -628,6 +628,29 @@ w32_get_watch_object (void *desc)
   return NILP (watch_list) ? Qnil : assoc_no_quit (descriptor, watch_list);
 }
 
+DEFUN ("w32notify-valid-p", Fw32notify_valid_p, Sw32notify_valid_p, 1, 1, 0,
+       doc: /* "Check a watch specified by its WATCH-DESCRIPTOR for validity.
+
+WATCH-DESCRIPTOR should be an object returned by `w32notify-add-watch'.
+
+A watch can become invalid if the directory it watches is deleted, or if
+the watcher thread exits abnormally for any other reason.  */)
+     (Lisp_Object watch_descriptor)
+{
+  Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list);
+
+  if (!NILP (watch_object))
+    {
+      struct notification *dirwatch =
+       (struct notification *)XINTPTR (watch_descriptor);
+      if (w32_valid_pointer_p (dirwatch, sizeof(struct notification))
+         && dirwatch->dir != NULL)
+       return Qt;
+    }
+
+  return Qnil;
+}
+
 void
 globals_of_w32notify (void)
 {
@@ -648,6 +671,7 @@ syms_of_w32notify (void)
 
   defsubr (&Sw32notify_add_watch);
   defsubr (&Sw32notify_rm_watch);
+  defsubr (&Sw32notify_valid_p);
 
   staticpro (&watch_list);