Skip to content

Commit

Permalink
Fixed readFile for Rhino (return JavaScript string instead of Java st…
Browse files Browse the repository at this point in the history
…ring)

[cappuccino#66 state:resolved responsible:tlrobinson]
  • Loading branch information
Tom Robinson committed Sep 22, 2008
1 parent 59e16f9 commit dff3b24
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Tools/Utilities/bridge.js
Expand Up @@ -107,24 +107,23 @@ if (typeof readFile == "undefined") {
var f = new Packages.java.io.File(path);

if (!f.canRead()) {
//alert("can't read: " + f.path)
alert("can't read: " + f.path)
return "";
}

//alert("reading: " + f.getAbsolutePath());
alert("reading: " + f.getAbsolutePath());

var fis = new Packages.java.io.FileInputStream(f);

var b = Packages.java.lang.reflect.Array.newInstance(Packages.java.lang.Byte.TYPE, fis.available());
fis.read(b);

fis.close();

//return String(new Packages.java.lang.String(b));

if (characterCoding)
return new Packages.java.lang.String(b, characterCoding);
return String(new Packages.java.lang.String(b, characterCoding));
else
return new Packages.java.lang.String(b);
return String(new Packages.java.lang.String(b));
}
}
else {
Expand Down Expand Up @@ -451,9 +450,9 @@ XMLHttpRequest.prototype.send = function(body) {

try {
this.responseText = readFile(this.url);
alert("xhr: " + this.url);
alert("xhr response: " + this.url + " (length="+this.responseText.length+")");
} catch (e) {
alert("read exception: " + this.url);
alert("xhr exception: " + this.url);
this.responseText = "";
this.responseXML = null;
}
Expand All @@ -467,7 +466,7 @@ XMLHttpRequest.prototype.send = function(body) {
this.status = 200;
}
else {
alert("empty file: " + this.url);
alert("xhr empty: " + this.url);
this.status = 404;
}

Expand Down

0 comments on commit dff3b24

Please sign in to comment.