Index: lang/cplusplus/fcgi-v8/trunk/io.cc
===================================================================
--- lang/cplusplus/fcgi-v8/trunk/io.cc (revision 18871)
+++ lang/cplusplus/fcgi-v8/trunk/io.cc (revision 18871)
@@ -0,0 +1,28 @@
+#include <v8.h>
+#include <cstdio>
+#include <cstdlib>
+#include "v8-util.h"
+
+v8::Handle<v8::Value> _open(const v8::Arguments& args) {
+    if (args.Length() != 2) {
+        return v8::ThrowException(v8::String::New("Exception: missing args: open(fname, mode)"));
+    }
+    v8::HandleScope handle_scope;
+    v8::String::AsciiValue str(args[0]);
+    v8::String::AsciiValue mode(args[1]);
+
+    FILE *fh;
+    if ((fh = fopen(*str, *mode))>0) {
+        v8::Local<v8::Object> obj = v8::Object::New();
+        obj->Set(v8::String::New("fh"), v8::External::New((void*)fh));
+        return obj;
+    } else {
+        printf("cannot open file: %s\n", *str);
+        return v8::ThrowException(v8::String::New("Exception: cannot open file"));
+    }
+}
+
+void setup_io(v8::Handle<v8::ObjectTemplate> target) {
+    target->Set(v8::String::New("open"), v8::FunctionTemplate::New(_open));
+}
+
