From 3d32e2c2590c00c98507b2902f8cee4d0adede2d Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Sat, 17 Dec 2022 16:41:54 +0100 Subject: [PATCH] example 'cl-repl': android: ensure write permission of copied asset files --- examples/cl-repl/lisp/ini.lisp | 8 +------- src/cpp/ecl_ext.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/cl-repl/lisp/ini.lisp b/examples/cl-repl/lisp/ini.lisp index 6065822..28ba3e9 100644 --- a/examples/cl-repl/lisp/ini.lisp +++ b/examples/cl-repl/lisp/ini.lisp @@ -35,7 +35,7 @@ ;;; check version #+mobile -(defconstant +version+ 2) +(defconstant +version+ 3) #+mobile (let ((.version (merge-pathnames ".version"))) @@ -47,12 +47,6 @@ (alexandria:write-string-into-file (princ-to-string +version+) .version :if-exists :supersede))) -#+android -(progn - ;; copied asset files are read-only by default - (when (probe-file "settings/") - (shell "chmod 664 settings/*.lisp"))) - ;;; hacks ;; needed for :sockets (linked as static lib) diff --git a/src/cpp/ecl_ext.cpp b/src/cpp/ecl_ext.cpp index 15e8e96..e92c2ce 100644 --- a/src/cpp/ecl_ext.cpp +++ b/src/cpp/ecl_ext.cpp @@ -623,7 +623,12 @@ cl_object qcopy_file(cl_object l_from, cl_object l_to) { /// Convenience function for android, for e.g. copying files from 'assets:/', /// which can't be accessed directly from Lisp. /// (qcopy-file "assets:/lib/asdf.fas" "asdf.fas") - bool ok = QFile::copy(toQString(l_from), toQString(l_to)); + QString to(toQString(l_to)); + bool ok = QFile::copy(toQString(l_from), to); +#ifdef Q_OS_ANDROID + // copied asset files are read-only by default + QFile::setPermissions(to, QFile::permissions(to) | QFileDevice::WriteOwner); +#endif ecl_return1(ecl_process_env(), ok ? ECL_T : ECL_NIL); }