How to Unpickle Komodo's "xmlc" files

A customer wondered how to get at the state information Komodo saves between sessions. There are three files in saved in the profile directory:




The "xmlc" files are pickled XML files, and are essentially unreadable outside Komodo. They're hard to unpickle outside Komodo, as they contain instances of objects Komodo knows about. But it's easy to write a macro to do the unpickling:

var dirSvc = Components.classes[";1"].getService(Components.interfaces.koIDirs);
var userDataDir = dirSvc.userDataDir;
var osPathSvc = Components.classes[";1"].
var factory = Components.classes[";1"].
var targetDir = "/tmp/";
// Would be better to get the list of *.xmlc files where
// there's no .xml file in place.
var pickledFiles = ['doc-state.xml', 'view-state.xml'];
for (var file, i = 0; file = pickledFiles[i]; i++) {
var fullPath = osPathSvc.join(userDataDir, file);
var targetPath = osPathSvc.join(targetDir, file);

I've deliberately had the macro write the plain-text XML files
into a scratch directory, so I can modify the files.

For extra fun, Komodo is flexible when it loads prefs -- if it
can't find a .xmlc file, it will look for a .xml file with
the same root, and load prefs from that instead.