I need my addon that can edit some files using an external tool. Any ideas?
This fragment shows or runs the file if there is a path:
var localFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); localFile.initWithPath("C:\\some-directory\\some-file.png"); if(localFile.exists()){ // localFile.reveal(); // open the containing folder of the file // localFile.launch(); // launch the file }
However, you may need to use nsIProcess to run the executable with the parameters (for example, the path to the file you are trying to open with the executable).
var exeFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); exeFile.initWithPath("C:\\Program Files\\...\\app.exe"); var parameter="C:\\some-directory\\some-file.txt"; if(exeFile.exists()){ var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(exeFile); process.run(false,[parameter],1); // launch the executable with another file as parameter. }
Documentation:
https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIFile https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsILocalFile https://developer.mozilla.org/en- US / docs / XPCOM_Interface_Reference / nsIProcess https://developer.mozilla.org/en-US/docs/Code_snippets/File_I_O
Source: https://habr.com/ru/post/1482764/More articles:Pickle Queue objects in python - pythonAngularJS: running e2e tests using karma - angularjsHow to run commands as root from Rails? - ruby | fooobar.comThe difference between and - dartThe bitset is divided into characters - c ++java htmlunit cannot load javascript - javaRunning opencv using java error - javaIs it worth passing kernel parameters through shared memory? - cudaSending AVAudioRecorder to iOS server - ios"this class is not key code compatible with the key ..." - iosAll Articles