zigorou #395(2007/07/09 13:06 GMT) [ XUL ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
var FileWatch = function(filename, duration) { this.file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); this.file.initWithPath(filename); this.duration = duration; }; FileWatch.prototype = { iid: null, lastTime: null, watch: function() { this.lastTime = (new Date()).getTime(); var self = this; this.iid = setInterval(function() { self.watchFile(); }, this.duration * 1000); }, watchFile: function() { if (this.file.lastModifiedTime - this.lastTime > 0) { this.log("modified"); } this.lastTime = (new Date()).getTime(); }, log: function(message) { Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(message); }, unwatch: function() { clearInterval(this.iid); } };
Rating0/0=0.00-0+
[ reply ]
zigorou #395() [ XUL ] Rating0/0=0.00
var FileWatch = function(filename, duration) { this.file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); this.file.initWithPath(filename); this.duration = duration; }; FileWatch.prototype = { iid: null, lastTime: null, watch: function() { this.lastTime = (new Date()).getTime(); var self = this; this.iid = setInterval(function() { self.watchFile(); }, this.duration * 1000); }, watchFile: function() { if (this.file.lastModifiedTime - this.lastTime > 0) { this.log("modified"); } this.lastTime = (new Date()).getTime(); }, log: function(message) { Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(message); }, unwatch: function() { clearInterval(this.iid); } };Rating0/0=0.00-0+
[ reply ]