Subj : Re: Announce: egachine 0.1.0 To : netscape.public.mozilla.jseng From : Jens Thiele Date : Tue Nov 23 2004 11:28 am Shanti Rao schrieb: > Very cool, Jens! > > Does it have file system interaction, or do resources have to be Base64 > encoded in JS source? > > Shanti At the moment it provides a module wrapping the C++ std::streambuf class and wrappers for constructors instanciating (subclasses of) this class. (File, Net) - additionaly the stream module always provides - stdout, stdin, stderr objects The file module test: ejs.ModuleLoader.load("File"); if (!File.mode.read) throw new Error("failed"); stream=File.open("Makefile",File.mode.read); if ((s=stream.read(10))!="# Makefile") throw new Error("failed: \""+s+"\""); stream=File.read("Makefile"); if ((s=stream.read(10))!="# Makefile") throw new Error("failed: \""+s+"\""); fname="delme-filetest-346x63hg3"; stream=File.write(fname); stream.write("Hello World"); stream.sync(); stream=File.read(fname); s=stream.read(11); if (s!="Hello World") throw new Error("failed: \""+s+"\""); Note: - doesn't support unicode yet - especially the net module is quite ugly The examples encode the resources into the source for two reasons: The security modell of ejs is simplistic: - it has an untrusted mode (others would probably call it a restricted shell), which if entered doesn't allow much (no new network connections, no filesystem access, ...) - to have the example completely in one file Greetings Jens .