diff -u5r chrome_/content/moz2ch/bbs/2ch/itaTree.js chrome/content/moz2ch/bbs/2ch/itaTree.js --- chrome_/content/moz2ch/bbs/2ch/itaTree.js 2007-01-21 15:50:24.000000000 +0900 +++ chrome/content/moz2ch/bbs/2ch/itaTree.js 2007-12-04 23:54:15.062134500 +0900 @@ -68,14 +68,14 @@ this.bbsId = "2ch"; this.rdfRootURI = "http://www.2ch.net/"; // BBSディレクトリゲトー - var dir = new Dir(this.getBBSDir()); + var dir = IO.getFileWithPath(this.getBBSDir()); dir.append(kMoz2chRDFName); - file = kIOService.newFileURI(dir.nsIFile).spec; + file = IO.newURI(dir).spec; // データソースをセテーイ var ds = kRDFService.GetDataSourceBlocking(file); this.datasource = ds; @@ -157,15 +157,15 @@ this.readOtherBrd(); this.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); var text = this.changeDat.join("\r\n"); - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSabaFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(text)); - f.close(); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(text); + stream.close(); this.checkItaMoveAndCreate(); // parse succeeded return true; @@ -176,26 +176,26 @@ * 外部板は/Moz2ch/bbs/2ch/other.brdに2channel.brd形式で格納する。 */ //moz2ch2chItaTree.prototype.itaTreeOtherBrd = "other.brd"; moz2ch2chItaTree.prototype.readOtherBrd = function () { - var f = new Dir(this.getBBSDir()); + var f = IO.getFileWithPath(this.getBBSDir()); f.append(this.itaTreeOtherBrd); var path = f.path; - var f = new File(path); + var f = IO.getFileWithPath(path); var brd; if (!f.exists()) { brd = moz2ch.getString("defaultOtherBrd"); - f.open("w", 0700); - f.write(moz2chCharset.uni2sjis(brd)); - f.close(); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(brd); + stream.close(); } else { - f.open("r"); - brd = moz2chCharset.sjis2uni(f.read()); - f.close(); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + brd = stream.readString(stream.available()); + stream.close(); } brd = brd.split("\r\n"); if (brd.length < 2) @@ -219,17 +219,17 @@ }; moz2ch2chItaTree.prototype.getsabaDat = function () { try{ - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSabaFileName); if(f.exists()){ - f.open("r"); - var dat = f.read(); - f.close(); - this.changeDat = moz2chCharset.sjis2uni(dat).split("\r\n"); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + var dat = stream.readString(stream.available()); + stream.close(); + this.changeDat = dat.split("\r\n"); } }catch(e){ moz2ch.debug(e); } }; moz2ch2chItaTree.prototype.urltoTitle = @@ -256,11 +256,11 @@ var ita = new Array(); var datDir = null; var oldDatDir = null; var oldDatSaba = null; var fileName = null; - var fileList = new Array(); + var fileList = null; var newFileName = null; var newFile = null; var oldFile = null; for(i=0; i 0){ - datDir = new Dir(this.getBBSDir()); + fileList = oldDatDir.directoryEntries.QueryInterface(Components.interfaces.nsIDirectoryEnumerator); + if(fileList.hasMoreElements()){ + datDir = IO.getFileWithPath(this.getBBSDir()); datDir.append(saba[i]); if(!datDir.exists()) - datDir.create(kMoz2chDataDirPerm); + datDir.create(datDir.DIRECTORY_TYPE, kMoz2chDataDirPerm); datDir.append(ita[i]); if(!datDir.exists()) - datDir.create(kMoz2chDataDirPerm); - for(j=0; j 0) { - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSureFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(html)); - f.close(); - - //2byte文字のJSLibのバグ回避 - var localFile = Components.classes['@mozilla.org/file/local;1'] - .createInstance(Components.interfaces.nsILocalFile); - - localFile.initWithPath(f.path); - var ioService = Components.classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService); - url = ioService.newFileURI(localFile).spec; - localFile = null; - ioService = null; + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); + + url = IO.newURI(f).spec; } else { url = "about:blank"; } //xhtml化用テストコード diff -u5r chrome_/content/moz2ch/bbs/jbbs/itaTree.js chrome/content/moz2ch/bbs/jbbs/itaTree.js --- chrome_/content/moz2ch/bbs/jbbs/itaTree.js 2007-11-08 01:32:42.000000000 +0900 +++ chrome/content/moz2ch/bbs/jbbs/itaTree.js 2007-12-02 00:43:14.000000000 +0900 @@ -58,14 +58,14 @@ this.bbsId = "jbbs"; this.rdfRootURI = "http://jbbs.livedoor.jp/"; // BBSディレクトリゲトー - var dir = new Dir(this.getBBSDir()); + var dir = IO.getFileWithPath(this.getBBSDir()); dir.append(kMoz2chRDFName); - file = kIOService.newFileURI(dir.nsIFile).spec; + file = IO.newURI(dir).spec; // データソースをセテーイ var ds = kRDFService.GetDataSourceBlocking(file); this.datasource = ds; @@ -95,16 +95,16 @@ var rv = this.parse(); this.loaded(); if (rv && this.data.length > 0) { // if parse succeeded, save the data. - var f = new File(this.getLogPath()); - f.open("w", kMoz2chDataFilePerm); - f.write(this.data); - f.close(); + var f = IO.getFileWithPath(this.getLogPath()); + var stream = IO.newOutputStream(f, "binary"); + stream.writeString(this.data); + stream.close(); } - moz2ch.busy(false); + moz2ch.setBusy(false); }; moz2chJbbsItaTree.prototype.parse = function () { // external ita tree file @@ -122,26 +122,26 @@ */ moz2chJbbsItaTree.prototype.itaTreeOtherBrd = "jbbs.brd"; moz2chJbbsItaTree.prototype.readOtherBrd = function () { try{ - var f = new Dir(this.getBBSDir()); + var f = IO.getFileWithPath(this.getBBSDir()); f.append(this.itaTreeOtherBrd); var path = f.path; - var f = new File(path); + var f = IO.getFileWithPath(path); var brd; if (!f.exists()) { brd = "1\r\nJBBS Livedoor\t0\r\n\t"; - f.open("w", 0700); - f.write(moz2chCharset.uni2sjis(brd)); - f.close(); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(brd); + stream.close(); } else { - f.open("r"); - brd = moz2chCharset.sjis2uni(f.read()); - f.close(); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + brd = stream.readString(stream.available()); + stream.close(); } brd = brd.split("\r\n"); if (brd.length < 2) diff -u5r chrome_/content/moz2ch/bbs/jbbs/sure.js chrome/content/moz2ch/bbs/jbbs/sure.js --- chrome_/content/moz2ch/bbs/jbbs/sure.js 2007-11-25 20:18:10.000000000 +0900 +++ chrome/content/moz2ch/bbs/jbbs/sure.js 2007-12-02 02:35:46.000000000 +0900 @@ -93,17 +93,17 @@ }; moz2chJbbsSure.prototype.loadLocalDat = function ( fileURL ) { try{ - var f = new File(fileURL); + var f = IO.getFileWithPath(fileURL); if (!f.exists()) return false; this.loading(); - f.open("r"); - this.data = f.read(); - f.close(); + var stream = IO.newInputStream(f, "binary"); + this.data = stream.readString(stream.available()); + stream.close(); var temp = this.data.split("\n"); if(temp.pop() != ""){ this.data = this.data + "\n"; } this.parse(); @@ -124,15 +124,15 @@ }; moz2chJbbsSure.prototype.get = function () { if(this == moz2ch.sureView.data){ - var log = new File(this.getMoz2chDir()); + var log = IO.getFileWithPath(this.getMoz2chDir()); log.append("log.txt"); - log.open("a", kMoz2chDataFilePerm); - log.write("get data\n"); - log.close(); + var stream = IO.newOutputStream(log, "text notruncate append"); + stream.writeString("get data\n"); + stream.close(); } // initialize data this.oldData = this.data; this.data = ""; @@ -157,20 +157,20 @@ //xhtml化用テストコード /*moz2chJbbsSure.prototype.getXHTMLPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); var sabaIDs = this.sabaID.split("/"); for (var i = 0; i < sabaIDs.length; i++) { logFile.append(sabaIDs[i]); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); } logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.datID + ".xhtml"); this.logPath = logFile.path; } return this.logPath; }; @@ -283,17 +283,17 @@ moz2ch.debug(this.sureClassName + ".parse: Parse Error, Do not save the data!"); return false; } var fontFamily = moz2chCharset.euc2uni('"MS Pゴシック","MS PGothic",Osaka,"IPAMonaPGothic","Mona","mona-gothic-jisx0208.1990-0",monospace'); - this.htmlHeader = moz2chCharset.euc2uni(moz2chskin.getHeader(moz2ch.skinName)); - this.htmlRes = moz2chCharset.euc2uni(moz2chskin.getRes(moz2ch.skinName)); - this.htmlNewres = moz2chCharset.euc2uni(moz2chskin.getNewres(moz2ch.skinName)); - this.htmlFooter = moz2chCharset.euc2uni(moz2chskin.getFooter(moz2ch.skinName)); - var moz2chDir = new Dir(moz2chskin.getskinPath()); + this.htmlHeader = moz2chskin.getHeader(moz2ch.skinName); + this.htmlRes = moz2chskin.getRes(moz2ch.skinName); + this.htmlNewres = moz2chskin.getNewres(moz2ch.skinName); + this.htmlFooter = moz2chskin.getFooter(moz2ch.skinName); + var moz2chDir = IO.getFileWithPath(moz2chskin.getskinPath()); moz2chDir.append(moz2ch.skinName); - var skinPath = moz2chDir.path?'file:///'+moz2chDir.path.replace(/\ /g, "%20").replace(/\\/g, "\/"):''; + var skinPath = moz2chDir.path?IO.newURI(moz2chDir).spec:''; if(this.old_URL != this.getDataURL() || !this.old_html || !this.sabun){ this.old_URL = this.getDataURL(); html = new Array(this.lines.length - 1); @@ -387,26 +387,17 @@ .replace(reg_allres, this.lines.length - 1) .replace(reg_sureurl, this.url.replace(/\/l50/g, ".dat")); var url; if (html.length > 0) { - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSureFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(html)); - f.close(); - - //2byte文字のJSLibのバグ回避 - var localFile = Components.classes['@mozilla.org/file/local;1'] - .createInstance(Components.interfaces.nsILocalFile); - - localFile.initWithPath(f.path); - var ioService = Components.classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService); - url = ioService.newFileURI(localFile).spec; - localFile = null; - ioService = null; + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); + + url = IO.newURI(f).spec; } else { url = "about:blank"; } //xhtml化用テストコード @@ -480,15 +471,15 @@ moz2chJbbsSure.prototype.onRequest = function () { // SABUN get code // set "Range" and "If-Modified-Since" request header for SABUN get - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (f.exists()) { - f.open("r"); - this.log = f.read(); - f.close(); + var stream = IO.newInputStream(f, "binary"); + this.log = stream.readString(stream.available()); + stream.close(); var temp = this.log.split("\n"); if(temp.pop() != ""){ this.log = this.log + "\n"; } } diff -u5r chrome_/content/moz2ch/bbs/machi/ita.js chrome/content/moz2ch/bbs/machi/ita.js --- chrome_/content/moz2ch/bbs/machi/ita.js 2005-05-18 14:25:46.000000000 +0900 +++ chrome/content/moz2ch/bbs/machi/ita.js 2007-12-02 00:43:14.000000000 +0900 @@ -84,20 +84,20 @@ moz2chMachiIta.prototype.logPath = null; moz2chMachiIta.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); var sabaIDs = this.sabaID.split("/"); for (var i = 0; i < sabaIDs.length; i++) { logFile.append(sabaIDs[i]); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); } logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.itaLeaf); this.logPath = logFile.path; } return this.logPath; }; @@ -275,18 +275,17 @@ /////////////////// // read/write index moz2chMachiIta.prototype.readIndex = function () { - var f = new File(this.getIndexPath()); + var f = IO.getFileWithPath(this.getIndexPath()); if (!f.exists()) return false; - f.open("r"); - var index = f.read(); - f.close(); - index = moz2chCharset.sjis2uni(index); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + var index = stream.readString(stream.available()); + stream.close(); index = index.split("\r\n"); this.clear(); for (var i = 0; i < index.length; i++) { var line = index[i].split(","); if (line.length < 5) @@ -328,15 +327,14 @@ + "," + this.sureRowSet[i].dat + "," + lm + "," + this.sureRowSet[i].sureAttr + "," + this.sureRowSet[i].surePos + "," + this.sureRowSet[i].sureAcq; } var index = table.join("\r\n") + "\r\n"; if (index.length > 0) { - index = moz2chCharset.uni2sjis(index); - var f = new File(this.getIndexPath()); - f.open("w", 0644); - f.write(index); - f.close(); + var f = IO.getFileWithPath(this.getIndexPath()); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(index); + stream.close(); } }; moz2chMachiIta.prototype.addSure = function (num, name, res, dat, lastModified) { diff -u5r chrome_/content/moz2ch/bbs/machi/itaTree.js chrome/content/moz2ch/bbs/machi/itaTree.js --- chrome_/content/moz2ch/bbs/machi/itaTree.js 2004-07-26 18:51:00.000000000 +0900 +++ chrome/content/moz2ch/bbs/machi/itaTree.js 2007-12-02 00:43:14.000000000 +0900 @@ -58,14 +58,14 @@ this.bbsId = "machi"; this.rdfRootURI = "http://www.machi.to/"; // BBSディレクトリゲトー - var dir = new Dir(this.getBBSDir()); + var dir = IO.getFileWithPath(this.getBBSDir()); dir.append(kMoz2chRDFName); - file = kIOService.newFileURI(dir.nsIFile).spec; + file = IO.newURI(dir).spec; // データソースをセテーイ var ds = kRDFService.GetDataSourceBlocking(file); this.datasource = ds; @@ -176,17 +176,17 @@ }; moz2chMachiItaTree.prototype.getsabaDat = function () { try{ - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSabaFileName); if(f.exists()){ - f.open("r"); - var dat = f.read(); - f.close(); - this.changeDat = moz2chCharset.sjis2uni(dat).split("\n"); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + var dat = stream.readString(stream.available()); + stream.close(); + this.changeDat = dat.split("\n"); } }catch(e){ moz2ch.debug(e); } }; moz2chMachiItaTree.prototype.urltoTitle = diff -u5r chrome_/content/moz2ch/bbs/machi/sure.js chrome/content/moz2ch/bbs/machi/sure.js --- chrome_/content/moz2ch/bbs/machi/sure.js 2007-11-18 23:05:52.000000000 +0900 +++ chrome/content/moz2ch/bbs/machi/sure.js 2007-12-02 00:43:14.000000000 +0900 @@ -111,18 +111,18 @@ return false; } var fontFamily = moz2chCharset.euc2uni('"MS Pゴシック","MS PGothic",Osaka,"IPAMonaPGothic","Mona","mona-gothic-jisx0208.1990-0",monospace'); - this.htmlHeader = moz2chCharset.euc2uni(moz2chskin.getHeader(moz2ch.skinName)); - this.htmlRes = moz2chCharset.euc2uni(moz2chskin.getRes(moz2ch.skinName)); - this.htmlNewres = moz2chCharset.euc2uni(moz2chskin.getNewres(moz2ch.skinName)); - this.htmlFooter = moz2chCharset.euc2uni(moz2chskin.getFooter(moz2ch.skinName)); + this.htmlHeader = moz2chskin.getHeader(moz2ch.skinName); + this.htmlRes = moz2chskin.getRes(moz2ch.skinName); + this.htmlNewres = moz2chskin.getNewres(moz2ch.skinName); + this.htmlFooter = moz2chskin.getFooter(moz2ch.skinName); - var moz2chDir = new Dir(moz2chskin.getskinPath()); + var moz2chDir = IO.getFileWithPath(moz2chskin.getskinPath()); moz2chDir.append(this.skinName); - var skinPath = moz2chDir.path?'file:///'+moz2chDir.path.replace(/\ /g, "%20").replace(/\\/g, "\/"):''; + var skinPath = moz2chDir.path?IO.newURI(moz2chDir).spec:''; if(this.old_URL != this.getDataURL() || !this.old_html || !this.sabun){ this.old_html = null; this.old_URL = this.getDataURL(); @@ -197,22 +197,17 @@ html = html.replace(reg_getres, "").replace(reg_allres, "") .replace(reg_newres, "").replace(reg_sureurl, ""); var url; if (html.length > 0) { - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSureFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(html)); - f.close(); - - url = f.URL; - // JSLib File.URL has a bug on Mac - // Hacking it... - if (navigator.platform.indexOf("Mac") > -1) - url = f.path ? "file:///" + f.path.replace(/\ /g, "%20") - .replace(/:/g, "\/") : ""; + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); + + url = IO.newURI(f).spec; } else { url = "about:blank"; } //取得済みの値をセテーイ diff -u5r chrome_/content/moz2ch/bbs/yahoo/ita.js chrome/content/moz2ch/bbs/yahoo/ita.js --- chrome_/content/moz2ch/bbs/yahoo/ita.js 2005-05-18 14:25:46.000000000 +0900 +++ chrome/content/moz2ch/bbs/yahoo/ita.js 2007-12-03 23:49:48.000000000 +0900 @@ -83,15 +83,15 @@ //moz2chYahooIta.prototype.logPath = null; moz2chYahooIta.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.itaLeaf); this.logPath = logFile.path; } return this.logPath; }; @@ -263,18 +263,17 @@ */ /////////////////// // read/write index moz2chYahooIta.prototype.readIndex = function () { - var f = new File(this.getIndexPath()); + var f = IO.getFileWithPath(this.getIndexPath()); if (!f.exists()) return false; - f.open("r"); - var index = f.read(); - f.close(); - index = moz2chCharset.sjis2uni(index); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + var index = stream.readString(stream.available()); + stream.close(); index = index.split("\r\n"); this.clear(); for (var i = 0; i < index.length; i++) { var line = index[i].split(","); if (line.length < 5) @@ -320,15 +319,14 @@ + "," + this.sureRowSet[i].sureAcq + "," + this.sureRowSet[i].board + "," + this.sureRowSet[i].tid + "," + this.sureRowSet[i].sid + "," + lm + "," + this.sureRowSet[i].sureAttr + "," + this.sureRowSet[i].surePos; } var index = table.join("\r\n") + "\r\n"; if (index.length > 0) { - index = moz2chCharset.uni2sjis(index); - var f = new File(this.getIndexPath()); - f.open("w", 0644); - f.write(index); - f.close(); + var f = IO.getFileWithPath(this.getIndexPath()); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(index); + stream.close(); } }; moz2chYahooIta.prototype.clear = function () { diff -u5r chrome_/content/moz2ch/bbs/yahoo/itaTree.js chrome/content/moz2ch/bbs/yahoo/itaTree.js --- chrome_/content/moz2ch/bbs/yahoo/itaTree.js 2004-06-16 20:01:26.000000000 +0900 +++ chrome/content/moz2ch/bbs/yahoo/itaTree.js 2007-12-03 23:22:22.000000000 +0900 @@ -60,23 +60,15 @@ }; this.bbsId = "yahoo"; this.rdfRootURI= "http://www.yahoo.co.jp/"; - // Moz2chディレクトリゲトー - var moz2chDir = kDirectoryService - .get("ProfD", Components.interfaces.nsIFile); - moz2chDir.append(kMoz2chDirName); - - if (!moz2chDir.exists()) - moz2chDir.create(moz2chDir.DIRECTORY_TYPE, 0700); - - var file = moz2chDir.clone(); - file.append("bbs"); - file.append(this.bbsId); - file.append(kMoz2chRDFName); - file = kIOService.newFileURI(file).spec; + // BBSディレクトリゲトー + var dir = IO.getFileWithPath(this.getBBSDir()); + + dir.append(kMoz2chRDFName); + file = IO.newURI(dir).spec; // データソースをセテーイ var ds = kRDFService.GetDataSourceBlocking(file); this.datasource = ds; @@ -279,11 +271,11 @@ moz2chYahooItaTree.prototype.logPath = null; moz2chYahooItaTree.prototype.getLogPath = function () { if (!this.logPath) { - var f = new Dir(this.getBBSDir()); + var f = IO.getFileWithPath(this.getBBSDir()); f.append(this.bbsId); f.append(kMoz2chItaTreeLeaf); this.logPath = f.path; } return this.logPath; diff -u5r chrome_/content/moz2ch/bbs/yahoo/sure.js chrome/content/moz2ch/bbs/yahoo/sure.js --- chrome_/content/moz2ch/bbs/yahoo/sure.js 2007-06-27 20:31:54.000000000 +0900 +++ chrome/content/moz2ch/bbs/yahoo/sure.js 2007-12-03 23:43:44.000000000 +0900 @@ -80,15 +80,15 @@ // title/log/download information moz2chYahooSure.prototype.logPath = null; moz2chYahooSure.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.tid + ".dat"); this.logPath = logFile.path; } return this.logPath; }; @@ -101,15 +101,15 @@ moz2chYahooSure.prototype.get = function () { var data = ""; var start = 1; - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (f.exists()) { - f.open("r"); - data = f.read(); - f.close(); + var stream = IO.newInputStream(f, "binary"); + data = stream.readString(stream.available()); + stream.close(); start = data.split("\n").length + 1; } this.subloader.sure = this; this.subloader.currentRes = start; @@ -270,14 +270,14 @@ parseLog: function () { //moz2ch.debug(this.sure.data); if ( ! this.sure.data ) this.sure.data = ""; this.sure.data += this.log - var f = new File(this.sure.getLogPath()); - f.open("w", kMoz2chDataFilePerm); - f.write(this.sure.data); - f.close(); + var f = IO.getFileWithPath(this.sure.getLogPath()); + var stream = IO.newOutputStream(f, "binary"); + stream.writeString(this.sure.data); + stream.close(); this.sure.parse(); }, getTargetURL: function ( idx ) { @@ -308,18 +308,18 @@ return false; } var fontFamily = moz2chCharset.euc2uni('"MS Pゴシック","MS PGothic",Osaka,"IPAMonaPGothic","Mona","mona-gothic-jisx0208.1990-0",monospace'); - this.htmlHeader = moz2chCharset.euc2uni(moz2chskin.getHeader(moz2ch.skinName)); - this.htmlRes = moz2chCharset.euc2uni(moz2chskin.getRes(moz2ch.skinName)); - this.htmlNewres = moz2chCharset.euc2uni(moz2chskin.getNewres(moz2ch.skinName)); - this.htmlFooter = moz2chCharset.euc2uni(moz2chskin.getFooter(moz2ch.skinName)); + this.htmlHeader = moz2chskin.getHeader(moz2ch.skinName); + this.htmlRes = moz2chskin.getRes(moz2ch.skinName); + this.htmlNewres = moz2chskin.getNewres(moz2ch.skinName); + this.htmlFooter = moz2chskin.getFooter(moz2ch.skinName); - var moz2chDir = new Dir(moz2chskin.getskinPath()); + var moz2chDir = IO.getFileWithPath(moz2chskin.getskinPath()); moz2chDir.append(this.skinName); - var skinPath = moz2chDir.path?'file:///'+moz2chDir.path.replace(/\ /g, "%20").replace(/\\/g, "\/"):''; + var skinPath = moz2chDir.path?IO.newURI(moz2chDir).spec:''; var html = new Array(this.lines.length + 1); html[0] = this.htmlHeader.replace(//g, fontFamily); var ary = this.lines[0].split(delimiter); if (ary.length < 2) @@ -346,22 +346,17 @@ html = html.replace(reg_getres, "").replace(reg_allres, "") .replace(reg_newres, "").replace(reg_sureurl, ""); var url; if (html.length > 0) { - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSureFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(html)); - f.close(); - - url = f.URL; - // JSLib File.URL has a bug on Mac - // Hacking it... - if (navigator.platform.indexOf("Mac") > -1) - url = f.path ? "file:///" + f.path.replace(/\ /g, "%20") - .replace(/:/g, "\/") : ""; + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); + + url = IO.newURI(f).spec; } else { url = "about:blank"; } diff -u5r chrome_/content/moz2ch/data.js chrome/content/moz2ch/data.js --- chrome_/content/moz2ch/data.js 2007-11-27 02:29:58.000000000 +0900 +++ chrome/content/moz2ch/data.js 2007-12-03 23:08:16.000000000 +0900 @@ -57,15 +57,10 @@ * void unload(); データの書き出し * void getBBSDir(); bbs用ルートディレクトリの取得 * */ -// JSLib -include("chrome://jslib/content/io/file.js"); -include("chrome://jslib/content/io/dir.js"); -include("chrome://jslib/content/io/dirUtils.js"); - const kMoz2chDataDirName = "Moz2ch"; const kMoz2chDataDirPerm = 0755; const kMoz2chDataFilePerm = 0644; function moz2chData(title, url) { @@ -120,15 +115,15 @@ // download functionality // start download get: function () { if(this == moz2ch.sureView.data){ - var log = new File(this.getMoz2chDir()); + var log = IO.getFileWithPath(this.getMoz2chDir()); log.append("log.txt"); - log.open("a", kMoz2chDataFilePerm); - log.write("get data\n"); - log.close(); + var stream = IO.newOutputStream(log, "text notruncate append"); + stream.writeString("get data\n"); + stream.close(); } // initialize data this.oldData = this.data; this.data = ""; @@ -171,25 +166,25 @@ }, // data handler onGet: function () { if(this == moz2ch.sureView.data){ - var log = new File(this.getMoz2chDir()); + var log = IO.getFileWithPath(this.getMoz2chDir()); log.append("log.txt"); - log.open("a", kMoz2chDataFilePerm); - log.write("start parse\n"); - log.close(); + var stream = IO.newOutputStream(log, "text notruncate append"); + stream.writeString("start parse\n"); + stream.close(); } var rv = this.parse(); this.loaded(); if (rv && this.data.length > 0) { // if parse succeeded, save the data. - var f = new File(this.getLogPath()); - f.open("w", kMoz2chDataFilePerm); - f.write(this.data); - f.close(); + var f = IO.getFileWithPath(this.getLogPath()); + var stream = IO.newOutputStream(f, "binary"); + stream.writeString(this.data); + stream.close(); } }, // error handler onError: function () { @@ -206,42 +201,42 @@ }, //////////////////// // log functionality deleteLog: function () { - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (!f.exists()) return false; try { moz2ch.debug("moz2chData.deleteLog: " + this.getLogPath()); - f.remove(); + f.remove(false); } catch (e) { moz2ch.debug("moz2chData.deleteLog: can't remove the file: " + this.getLogPath()); } }, readLog: function () { if(this == moz2ch.sureView.data){ - var log = new File(this.getMoz2chDir()); + var log = IO.getFileWithPath(this.getMoz2chDir()); log.append("log.txt"); - log.open("w", kMoz2chDataFilePerm); - log.write("readLog\n"); - log.close(); + var stream = IO.newOutputStream(log, "text"); + stream.writeString("readLog\n"); + stream.close(); } - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (!f.exists()) return false; this.loading(); - f.open("r"); - this.data = f.read(); + var stream = IO.newInputStream(f, "binary"); + this.data = stream.readString(stream.available()); if(this == moz2ch.sureView.data){ var temp = this.data.split("\n"); if(temp.pop() != ""){ this.data = this.data + "\n"; } } - f.close(); + stream.close(); this.parse(); this.loaded(); if(this == moz2ch.sureView.data){ if(this.ita.getAttribute(this.datID + ".dat", "sureNew")){ this.ita.setAttribute(this.datID + ".dat", "sureNew", null); @@ -249,37 +244,36 @@ } return true; }, logTest: function() { - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (!f.exists()) return false; return true; }, // utility method moz2chDir: null, getMoz2chDir: function () { if (!this.moz2chDir) { - var dirUtils = new DirUtils(); - var dir = new Dir(dirUtils.getMozUserHomeDir()); + var dir = IO.getFile("Profile", ""); dir.append(kMoz2chDataDirName); if (!dir.exists()) - dir.create(kMoz2chDataDirPerm); + dir.create(dir.DIRECTORY_TYPE, kMoz2chDataDirPerm); this.moz2chDir = dir.path; } return this.moz2chDir; }, getBBSDir: function () { if (!this.bbsDir) { - var dir = new Dir(this.getMoz2chDir()); + var dir = IO.getFileWithPath(this.getMoz2chDir()); dir.append("bbs"); dir.append(this.bbsId); if (!dir.exists()) - dir.create(kMoz2chDataDirPerm); + dir.create(dir.DIRECTORY_TYPE, kMoz2chDataDirPerm); this.bbsDir = dir.path; } return this.bbsDir; }, diff -u5r chrome_/content/moz2ch/ita.js chrome/content/moz2ch/ita.js --- chrome_/content/moz2ch/ita.js 2007-11-25 01:35:42.000000000 +0900 +++ chrome/content/moz2ch/ita.js 2007-12-02 02:37:08.000000000 +0900 @@ -87,20 +87,20 @@ moz2chIta.prototype.logPath = null; moz2chIta.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); var sabaIDs = this.sabaID.split("/"); for (var i = 0; i < sabaIDs.length; i++) { logFile.append(sabaIDs[i]); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); } logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.itaLeaf); this.logPath = logFile.path; } return this.logPath; }; @@ -308,18 +308,17 @@ /////////////////// // read/write index moz2chIta.prototype.readIndex = function () { try{ - var f = new File(this.getIndexPath()); + var f = IO.getFileWithPath(this.getIndexPath()); if (!f.exists()) return false; - f.open("r"); - var index = f.read(); - f.close(); - index = moz2chCharset.sjis2uni(index); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + var index = stream.readString(stream.available()); + stream.close(); index = index.split("\r\n"); this.clear(); for (var i = 0; i < index.length; i++) { var line = index[i].split(","); if (line.length < 5) @@ -368,15 +367,14 @@ + "," + tempRowSet[i].surePos + "," + tempRowSet[i].sureAcq; } var index = table.join("\r\n"); if (index.length > 0) { - index = moz2chCharset.uni2sjis(index); - var f = new File(this.getIndexPath()); - f.open("w", 0644); - f.write(index); - f.close(); + var f = IO.getFileWithPath(this.getIndexPath()); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(index); + stream.close(); } tempRowSet = null; }catch(e){ moz2ch.debug(e); } }; diff -u5r chrome_/content/moz2ch/itaTree.js chrome/content/moz2ch/itaTree.js --- chrome_/content/moz2ch/itaTree.js 2005-06-09 21:21:14.000000000 +0900 +++ chrome/content/moz2ch/itaTree.js 2007-12-02 00:43:12.000000000 +0900 @@ -103,11 +103,11 @@ moz2chItaTree.prototype.logPath = null; moz2chItaTree.prototype.getLogPath = function () { if (!this.logPath) { - var f = new Dir(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chItaTreeLeaf); this.logPath = f.path; } return this.logPath; }; @@ -237,25 +237,25 @@ * 外部板は/Moz2ch/other.brdに2channel.brd形式で格納する。 */ moz2chItaTree.prototype.itaTreeOtherBrd = "other.brd"; moz2chItaTree.prototype.readOtherBrd = function () { - var f = new File(this.getIndexPath()); - f.leaf = this.itaTreeOtherBrd; + var f = IO.getFileWithPath(this.getIndexPath()); + f.leafName = this.itaTreeOtherBrd; var path = f.path; - var f = new File(path); + var f = IO.getFileWithPath(path); var brd; if (!f.exists()) { brd = moz2ch.getString("defaultOtherBrd"); - f.open("w", 0700); - f.write(moz2chCharset.uni2sjis(brd)); - f.close(); + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(brd); + stream.close(); } else { - f.open("r"); - brd = moz2chCharset.sjis2uni(f.read()); - f.close(); + var stream = IO.newInputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + brd = stream.readString(stream.available()); + stream.close(); } brd = brd.split("\r\n"); if (brd.length < 2) return; diff -u5r chrome_/content/moz2ch/localrule.js chrome/content/moz2ch/localrule.js --- chrome_/content/moz2ch/localrule.js 2005-07-06 23:16:52.000000000 +0900 +++ chrome/content/moz2ch/localrule.js 2007-11-29 23:19:42.000000000 +0900 @@ -62,20 +62,20 @@ moz2chLocalRule.prototype.logPath = null; moz2chLocalRule.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getMoz2chDir()); + var logFile = IO.getFileWithPath(this.getMoz2chDir()); var sabaIDs = this.ita.sabaID.split("/"); for (var i = 0; i < sabaIDs.length; i++) { logFile.append(sabaIDs[i]); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); } logFile.append(this.ita.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(kMoz2chLocalRuleLeaf); this.logPath = logFile.path; } return this.logPath; }; diff -u5r chrome_/content/moz2ch/skin.js chrome/content/moz2ch/skin.js --- chrome_/content/moz2ch/skin.js 2007-06-27 20:31:54.000000000 +0900 +++ chrome/content/moz2ch/skin.js 2007-12-03 23:09:20.000000000 +0900 @@ -60,15 +60,15 @@ var moz2chskin = { init: function() { try{ // defaultのスキンファイルがなければ作るモナ - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(kMoz2chdefaultskin); if (! moz2chDir.exists()) - moz2chDir.create(kMoz2chDataDirPerm); + moz2chDir.create(moz2chDir.DIRECTORY_TYPE, kMoz2chDataDirPerm); var checkFlag; if(nsPreferences.getBoolPref("moz2ch.skinCheckFlag") != null){ checkFlag = nsPreferences.getBoolPref("moz2ch.skinCheckFlag"); }else{ @@ -94,198 +94,195 @@ + " \n" + " \n" + " \n" + " \n" + "
\n"; - var f = new File(moz2chDir.path); + var f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinHeader); if (!f.exists()) { - f.open("w", kMoz2chDataFilePerm); - f.write(html); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); }else if(checkFlag){ - f.open("r"); - old_html = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + old_html = stream.readString(stream.available()); + stream.close(); if(old_html != html){ - f.remove(); - f = new File(moz2chDir.path); + f.remove(false); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinHeader); - f.open("w", kMoz2chDataFilePerm); - f.write(html); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); } } - f = new File(moz2chDir.path); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinRes); html=moz2ch.getString("defaultSkinRes"); if (!f.exists()) { - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2euc(html)); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); }else if(checkFlag){ - f.open("r"); - old_html = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + old_html = stream.readString(stream.available()); + stream.close(); if(old_html != html){ - f.remove(); - f = new File(moz2chDir.path); + f.remove(false); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinRes); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2euc(html.replace(/\r\n/g, "\n"))); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html.replace(/\r\n/g, "\n")); + stream.close(); } } html = moz2ch.getString("defaultSkinNew"); html = html.replace(/\r\n/g,'\n'); - f = new File(moz2chDir.path); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinNewres); if (!f.exists()) { - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2euc(html)); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); }else if(checkFlag){ - f.open("r"); - old_html = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + old_html = stream.readString(stream.available()); + stream.close(); if(old_html != html){ - f.remove(); - f = new File(moz2chDir.path); + f.remove(false); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinNewres); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2euc(html)); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); } } html = " \n" + "\n"; - f = new File(moz2chDir.path); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinFooter); if (!f.exists()) { - f.open("w", kMoz2chDataFilePerm); - f.write(html); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); }else if(checkFlag){ - f.open("r"); - old_html = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + old_html = stream.readString(stream.available()); + stream.close(); if(old_html != html){ - f.remove(); - f = new File(moz2chDir.path); + f.remove(false); + f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinFooter); - f.open("w", kMoz2chDataFilePerm); - f.write(html); - f.close(); + var stream = IO.newOutputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); } } }catch(e){ alert(e); } }, skinHeader: null, getHeader: function(skin) { if (!this.skinHeader) { - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(skin); if (!moz2chDir.exists()){ - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(kMoz2chdefaultskin); } - var f = new File(moz2chDir.path); + var f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinHeader); if (!f.exists()) return false; - f.open("r"); - this.skinHeader = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + this.skinHeader = stream.readString(stream.available()); + stream.close(); } return this.skinHeader; }, skinRes: null, getRes: function(skin) { if (!this.skinRes) { - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(skin); if (!moz2chDir.exists()){ - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(kMoz2chdefaultskin); } - var f = new File(moz2chDir.path); + var f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinRes); if (!f.exists()) return false; - f.open("r"); - this.skinRes = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + this.skinRes = stream.readString(stream.available()); + stream.close(); } return this.skinRes; }, skinNewres: null, getNewres: function(skin) { if (!this.skinNewres) { - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(skin); if (!moz2chDir.exists()){ - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(kMoz2chdefaultskin); } - var f = new File(moz2chDir.path); + var f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinNewres); if (!f.exists()) return false; - f.open("r"); - this.skinNewres = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + this.skinNewres = stream.readString(stream.available()); + stream.close(); } return this.skinNewres; }, skinFooter: null, getFooter: function(skin) { if (!this.skinFooter) { - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(skin); if (!moz2chDir.exists()){ - var moz2chDir = new Dir(this.getskinPath()); + var moz2chDir = IO.getFileWithPath(this.getskinPath()); moz2chDir.append(kMoz2chdefaultskin); } - var f = new File(moz2chDir.path); + var f = IO.getFileWithPath(moz2chDir.path); f.append(kMoz2chskinFooter); if (!f.exists()) return false; - f.open("r"); - this.skinFooter = f.read(); - f.close(); + var stream = IO.newInputStream(f, "text", "EUC-JP", "?".charCodeAt(0), 1024 * 200); + this.skinFooter = stream.readString(stream.available()); + stream.close(); } return this.skinFooter; }, skinDir: null, getskinPath: function() { if (!this.skinDir) { - var dirUtils = new DirUtils(); - var skinDir = new Dir(dirUtils.getMozUserHomeDir()); - - skinDir.append(kMoz2chDataDirName); + var skinDir = IO.getFile("Profile", kMoz2chDataDirName); if (!skinDir.exists()) - skinDir.create(kMoz2chDataDirPerm); + skinDir.create(skinDir.DIRECTORY_TYPE, kMoz2chDataDirPerm); skinDir.append(kMoz2chskinDir); if (! skinDir.exists()) - skinDir.create(kMoz2chDataDirPerm); + skinDir.create(skinDir.DIRECTORY_TYPE, kMoz2chDataDirPerm); this.skinDir = skinDir.path } return this.skinDir; }, existsSkinDir: function(skin) { var dir = this.getskinPath(); - var checkDir = new Dir(dir); + var checkDir = IO.getFileWithPath(dir); checkDir.append(skin); if(checkDir.exists()) return skin; else return kMoz2chdefaultskin; diff -u5r chrome_/content/moz2ch/sure.js chrome/content/moz2ch/sure.js --- chrome_/content/moz2ch/sure.js 2007-11-25 01:34:08.000000000 +0900 +++ chrome/content/moz2ch/sure.js 2007-12-02 02:47:40.000000000 +0900 @@ -98,20 +98,20 @@ moz2chSure.prototype.logPath = null; moz2chSure.prototype.getLogPath = function () { if (!this.logPath) { - var logFile = new Dir(this.getBBSDir()); + var logFile = IO.getFileWithPath(this.getBBSDir()); var sabaIDs = this.sabaID.split("/"); for (var i = 0; i < sabaIDs.length; i++) { logFile.append(sabaIDs[i]); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); } logFile.append(this.itaID); if (!logFile.exists()) - logFile.create(kMoz2chDataDirPerm); + logFile.create(logFile.DIRECTORY_TYPE, kMoz2chDataDirPerm); logFile.append(this.datID + ".dat"); this.logPath = logFile.path; } return this.logPath; }; @@ -152,18 +152,18 @@ return false; } var fontFamily = moz2chCharset.euc2uni('"MS Pゴシック",Osaka,"Mona","mona-gothic-jisx0208.1990-0",monospace'); - this.htmlHeader = moz2chCharset.euc2uni(moz2chskin.getHeader(moz2ch.skinName)); - this.htmlRes = moz2chCharset.euc2uni(moz2chskin.getRes(moz2ch.skinName)); - this.htmlNewres = moz2chCharset.euc2uni(moz2chskin.getNewres(moz2ch.skinName)); - this.htmlFooter = moz2chCharset.euc2uni(moz2chskin.getFooter(moz2ch.skinName)); + this.htmlHeader = moz2chskin.getHeader(moz2ch.skinName); + this.htmlRes = moz2chskin.getRes(moz2ch.skinName); + this.htmlNewres = moz2chskin.getNewres(moz2ch.skinName); + this.htmlFooter = moz2chskin.getFooter(moz2ch.skinName); - var moz2chDir = new Dir(moz2chskin.getskinPath()); + var moz2chDir = IO.getFileWithPath(moz2chskin.getskinPath()); moz2chDir.append(this.skinName); - var skinPath = moz2chDir.path?'file:///'+moz2chDir.path.replace(/\ /g, "%20").replace(/\\/g, "\/"):''; + var skinPath = moz2chDir.path?IO.newURI(moz2chDir).spec:''; if(this.old_URL != this.getDataURL() || !this.old_html || !this.sabun){ this.old_html = null; this.old_URL = this.getDataURL(); @@ -237,22 +237,17 @@ html += this.htmlFooter; html = html.replace(//g, skinPath); var url; if (html.length > 0) { - var f = new File(this.getMoz2chDir()); + var f = IO.getFileWithPath(this.getMoz2chDir()); f.append(kMoz2chSureFileName); - f.open("w", kMoz2chDataFilePerm); - f.write(moz2chCharset.uni2sjis(html)); - f.close(); - - url = f.URL; - // JSLib File.URL has a bug on Mac - // Hacking it... - if (navigator.platform.indexOf("Mac") > -1) - url = f.path ? "file:///" + f.path.replace(/\ /g, "%20") - .replace(/:/g, "\/") : ""; + var stream = IO.newOutputStream(f, "text", "Shift_JIS", "?".charCodeAt(0), 1024 * 200); + stream.writeString(html); + stream.close(); + + url = IO.newURI(f).spec; } else { url = "about:blank"; } //取得済みの値をセテーイ @@ -305,21 +300,21 @@ moz2chSure.prototype.onRequest = function () { // SABUN get code // set "Range" and "If-Modified-Since" request header for SABUN get - var f = new File(this.getLogPath()); + var f = IO.getFileWithPath(this.getLogPath()); if (f.exists() && this.ita.getAttribute(this.datID + ".dat", "lastModified")) { this.channel.setRequestHeader("If-Modified-Since", this.ita.getAttribute(this.datID + ".dat", "lastModified"), false); this.channel.setRequestHeader("Accept-Encoding", "identity", false); moz2ch.debug(this.sureClassName + ".onRequest: lastModified=" + this.ita.getAttribute(this.datID + ".dat", "lastModified")); - this.channel.setRequestHeader("Range", "bytes=" + f.size + "-", false); - f.open("r"); - this.log = f.read(); - f.close(); + this.channel.setRequestHeader("Range", "bytes=" + f.fileSize + "-", false); + var stream = IO.newInputStream(f, "binary"); + this.log = stream.readString(stream.available()); + stream.close(); var temp = this.log.split("\n"); if(temp.pop() != ""){ this.log = this.log + "\n"; } } diff -u5r chrome_/content/moz2ch/treeData.js chrome/content/moz2ch/treeData.js --- chrome_/content/moz2ch/treeData.js 2005-06-21 20:43:26.000000000 +0900 +++ chrome/content/moz2ch/treeData.js 2007-11-30 21:48:10.000000000 +0900 @@ -81,26 +81,26 @@ var rv = this.parse(); this.loaded(); if (rv && this.data.length > 0) { // if parse succeeded, save the data. - var f = new File(this.getLogPath()); - f.open("w", kMoz2chDataFilePerm); - f.write(this.data); - f.close(); + var f = IO.getFileWithPath(this.getLogPath()); + var stream = IO.newOutputStream(f, "binary"); + stream.writeString(this.data); + stream.close(); // write out data this.unload(); } }catch(e){ moz2ch.debug(e); } }; moz2chTreeData.prototype.indexPath = null; moz2chTreeData.prototype.getIndexPath = function () { if (!this.indexPath) { - var f = new File(this.getLogPath()); - f.leaf = kMoz2chTreeDataFileName; + var f = IO.getFileWithPath(this.getLogPath()); + f.leafName = kMoz2chTreeDataFileName; this.indexPath = f.path; } return this.indexPath; };