along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
+
#include <allocator.h>
#include <assert.h>
#include <careadlinkat.h>
#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>
#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. */
/* 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;
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'. */
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);
/* 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)))
#include <errno.h>
#include <minmax.h>
#include <string.h>
+#include <systime.h>
#include <semaphore.h>
#include <sys/stat.h>
/* 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. */
/* 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;
}