-/* $Id: js_fd.c,v 1.31 2005/07/04 13:52:42 mmondor Exp $ */
+/* $Id: js_fd.c,v 1.32 2005/07/07 00:11:17 mmondor Exp $ */
/*
* Copyright (c) 2005, Matthew Mondor
* - rename(2), unlink(2) etc would be useful, but we need another class
* for this (maybe a VFS static class?) Maybe even something calling
* execve(2) and fork(2), those primitives... popen(3) also.
+ * - Also opendir(3) and friends wrapper...
* - Error numbers for errno should be placed in a separate class, Errno?
*/
#define QUEUE_EXCEPTION(s) do { \
JS_SetPendingException(cx, \
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (s)))); \
- (void) fprintf(stderr, " * %s\n", (s)); \
} while (/* CONSTCOND */0)
/* We can finally attempt to open(2) */
if ((fd = open(bytes, flags, mode)) == -1) {
jsfd->error = errno;
- QUEUE_EXCEPTION(strerror(errno));
+ /*
+ * XXX strerror() seems to always need to load up the
+ * nls table file, which is way silly for performance.
+ * This is related to locale stuff, and should be able
+ * to simply be disabled, even.
+ * Since this event occurs often in httpd.js, let's just
+ * output a fixed string for now.
+ * I should actually fix NetBSD libc on this matter.
+ */
+/* QUEUE_EXCEPTION(strerror(errno)); */
+ QUEUE_EXCEPTION("open() error");
JS_free(cx, jsfd->u.file.path);
return JS_FALSE;
}
DEFINE_INT_PROP("st_uid", st.st_uid);
DEFINE_INT_PROP("st_gid", st.st_gid);
DEFINE_INT_PROP("st_rdev", st.st_rdev);
- /* Dates... XXX Should probably provide JS-friendly Date? */
/*
- * XXX Note: there are off_t and int64_t fields which won't properly
- * be converted
+ * XXX
+ * The three times in struct stat are struct timespec (seconds since
+ * epoch, and nanoseconds in current second. I should probably
+ * provide exactly the same, making sure that it be in GMT, possibly.
+ * Or, I could leave the application convert it to GMT. However, I
+ * then need a new object for storage of the two values, unless I
+ * converted them into a string with some field separator character.
+ * For now, I'll just care about the seconds and return those, and
+ * will return them in GMT. This is currently used by httpd.js to
+ * verify if a file was modified before sending it again, or before
+ * needing to read and parse scripts again.
+ */
+ /*
+ * XXX Seems that I am exceeding the JavaScript maximum integer size!
+ * Will I need to create my own arithmetic types!?
+ * This seems to be related to the way jsval are stored.
+ * jsval probably should be a structure or union, at the expense
+ * of some performance loss perhaps.
+ * I now return time in minutes instead!
+ */
+ DEFINE_INT_PROP("st_atime", st.st_atime / 60);
+ DEFINE_INT_PROP("st_mtime", st.st_mtime / 60);
+ DEFINE_INT_PROP("st_ctime", st.st_ctime / 60);
+ /*
+ * XXX Note: there are off_t and int64_t fields which won't properly
+ * be converted.
*/
DEFINE_INT_PROP("st_size", st.st_size);
DEFINE_INT_PROP("st_blocks", st.st_blocks);