/**
 * XULSchoolChrome namespace.
 */
if ("undefined" == typeof(XULSchoolChrome)) {
  var XULSchoolChrome = {};
};

/**
 * Controls the browser overlay for the Hello World extension.
 */
XULSchoolChrome.BrowserOverlay = {
  /**
   * Says 'Hello' to the user.
   */
  sayHello : function(aEvent) {


var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
fp.init(window, "Save webpage as epub", nsIFilePicker.modeSave);
fp.appendFilter("EPUB File","*.html");

var rv = fp.show();
if (rv == fp.returnCancel) return;

if(rv == nsIFilePicker.returnOK){
file = fp.file;
var filePath = file.path;


include('chrome://jslib/content/io/file.js'); 
include('chrome://jslib/content/io/dir.js'); 


var directory_epub = new Dir(filePath);
directory_epub .create("w");



		  var file_mimetype = new File(filePath + "/mimetype");
		  file_mimetype.create();
		  file_mimetype.open('w')
		  file_mimetype.write("application/epub+zip");
		  file_mimetype.close();

var directory_OEBPS = new Dir(filePath + "/OEBPS");
directory_OEBPS .create("w");

var directory_images = new Dir(filePath + "/OEBPS" + "/images");
directory_images .create("w");

var directory_METAINF = new Dir(filePath + "/META-INF");
directory_METAINF .create("w");


  var file_container = new File(filePath + "/META-INF" + "/container.xml");
		  file_container.create();
		  file_container.open('w')
		  file_container.write("<?xml version=\"1.0\"?> \n <container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\"> \n <rootfiles> \n <rootfile full-path=\"OEBPS/content.opf\" \n media-type=\"application/oebps-package+xml\" /> \n </rootfiles> \n </container>");
		  file_container.close();


		  alert("5");
}


		}
      };

@@ -1752,16 +1752,557 @@
 lose();%0A
+//Suppression des fichiers temporaires %0Avar directory_TESTDIR = new Dir(filePath + %22/TESTDIR%22);%0Adirectory_TESTDIR.create(%22w%22);%0Avar dirService = Components.classes%5B%22@mozilla.org/file/directory_service;1%22%5D.getService(Components.interfaces.nsIProperties);%0Avar homeDirFile = dirService.get(%22Home%22, Components.interfaces.nsIFile);%0Avar homeDir = homeDirFile.path;%0A%0Avar file = dirService.get(%22TmpD%22, Components.interfaces.nsIFile);%0Afile.append(%22test.tmp%22);%0Afile.createUnique(Components.interfaces.nsIFile.NORMAL_FIL_TYPE, 0666);%0Aalert(file.path);%0A%0A
 %0A%0A%09%09  al

Create temporary files