1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-14 23:40:39 -08:00

Partially implement rename operations on SAF files

* java/org/gnu/emacs/EmacsSafThread.java
(postInvalidateCacheDir):
* java/org/gnu/emacs/EmacsService.java (renameDocument): New
functions.
* src/android.c (android_init_emacs_service):
* src/android.h (struct android_emacs_service): Link to new JNI
function.
* src/androidvfs.c (android_saf_rename_document): New function.
(android_saf_tree_rename): Implement in terms of that function
if possible.
This commit is contained in:
Po Lu 2023-07-30 13:39:27 +08:00
parent 7ce7a004f6
commit 37f68e8696
5 changed files with 293 additions and 5 deletions

View file

@ -1698,4 +1698,41 @@ public final class EmacsService extends Service
return -1;
}
/* Rename the document designated by DOCID inside the directory tree
identified by URI, which should be within the directory
designated by DIR, to NAME. If the file can't be renamed because
it doesn't support renaming, return -1, 0 otherwise. */
public int
renameDocument (String uri, String docId, String dir, String name)
throws FileNotFoundException
{
Uri tree, uriObject;
tree = Uri.parse (uri);
uriObject = DocumentsContract.buildDocumentUriUsingTree (tree, docId);
try
{
if (DocumentsContract.renameDocument (resolver, uriObject,
name)
!= null)
{
/* Invalidate the cache. */
if (storageThread != null)
storageThread.postInvalidateCacheDir (tree, docId,
name);
return 0;
}
}
catch (UnsupportedOperationException e)
{
;;
}
/* Handle unsupported operation exceptions specially, so
`android_rename' can return ENXDEV. */
return -1;
}
};