* src/fileio.c (report_file_notify_error): New function.
* src/inotify.c (report_inotify_error): Remove function.
(inotify_callback, symbol_to_inotifymask, Finotify_add_watch)
(Finotify_rm_watch): Use report_file_notify_error.
* src/lisp.h (report_file_notify_error): Declare external function.
* src/w32notify.c (report_w32notify_error): Remove function.
(Fw32notify_add_watch, Fw32notify_rm_watch):
Use report_file_notify_error.
report_file_errno (string, name, errno);
}
+/* Like report_file_error, but reports a file-notify-error instead. */
+
+void
+report_file_notify_error (const char *string, Lisp_Object name)
+{
+ Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
+ synchronize_system_messages_locale ();
+ char *str = strerror (errno);
+ Lisp_Object errstring
+ = code_convert_string_norecord (build_unibyte_string (str),
+ Vlocale_coding_system, 0);
+ Lisp_Object errdata = Fcons (errstring, data);
+
+ xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
+}
+
void
close_file_unwind (int fd)
{
XCDR (watch_object));
}
-/* Like report_file_error, but reports a file-notify-error instead. */
-static _Noreturn void
-report_inotify_error (const char *string, Lisp_Object name)
-{
- Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errno);
- Lisp_Object errstring
- = code_convert_string_norecord (build_unibyte_string (str),
- Vlocale_coding_system, 0);
- Lisp_Object errdata = Fcons (errstring, data);
-
- xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
-}
-
/* This callback is called when the FD is available for read. The inotify
events are read from FD and converted into input_events. */
static void
to_read = 0;
if (ioctl (fd, FIONREAD, &to_read) == -1)
- report_inotify_error ("Error while trying to retrieve file system events",
- Qnil);
+ report_file_notify_error ("Error while retrieving file system events",
+ Qnil);
buffer = xmalloc (to_read);
n = read (fd, buffer, to_read);
if (n < 0)
{
xfree (buffer);
- report_inotify_error ("Error while trying to read file system events",
- Qnil);
+ report_file_notify_error ("Error while reading file system events", Qnil);
}
EVENT_INIT (event);
else
{
errno = EINVAL;
- report_inotify_error ("Unknown aspect", symb);
+ report_file_notify_error ("Unknown aspect", symb);
}
}
{
inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
if (inotifyfd < 0)
- report_inotify_error ("File watching (inotify) is not available", Qnil);
+ report_file_notify_error ("File watching is not available", Qnil);
watch_list = Qnil;
add_read_fd (inotifyfd, &inotify_callback, NULL);
}
encoded_file_name = ENCODE_FILE (file_name);
watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
if (watchdesc == -1)
- report_inotify_error ("Could not add watch for file", file_name);
+ report_file_notify_error ("Could not add watch for file", file_name);
watch_descriptor = make_watch_descriptor (watchdesc);
int wd = XINT (watch_descriptor);
if (inotify_rm_watch (inotifyfd, wd) == -1)
- report_inotify_error ("Could not rm watch", watch_descriptor);
+ report_file_notify_error ("Could not rm watch", watch_descriptor);
/* Remove watch descriptor from watch list. */
watch_object = Fassoc (watch_descriptor, watch_list);
extern void restore_point_unwind (Lisp_Object);
extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
extern _Noreturn void report_file_error (const char *, Lisp_Object);
+extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
extern bool internal_delete_file (Lisp_Object);
extern Lisp_Object emacs_readlinkat (int, const char *);
extern bool file_directory_p (const char *);
return flags;
}
-/* Like report_file_error, but reports a file-notify-error instead. */
-static void
-report_w32notify_error (const char *string, Lisp_Object name)
-{
- Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errno);
- Lisp_Object errstring
- = code_convert_string_norecord (build_unibyte_string (str),
- Vlocale_coding_system, 0);
- Lisp_Object errdata = Fcons (errstring, data);
-
- xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
-}
-
DEFUN ("w32notify-add-watch", Fw32notify_add_watch,
Sw32notify_add_watch, 3, 3, 0,
doc: /* Add a watch for filesystem events pertaining to FILE.
|| (w32_major_version == 5 && w32_major_version < 1))
{
errno = ENOSYS;
- report_w32notify_error ("Watching filesystem events is not supported",
- Qnil);
+ report_file_notify_error ("Watching filesystem events is not supported",
+ Qnil);
}
/* filenotify.el always passes us a directory, either the parent
Vlocale_coding_system, 0);
else
lisp_errstr = build_string (errstr);
- report_w32notify_error ("Cannot watch file",
- Fcons (lisp_errstr, Fcons (file, Qnil)));
+ report_file_notify_error ("Cannot watch file",
+ Fcons (lisp_errstr, Fcons (file, Qnil)));
}
else
- report_w32notify_error ("Cannot watch file", Fcons (file, Qnil));
+ report_file_notify_error ("Cannot watch file", Fcons (file, Qnil));
}
/* Store watch object in watch list. */
watch_descriptor = make_pointer_integer (dirwatch);
}
if (status == -1)
- report_w32notify_error ("Invalid watch descriptor", Fcons (watch_descriptor,
- Qnil));
+ report_file_notify_error ("Invalid watch descriptor",
+ Fcons (watch_descriptor, Qnil));
return Qnil;
}