Skip to content

Commit

Permalink
file reads as text now
Browse files Browse the repository at this point in the history
  • Loading branch information
timkim committed May 10, 2012
1 parent 58943e2 commit 1af4b05
Showing 1 changed file with 23 additions and 52 deletions.
75 changes: 23 additions & 52 deletions lib/playbook/plugin/playbook/FileReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,63 +88,34 @@ FileReader.prototype.readAsText = function(file, encoding) {
var enc = encoding ? encoding : "UTF-8";

var me = this;
console.log('read as text');
if(blackberry.io.file.exists(this.fileName)){

}
// Read file
/*
exec(
// Success callback
function(r) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileReader.DONE) {
return;
}
// Save result
me.result = r;
// If onload callback
if (typeof me.onload === "function") {
me.onload(new ProgressEvent("load", {target:me}));
}
// DONE state
me.readyState = FileReader.DONE;
// If onloadend callback
if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
},
// Error callback
function(e) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileReader.DONE) {
return;
if(blackberry.io.file.exists(this.fileName)){
var theText = '';
var getFileContents = function(path,blob){
if(blob){

theText = blackberry.utils.blobToString(blob);
me.result = theText;

if (typeof me.onload === "function") {
me.onload(new ProgressEvent("load", {target:me}));
}

me.readyState = FileReader.DONE;

if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
}
}
// setting asynch to off - worry about making this all callbacks later
blackberry.io.file.readFile(this.fileName, getFileContents, false);

// DONE state
me.readyState = FileReader.DONE;
}else{

// null result
me.result = null;
// TODO: file doesn't exist - throw error

// Save error
me.error = new FileError(e);
// If onerror callback
if (typeof me.onerror === "function") {
me.onerror(new ProgressEvent("error", {target:me}));
}
// If onloadend callback
if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
}, "File", "readAsText", [this.fileName, enc]);
*/
}
};


Expand Down

0 comments on commit 1af4b05

Please sign in to comment.