[uim-commit] r1168 - trunk/uim

tkng at freedesktop.org tkng at freedesktop.org
Tue Aug 9 10:28:47 EST 2005


Author: tkng
Date: 2005-08-08 17:28:25 -0700 (Mon, 08 Aug 2005)
New Revision: 1168

Modified:
   trunk/uim/uim-util.c
Log:
* uim/uim-util.c: Oops, forgotten to commit this file.
 -(get_file_mtime): New function.


Modified: trunk/uim/uim-util.c
===================================================================
--- trunk/uim/uim-util.c	2005-08-09 00:19:45 UTC (rev 1167)
+++ trunk/uim/uim-util.c	2005-08-09 00:28:25 UTC (rev 1168)
@@ -35,6 +35,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
@@ -599,6 +600,20 @@
   return uim_scm_f();
 }
 
+static uim_lisp
+get_file_mtime(uim_lisp f)
+{
+  const char *filename = uim_scm_refer_c_str(f);
+  struct stat buf;
+
+  if(stat(filename, &buf) == 0) {
+    return uim_scm_make_int(buf.st_mtime);
+  } else {
+    /* FIXME: Write error handling code. */
+    return uim_scm_make_int(0);
+  }
+}
+
 void
 uim_init_util_subrs(void)
 {
@@ -631,4 +646,5 @@
   uim_scm_init_subr_2("find-tail", find_tail);
   uim_scm_init_subr_1("lang-code->lang-name-raw", lang_code_to_lang_name_raw);
   uim_scm_init_subr_0("is-set-ugid?", is_setugidp);
+  uim_scm_init_subr_1("get-file-mtime", get_file_mtime);
 }



More information about the uim-commit mailing list