]> git.eshelyaron.com Git - emacs.git/commitdiff
Better verify arguments to android-relinquish-directory-access
authorPo Lu <luangruo@yahoo.com>
Sun, 21 Apr 2024 13:11:22 +0000 (21:11 +0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Apr 2024 18:36:13 +0000 (20:36 +0200)
* src/androidvfs.c (Fandroid_relinquish_directory_access):
Provide for NULL values from android_name_file and remote files.

* src/xdisp.c (decode_mode_spec): Don't intern file-remote-p.
(syms_of_xdisp) <Qfile_remote_p>: New defsym.

(cherry picked from commit 4773ecb93193495f141e5d60c0c5ded58eaa2c98)

src/androidvfs.c
src/xdisp.c

index 9e65dd2b14036db75b289e26af418b9c8f9f1879..c4b3dba4af07d54b45dbb1b498b68d45ab5a0606 100644 (file)
@@ -7805,10 +7805,10 @@ DEFUN ("android-relinquish-directory-access",
        Sandroid_relinquish_directory_access, 1, 1,
        "DDirectory: ",
        doc: /* Relinquish access to the provided directory.
-DIRECTORY must be an inferior directory to a subdirectory of
-/content/storage.  Once the command completes, the parent of DIRECTORY
-below that subdirectory from will cease to appear there, but no files
-will be removed.  */)
+DIRECTORY must be the toplevel directory of an open SAF volume (i.e., a
+file under /content/storage), or one of its inferiors.  Once the command
+completes, the SAF directory holding this directory will vanish, but no
+files will be removed.  */)
   (Lisp_Object file)
 {
   struct android_vnode *vp;
@@ -7824,7 +7824,14 @@ will be removed.  */)
     return Qnil;
 
   file = ENCODE_FILE (Fexpand_file_name (file, Qnil));
-  vp   = android_name_file (SSDATA (file));
+
+  if (!NILP (call1 (Qfile_remote_p, file)))
+    signal_error ("Cannot relinquish access to remote file", file);
+
+  vp = android_name_file (SSDATA (file));
+
+  if (!vp)
+    report_file_error ("Relinquishing directory", file);
 
   if (vp->type != ANDROID_VNODE_SAF_TREE)
     {
index 5fe16ab95369618ea74cec92c93153767cef9722..72a217513ef83c0917eac7e44196f8677d32c8fa 100644 (file)
@@ -28860,7 +28860,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
        Lisp_Object val = Qnil;
 
        if (STRINGP (curdir))
-         val = dsafe_call1 (intern ("file-remote-p"), curdir);
+         val = dsafe_call1 (Qfile_remote_p, curdir);
 
        val = unbind_to (count, val);
 
@@ -38257,6 +38257,9 @@ The default value is zero, which disables this feature.
 The recommended non-zero value is between 100000 and 1000000,
 depending on your patience and the speed of your system.  */);
   max_redisplay_ticks = 0;
+
+  /* Called by decode_mode_spec.  */
+  DEFSYM (Qfile_remote_p, "file-remote-p");
 }