Include installation date within asset files
* src/android.c (setEmacsParams): Set `emacs_installation_time' to the mtime of the class path file, which happens to be the time of Emacs's installation. (emacs_installation_time): New variable. * src/android.h (emacs_installation_time): Export new variable. * src/androidvfs.c (android_afs_stat): If emacs_installation_time is a valid timespec, set st_mtime to it.
This commit is contained in:
parent
128ed5c9f1
commit
21a0caea77
3 changed files with 47 additions and 3 deletions
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <allocator.h>
|
||||
#include <assert.h>
|
||||
#include <careadlinkat.h>
|
||||
|
@ -31,12 +32,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <signal.h>
|
||||
#include <stat-time.h>
|
||||
#include <stdckdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <timespec.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Old NDK versions lack MIN and MAX. */
|
||||
#include <minmax.h>
|
||||
|
||||
|
@ -47,6 +51,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include "blockinput.h"
|
||||
#include "coding.h"
|
||||
#include "epaths.h"
|
||||
#include "systime.h"
|
||||
|
||||
/* Whether or not Emacs is running inside the application process and
|
||||
Android windowing should be enabled. */
|
||||
|
@ -187,6 +192,10 @@ static struct android_emacs_window window_class;
|
|||
/* Various methods associated with the EmacsCursor class. */
|
||||
static struct android_emacs_cursor cursor_class;
|
||||
|
||||
/* The time at which Emacs was installed, which also supplies the
|
||||
mtime of asset files. */
|
||||
struct timespec emacs_installation_time;
|
||||
|
||||
/* The last event serial used. This is a 32 bit value, but it is
|
||||
stored in unsigned long to be consistent with X. */
|
||||
unsigned int event_serial;
|
||||
|
@ -1247,6 +1256,7 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
|
|||
int pipefd[2];
|
||||
pthread_t thread;
|
||||
const char *java_string;
|
||||
struct stat statb;
|
||||
|
||||
/* Set the Android API level early, as it is used by
|
||||
`android_vfs_init'. */
|
||||
|
@ -1341,13 +1351,24 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
|
|||
|
||||
android_class_path = strdup ((const char *) java_string);
|
||||
|
||||
if (!android_files_dir)
|
||||
if (!android_class_path)
|
||||
emacs_abort ();
|
||||
|
||||
(*env)->ReleaseStringUTFChars (env, (jstring) class_path,
|
||||
java_string);
|
||||
}
|
||||
|
||||
/* Derive the installation date from the modification time of the
|
||||
file constitituing the class path. */
|
||||
|
||||
emacs_installation_time = invalid_timespec ();
|
||||
|
||||
if (class_path)
|
||||
{
|
||||
if (!stat (android_class_path, &statb))
|
||||
emacs_installation_time = get_stat_mtime (&statb);
|
||||
}
|
||||
|
||||
/* Calculate the site-lisp path. */
|
||||
|
||||
android_site_load_path = malloc (PATH_MAX + 1);
|
||||
|
|
|
@ -299,6 +299,10 @@ extern jobject emacs_service;
|
|||
/* Various methods associated with the EmacsService. */
|
||||
extern struct android_emacs_service service_class;
|
||||
|
||||
/* The time at which Emacs was installed, which also supplies the
|
||||
mtime of asset files. */
|
||||
extern struct timespec emacs_installation_time;
|
||||
|
||||
#define ANDROID_DELETE_LOCAL_REF(ref) \
|
||||
((*android_java_env)->DeleteLocalRef (android_java_env, \
|
||||
(ref)))
|
||||
|
|
|
@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include <errno.h>
|
||||
#include <minmax.h>
|
||||
#include <string.h>
|
||||
#include <systime.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
@ -2058,7 +2059,7 @@ android_afs_stat (struct android_vnode *vnode, struct stat *statb)
|
|||
/* Concoct a nonexistent device and an inode number. */
|
||||
statb->st_dev = -1;
|
||||
statb->st_ino = 0;
|
||||
return 0;
|
||||
goto set_file_times;
|
||||
}
|
||||
|
||||
/* AASSET_MODE_STREAMING is fastest here. */
|
||||
|
@ -2083,6 +2084,24 @@ android_afs_stat (struct android_vnode *vnode, struct stat *statb)
|
|||
|
||||
/* Close the asset. */
|
||||
AAsset_close (asset_desc);
|
||||
|
||||
set_file_times:
|
||||
|
||||
/* If the installation date can be ascertained, return that as the
|
||||
file's modification time. */
|
||||
|
||||
if (timespec_valid_p (emacs_installation_time))
|
||||
{
|
||||
#ifdef STAT_TIMESPEC
|
||||
STAT_TIMESPEC (statb, st_mtim) = emacs_installation_time;
|
||||
#else /* !STAT_TIMESPEC */
|
||||
/* Headers supplied by the NDK r10b contain a `struct stat'
|
||||
without POSIX fields for nano-second timestamps. */
|
||||
statb->st_mtime = emacs_installation_time.tv_sec;
|
||||
statb->st_mtime_nsec = emacs_installation_time.tv_nsec;
|
||||
#endif /* STAT_TIMESPEC */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue