Reputation: 530
I would like to do some operation on my filesystem through a Thunderbird plugin. For example create a folder at a specific location and a text file, containing some data from thunderbird, in this folder.
As you know, Mozilla Extensions consist of javascript code. So I looked for this, found some code about ActiveXObject, which is not working for Thunderbird.
Any ideas what should I do about it?
Upvotes: 0
Views: 847
Reputation: 1
Here is a code snippet from my extension. I create text file in Profile directory and then I add some text into this file.
var path = Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path + "\\";
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(path);
file.append("settings.txt")
file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0664)
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance( Components.interfaces.nsIFileOutputStream );
outputStream.init( file, 0x04 | 0x10, 0664, 0 );
var output = "some text here"
var result = outputStream.write( output, output.length );
outputStream.close();
Upvotes: 0
Reputation: 33192
First, read up on extensions in general (Firefox docs apply to Thunderbird as well, except for the Add-on SDK, which does not really work with Thunderbird; go the XUL overlay route).
Then there are multiple ways to perform File I/O, in particular XPCOM stuff and OS.File
:
Upvotes: 1