From 0c3e7034fc67942ce6864748ad00b24b63fb2d70 Mon Sep 17 00:00:00 2001 From: Philip Peitsch Date: Thu, 11 Sep 2014 15:03:43 +1000 Subject: [PATCH] Remove now-unused runtime.getFileSize function --- attic/programs/nativeQtClient/odfview.cpp | 3 -- programs/docnosis/docnosis.js | 10 +--- programs/editor/localfileeditor.js | 10 +--- programs/editor/revieweditor.js | 10 +--- webodf/lib/runtime.js | 65 ----------------------- 5 files changed, 3 insertions(+), 95 deletions(-) diff --git a/attic/programs/nativeQtClient/odfview.cpp b/attic/programs/nativeQtClient/odfview.cpp index 97125a55..60da5c9e 100644 --- a/attic/programs/nativeQtClient/odfview.cpp +++ b/attic/programs/nativeQtClient/odfview.cpp @@ -75,9 +75,6 @@ OdfView::slotLoadFinished(bool ok) { " var data = nativeio.read(path, offset, length);" " data = runtime.byteArrayFromString(data, 'binary');" " callback(nativeio.error()||null, data);" - "};" - "runtime.getFileSize = function (path, callback) {" - " callback(nativeio.getFileSize(path));" "};"; frame->evaluateJavaScript(js); } diff --git a/programs/docnosis/docnosis.js b/programs/docnosis/docnosis.js index ef846eaf..2130da62 100644 --- a/programs/docnosis/docnosis.js +++ b/programs/docnosis/docnosis.js @@ -783,8 +783,7 @@ function Docnosis(element) { } function enhanceRuntime() { - var read = runtime.read, - getFileSize = runtime.getFileSize; + var read = runtime.read; runtime.read = function (path, offset, length, callback) { if (openedFiles.hasOwnProperty(path)) { return openedFiles[path].read(offset, length, callback); @@ -792,13 +791,6 @@ function Docnosis(element) { return read(path, offset, length, callback); } }; - runtime.getFileSize = function (path, callback) { - if (openedFiles.hasOwnProperty(path)) { - return callback(openedFiles[path].file.size); - } else { - return getFileSize(path, callback); - } - }; } form = createForm(); diff --git a/programs/editor/localfileeditor.js b/programs/editor/localfileeditor.js index 4202efd4..4a7aacef 100644 --- a/programs/editor/localfileeditor.js +++ b/programs/editor/localfileeditor.js @@ -77,8 +77,7 @@ function createEditor() { function enhanceRuntime() { var openedFiles = {}, - read = runtime.read, - getFileSize = runtime.getFileSize; + read = runtime.read; runtime.read = function (path, offset, length, callback) { var array; if (openedFiles.hasOwnProperty(path)) { @@ -88,13 +87,6 @@ function createEditor() { return read(path, offset, length, callback); } }; - runtime.getFileSize = function (path, callback) { - if (openedFiles.hasOwnProperty(path)) { - return callback(openedFiles[path].byteLength); - } else { - return getFileSize(path, callback); - } - }; runtime.registerFile = function (path, data) { openedFiles[path] = data; }; diff --git a/programs/editor/revieweditor.js b/programs/editor/revieweditor.js index f3201de5..666000c2 100644 --- a/programs/editor/revieweditor.js +++ b/programs/editor/revieweditor.js @@ -77,8 +77,7 @@ function createReviewEditor() { function enhanceRuntime() { var openedFiles = {}, - read = runtime.read, - getFileSize = runtime.getFileSize; + read = runtime.read; runtime.read = function (path, offset, length, callback) { var array; if (openedFiles.hasOwnProperty(path)) { @@ -88,13 +87,6 @@ function createReviewEditor() { return read(path, offset, length, callback); } }; - runtime.getFileSize = function (path, callback) { - if (openedFiles.hasOwnProperty(path)) { - return callback(openedFiles[path].byteLength); - } else { - return getFileSize(path, callback); - } - }; runtime.registerFile = function (path, data) { openedFiles[path] = data; }; diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index ea1ad28a..f2fdb312 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -110,12 +110,6 @@ Runtime.prototype.loadXML = function (path, callback) {"use strict"; }; Runtime.prototype.writeFile = function (path, data, callback) {"use strict"; }; /** * @param {!string} path -/** - * @param {!string} path - * @param {!function(number):undefined} callback - * @return {undefined} - */ -Runtime.prototype.getFileSize = function (path, callback) {"use strict"; }; * @param {!function(?string):undefined} callback * @return {undefined} */ @@ -791,44 +785,12 @@ function BrowserRuntime(logoutput) { callback(e.message, null); } } - /** - * @param {!string} path - * @param {!function(number):undefined} callback - * @return {undefined} - */ - function getFileSize(path, callback) { - var xhr = new XMLHttpRequest(); - xhr.open("HEAD", path, true); - xhr.onreadystatechange = function () { - if (xhr.readyState !== 4) { - return; - } - var cl = xhr.getResponseHeader("Content-Length"); - if (cl) { - callback(parseInt(cl, 10)); - } else { - // Due to CORS implementation bugs, some browsers will not allow access to certain headers - // even if the server says it's ok. This specific bug was observed in Cocoa's WebView on OSX10.8. - // However, even though the browser won't pull the content-length header (coz it's a security risk!) - // the content can still be fetched. - readFile(path, "binary", function (err, data) { - if (!err) { - callback(data.length); - } else { - callback(-1); - } - }); - } - }; - xhr.send(null); - } this.readFile = readFile; this.read = read; this.readFileSync = readFileSync; this.writeFile = writeFile; this.deleteFile = deleteFile; this.loadXML = loadXML; - this.getFileSize = getFileSize; this.log = log; this.enableAlerts = true; this.assert = Runtime.assert; @@ -1113,21 +1075,6 @@ function NodeJSRuntime() { } return s; }; - /** - * @param {!string} path - * @param {!function(number):undefined} callback - * @return {undefined} - */ - this.getFileSize = function (path, callback) { - path = pathmod.resolve(currentDirectory, path); - fs.stat(path, function (err, stats) { - if (err) { - callback(-1); - } else { - callback(stats.size); - } - }); - }; /** * @param {!string} msgOrCategory * @param {string=} msg @@ -1440,18 +1387,6 @@ function RhinoRuntime() { } return s; }; - /** - * @param {!string} path - * @param {!function(number):undefined} callback - * @return {undefined} - */ - this.getFileSize = function (path, callback) { - if (currentDirectory) { - path = currentDirectory + "/" + path; - } - var file = new Packages.java.io.File(path); - callback(file.length()); - }; /** * @param {!string} msgOrCategory * @param {string=} msg