From ali79qau at yahoo.com Fri Mar 19 03:09:39 2004 From: ali79qau at yahoo.com (Simon Brown) Date: Fri Mar 19 06:20:44 2004 Subject: [Jsconsole] File IO in JS Console, Help! Message-ID: <20040319110939.81961.qmail@web12826.mail.yahoo.com> Hi, I am trying to create a file and put some content in it, this is what i am doing... __IMPORT__( "chrome://mozlib/content/lib/js/io/file/", "file_instantiator.js" ); var IOFile = new IO_file_fileInstantiator(); IOFile.set_handle("Phoenix\test.txt"); IOFile.setOut("test"); IOFile.set_handle(); i've tried giving path in various ways like c:\\path, chrome://path etc... but i am getting this error: [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: chrome://mozlib/content/lib/js/io/file/instantiator.js :: anonymous :: line 72" data: no] Please guide me to the correct way of doing this... thanks! __________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com From dfour at noos.fr Fri Mar 19 17:50:14 2004 From: dfour at noos.fr (Daniel Fournier) Date: Fri Mar 19 12:01:51 2004 Subject: [Jsconsole] File IO in JS Console, Help! In-Reply-To: <20040319110939.81961.qmail@web12826.mail.yahoo.com> References: <20040319110939.81961.qmail@web12826.mail.yahoo.com> Message-ID: <405B24C6.2020409@noos.fr> Simon Brown wrote: > Hi, > > I am trying to create a file and put some content in > it, this is what i am doing... > > __IMPORT__( "chrome://mozlib/content/lib/js/io/file/", > "file_instantiator.js" ); > var IOFile = new IO_file_fileInstantiator(); > IOFile.set_handle("Phoenix\test.txt"); > IOFile.setOut("test"); > IOFile.set_handle(); > > i've tried giving path in various ways like c:\\path, > chrome://path etc... but i am getting this error: > > [Exception... "Component returned failure code: > 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) > [nsILocalFile.initWithPath]" nsresult: "0x80520001 > (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame > :: > chrome://mozlib/content/lib/js/io/file/instantiator.js > :: anonymous :: line 72" data: no] > > Please guide me to the correct way of doing this... thanks! > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - More reliable, more storage, less spam > http://mail.yahoo.com > _______________________________________________ > Jsconsole mailing list > Jsconsole@mozdev.org > http://mozdev.org/mailman/listinfo/jsconsole > IO_file_fileInstantiator::setHandle method arguments are: 1. integer constant: file type (directory or file) -- use IOFile.K.DIR_INSTANCE (1) for a directory and IOFile.K.FILE_INSTANCE (0) for a file; 2. string: local file system absolute path or chrome path (if the file is located in a chrome registered package) -- omitted to close the file handle; 3. integer: file permissions code (ala Unix) -- optional. Your call raises an exception because the 1st (mandatory) argument is missing. Have a look at setHandle method code in: chrome://mozlib/content/lib/js/io/file/instantiator.js at line 58 Daniel Fournier