From 9737a42fa1b90ec00b4f311825e6767628c209a6 Mon Sep 17 00:00:00 2001 From: mitsugu oyama Date: Wed, 29 Jun 2011 12:25:52 +0900 Subject: overwrite the image file? pixiv version --- pixiv.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pixiv.js') diff --git a/pixiv.js b/pixiv.js index c216383..5185535 100644 --- a/pixiv.js +++ b/pixiv.js @@ -1,6 +1,6 @@ // INFO // var INFO = - @@ -77,8 +77,8 @@ commands.addUserCommand( } return path; }; - let savePath=directoryPicker(); - if(savePath.length<1) return; + let saveDirectory=directoryPicker(); + if(saveDirectory.length<1) return; let getDOMHtmlDocument=function(str){ let doc; @@ -131,11 +131,20 @@ commands.addUserCommand( if (-1!=fileName.indexOf('?')){ fileName=fileName.substr(0,fileName.indexOf('?')); } - let tmpPath=savePath+fileName; + let tmpPath=saveDirectory+fileName; let instream=xhrImg.responseText; let aFile=Cc["@mozilla.org/file/local;1"] .createInstance(Ci.nsILocalFile); aFile.initWithPath(tmpPath); + if(true===aFile.exists()){ + let value=window.prompt('すでに同じ名前のファイルがあります。デフォルトファイル名を変更してください。',fileName.substr(1)); + if(null===value){ + return false; + } + fileName='/'+value; + tmpPath=saveDirectory+fileName; + aFile.initWithPath(tmpPath); + } let outstream=Cc["@mozilla.org/network/safe-file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); outstream.init(aFile,0x02|0x08|0x20,0664,0); -- cgit v1.2.3