Remove now-unused runtime.getFileSize function

This commit is contained in:
Philip Peitsch
2014-09-11 15:03:43 +10:00
parent 7f50cdc093
commit 0c3e7034fc
5 changed files with 3 additions and 95 deletions
@@ -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);
}
+1 -9
View File
@@ -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();
+1 -9
View File
@@ -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;
};
+1 -9
View File
@@ -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;
};
-65
View File
@@ -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