修改了一下DownThemAll! 使之下载完成后自动写入descript.ion

dta/manager.js

--- manager.js.orig	2009-10-27 18:16:52.000000000 +0800
+++ manager.js	2009-11-19 15:47:08.000000000 +0800

@@ -1408,6 +1408,13 @@ QueueItem.prototype = {
 			}
 			else {
 				this.tmpFile.clone().moveTo(destination, this.destinationName);
+			        //{{{ write descript.ion
+			        try {
+				    writeDescription(this.destinationPath, this.destinationName, this.urlManager.usable);
+				} catch (x) {
+				}
+			        
 				this.complete();
 			}
 		}

dta/manager.xul

--- manager.xul.orig	2009-10-27 18:16:52.000000000 +0800
+++ manager.xul	2009-11-17 18:24:28.000000000 +0800
@@ -70,6 +70,7 @@
 	
 		
 			
+			
 			
 			
 			 

 

dta/manager/tree.js

--- manager/tree.js.orig	2009-10-27 18:16:52.000000000 +0800
+++ manager/tree.js	2009-11-19 15:45:24.000000000 +0800
@@ -463,6 +463,17 @@ var Tree = {
 		}
 		this.endUpdate();
 	},
+	writeInfo: function () {
+	    this.beginUpdate();
+
+	    for (let d in Tree.selected) {
+		var dir=d.destinationPath;
+		var filename=d.destinationName;
+		var url = d.urlManager.usable;
+	        writeDescription(dir, filename, url);
+	    }
+	    this.endUpdate();
+	},
 	_hoverItem: null,
 	_ww: Serv('@mozilla.org/embedcomp/window-watcher;1', 'nsIWindowWatcher'),
 	hovering: function(event) {

common/internalFunctions.js

 

var writeDescription = function () {
    var UNICODE =Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].getService(Components.interfaces.nsIScriptableUnicodeConverter); 
    UNICODE.charset = 'UTF-8';

    		//check downloaded file existence
		var downloadedFile = new FileFactory(dir);
		if (!downloadedFile.exists() )
			return;
		downloadedFile.append(filename);
		if (!downloadedFile.exists() )
			return;

		//open descript.ion
		var descFile = new FileFactory(dir);
		descFile.append("descript.ion");
		if (!descFile.exists()) {
			descFile.create(descFile.NORMAL_FILE_TYPE, 0666);
		}

		//write info
		var aContent = "\"" + filename + "\"\t" + url + "\n";
		aContent  = UNICODE.ConvertFromUnicode(aContent);
		var ostream = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);
		//init ( nsIFile file , PRInt32 ioFlags , PRInt32 perm , PRInt32 behaviorFlags )
		const PR_WRONLY = 2;
		const PR_APPEND = 16; 
		ostream.init(descFile, 0x02|0x08|0x10, 0x200, false);

		//const NS_SEEK_END = 2;
		//ostream.seek(NS_SEEK_END, 0);
		ostream.write(aContent, aContent.length);

		aContent = UNICODE.Finish();
		if (aContent.length > 0) ostream.write(aContent, aContent.length);
		ostream.close();
	} //end of writeDescription_impl

     return writeDescription_impl;
}();

你可能感兴趣的:(Firefox)