Welcome to weblogs.com.pk Sign in | Join | Help

Adnan Siddiqi

Lets get technical


  • View Adnan Siddiqi's profile on LinkedIn
I/O in Javascript

This is something which every web2.0 wants to be provided in Web browsers and people have been using different techniques to store data on client side like using hidden flash applets or by using Mozilla's API to store data by calling XP Components.

Neil reports about new API being provided by Mozilla to perform I/O operations in Javascript. Imagine you have been provided something like following to create text files in Javascript, how would you feel?


// write a string to the file stuff.txt from the Home directory.
var file = IO.newFile("Home", "stuff.txt");
var stream = IO.newOutputStream(file, "text");
stream.writeString("This is a file\n");



// get the file stuff.txt from the Home directory.
// 'Home' is a key used in the directory service and 'stuff.txt' is a filename.
var file1 = IO.newFile("Home", "stuff.txt");

// get a direct path
var file2 = IO.newFileWithPath("/usr/local/myfile.txt");

// write a UTF-8 string to the file
var stream = IO.newOutputStream(file1, "text");
stream.writeString("This is a file\n");


Interesting, isn't it? Read further about Scriptable IO. The question which would naturally comes in any developer's mind is Security. Would it not be damn easy for hackers to inject I/O code on runtime which could become the reason of compromising your system security. I don't know. Only Mozilla guys could shed some light upon it.


Posted: Thursday, May 10, 2007 11:54 PM by kadnan


No Comments

Anonymous comments are disabled