summaryrefslogtreecommitdiff
path: root/src/w32notify.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-11-27 18:03:02 +0200
committerEli Zaretskii <eliz@gnu.org>2013-11-27 18:03:02 +0200
commitfb6a5d68e3cbb993a9c72f0bf20e74951e873e72 (patch)
treeaa04b16d9963e2720f629634993fd6d1400ea6cf /src/w32notify.c
parent1baa1e49d84061e964802eba34713052804185f8 (diff)
downloademacs-fb6a5d68e3cbb993a9c72f0bf20e74951e873e72.tar.gz
Fix watching directories using w32notify.c.
src/w32notify.c (Fw32notify_add_watch): If the argument FILE is a directory, watch it and not its parent. (add_watch): Allow empty string in FILE. lisp/filenotify.el (file-notify-add-watch): Don't special-case w32notify when computing the directory to watch.
Diffstat (limited to 'src/w32notify.c')
-rw-r--r--src/w32notify.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/w32notify.c b/src/w32notify.c
index a48a83daf53..1f2ef83b2fd 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -324,7 +324,7 @@ add_watch (const char *parent_dir, const char *file, BOOL subdirs, DWORD flags)
HANDLE hdir;
struct notification *dirwatch = NULL;
- if (!file || !*file)
+ if (!file)
return NULL;
hdir = CreateFile (parent_dir,
@@ -526,13 +526,21 @@ generate notifications correctly, though. */)
report_file_error ("GetFullPathName failed",
Fcons (lisp_errstr, Fcons (file, Qnil)));
}
- /* We need the parent directory without the slash that follows it.
- If BASENAME is NULL, the argument was the root directory on its
- drive. */
- if (basename)
- basename[-1] = '\0';
+ /* filenotify.el always passes us a directory, either the parent
+ directory of a file to be watched, or the directory to be
+ watched. */
+ if (file_directory_p (parent_dir))
+ basename = "";
else
- subdirs = TRUE;
+ {
+ /* This should only happen if we are called directly, not via
+ filenotify.el. If BASENAME is NULL, the argument was the
+ root directory on its drive. */
+ if (basename)
+ basename[-1] = '\0';
+ else
+ subdirs = TRUE;
+ }
if (!NILP (Fmember (Qsubtree, filter)))
subdirs = TRUE;