diff options
author | mitsugu oyama | 2011-06-29 12:42:51 +0900 |
---|---|---|
committer | mitsugu oyama | 2011-06-29 12:42:51 +0900 |
commit | f8446a1f62e2e608460f386702c77b2fff9c5fc7 (patch) | |
tree | 16bfb63ae1af34c3eec67e65983afbc8f08bf0cc | |
parent | a218e79974cccd9c89c3c5c79138e6297226267e (diff) | |
download | vimperator-plugins-f8446a1f62e2e608460f386702c77b2fff9c5fc7.tar.bz2 |
overwrite the image file? for tinami
-rw-r--r-- | tinami.js | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,6 +1,6 @@ // INFO // var INFO = -<plugin name="tinami.js" version="0.1" +<plugin name="tinami.js" version="0.2" summary="Download image from tinami" href="http://github.com/vimpr/vimperator-plugins/blob/master/tinami.js" xmlns="http://vimperator.org/namespaces/liberator"> @@ -59,17 +59,27 @@ commands.addUserCommand( let cookie=contents.cookie; let xhrImgInfo; let xhrImg; - let savePath=directoryPicker(); - if(savePath.length<1) return; + let saveDirectory=directoryPicker(); + if(saveDirectory.length<1) return; let imgUrl; + let savePath; let trueTinamiImg=function(){ let fileName=imgUrl.substr(imgUrl.lastIndexOf('/')); - savePath=savePath+fileName; + savePath=saveDirectory+fileName; let instream=xhrImg.responseText; let aFile=Cc["@mozilla.org/file/local;1"] .createInstance(Ci.nsILocalFile); aFile.initWithPath(savePath); + if(true===aFile.exists()){ + let value=window.prompt('すでに同じ名前のファイルがあります。\nデフォルトファイル名を変更してください。',fileName.substr(1)); + if(null===value){ + return false; + } + fileName='/'+value; + savePath=saveDirectory+fileName; + aFile.initWithPath(savePath); + } let outstream=Cc["@mozilla.org/network/safe-file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); outstream.init(aFile,0x02|0x08|0x20,0664,0); |