#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include "dumpemacs.h"
int is_emacs_valid(int debugflag)
{
struct stat sb;
int ret;
time_t lastMod;
ret = lstat(kEmacsArchPath, &sb);
if(ret == -1) {
if(errno == ENOENT)
return 0; else
return -1; }
if(S_ISDIR(sb.st_mode)) {
errno = EISDIR;
return -1;
} else if(!S_ISREG(sb.st_mode)) {
return 0;
}
lastMod = sb.st_mtime;
ret = lstat(kEmacsWrapperPath, &sb);
if(ret == -1)
return -1;
if(sb.st_mtime > lastMod) {
return 0; }
ret = lstat(kDumpEmacsPath, &sb);
if(ret == -1)
return -1;
if(sb.st_mtime > lastMod) {
return 0; }
return 1;
}