[Jslib] Problem with File.open('w')

Sudhakar Chandra thaths at openscroll.org
Fri Jul 30 20:24:32 EDT 2004


Hi,

I am facing a strange problem.  I am using JSLib version 0.1.185 under 
Mozilla 1.7.1.  I am having trouble opening a file to write.

My code looks something like this:

var localFile;
// localPatch contains the path to the file
try {
   localFile = new File(localPath);
} catch (e) {
   dump("Error initializing file: " + e + "\n");
}

if (! localFile.exists()) {
   try {
     dump(localPath + " does not exist. Creating\n");
     localFile.create();
   } catch (e) {
   dump("Error creating file " + localPath + " : " + e + "\n");
   }
}
dump(localPath + " Created\n");

try {
   dump("Trying to write to " + localPath + "\n");
   if(localFile.open('w')) {
     dump("Writing fetched data to " + localPath + "\n");
     localFile.write("" + xmlhttp.responseText);
   } else {
     dump("Unable to write into " + localPath + "\n");
   }
} catch (e) {
   dump("Error writing fetched data to local file\n");
}
localFile.close();


As you can see, it is pretty simple code.  If the file does not exist, 
the code is creating the file just fine.  The problem happens when 
opening the file for writing.  open() returns false and my code goes 
into the else branch and prints "Unable to write...".

Any ideas on how I can debug this?  Its is very possible that there is 
something wrong with my particular installation of Mozilla because I had 
trouble with my cookies not getting written to cookies.txt.

Thanks.

Thaths
-- 
"Kids, you tried your best and you failed miserably. The lesson is,
                  never try." -- Homer J. Simpson
Slacker Without Borders                        http://openscroll.org/
Key fingerprint = 8A 84 2E 67 10 9A 64 03  24 38 B6 AB 1B 6E 8C E4


More information about the Jslib mailing list