Skip to content
Noitidart edited this page May 7, 2015 · 5 revisions

This add-on was written as a demonstration to leverage the latest Mozilla technologies. OS.File is a fully asynchronous method to handle files from the privileged Javascript scope.

The current methods for compressing and decompressing zip files from add-ons depends on the nsIZipWriter and nsIZipReader interfaces. This has the downside of reliance on the synchronous nsIFile system, which is less preferred then OS.File.

If a developer's goal was to be performant, OS.File would be used. If zip functionality was needed, an unfavorable mix of the mentioned nsI* interfaces and OS.File cannot be avoided. Aside from the downside of mixing synchronous with asynchronous functionality, some redundancies between OS.File and nsIFile will have to be take place.

Due to this reason, an approach using zip.js was taken, allowing for performant, off-mainthread, zip file manipulation.

Pending Work

Total nsIFile Avoidance

The native file dialog functions of the privileged scope rely on nsIFile, so dependence on this interface cannot be completely removed as of yet. However js-ctypes can be implemented to remove nsIFile dependence.

Future Work

OS.Zip

The zip.js interface is based on the HTML5 File API, it may be worthwhile to shift basis to the OS.File interface. Performance difference between the HTML5 File API and OS.File may be the same as they were introduced around the same time frames.

Clone this wiki locally