Fix visiting and saving writable content provider files
* java/org/gnu/emacs/EmacsService.java (checkContentUri): Improve debug output. * lisp/files.el (basic-save-buffer): Check whether or not file itself exists before checking for the existence of the directory containing it. * src/android.c (android_open): Don't forget to set errno after open_content_uri fails.
This commit is contained in:
parent
4354a3b699
commit
48b5a770f2
3 changed files with 19 additions and 2 deletions
|
@ -752,6 +752,8 @@ invocation of app_process (through android-emacs) can
|
|||
if (writable)
|
||||
mode += "w";
|
||||
|
||||
Log.d (TAG, "checkContentUri: checking against mode " + mode);
|
||||
|
||||
try
|
||||
{
|
||||
fd = resolver.openFileDescriptor (Uri.parse (name), mode);
|
||||
|
|
|
@ -5726,9 +5726,14 @@ Before and after saving the buffer, this function runs
|
|||
(run-hook-with-args-until-success 'write-file-functions)
|
||||
;; If a hook returned t, file is already "written".
|
||||
;; Otherwise, write it the usual way now.
|
||||
(let ((dir (file-name-directory
|
||||
(let ((file (buffer-file-name))
|
||||
(dir (file-name-directory
|
||||
(expand-file-name buffer-file-name))))
|
||||
(unless (file-exists-p dir)
|
||||
;; Some systems have directories (like /content on
|
||||
;; Android) in which files can exist without a
|
||||
;; corresponding parent directory.
|
||||
(unless (or (file-exists-p file)
|
||||
(file-exists-p dir))
|
||||
(if (y-or-n-p
|
||||
(format-message
|
||||
"Directory `%s' does not exist; create? " dir))
|
||||
|
|
|
@ -1715,9 +1715,19 @@ android_open (const char *filename, int oflag, int mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* If fd is -1, just assume that the file does not exist,
|
||||
and return -1 with errno set to ENOENT. */
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
errno = ENOENT;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
if (mode & O_CLOEXEC)
|
||||
android_close_on_exec (fd);
|
||||
|
||||
skip:
|
||||
ANDROID_DELETE_LOCAL_REF (string);
|
||||
return fd;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue