Minor change for synchronous write. This seems like a bad idea.

This commit is contained in:
Brock Whitten 2010-02-25 10:09:58 -08:00
parent 9c0259c2c1
commit f93c2badcc
2 changed files with 9 additions and 10 deletions

View File

@ -195,17 +195,10 @@ FileReader.prototype.readAsText = function(file)
navigator.fileMgr.addFileReader(this.fileName,this);
//alert("Calling File.read : " + this.fileName);
//window.location = "gap://File.readFile/"+ file;
this.onerror = errorCallback;
this.oncomplete = successCallback;
return FileUtil.read(fileName);
}
FileReader.prototype.hasRead(data)
{
}
// File Writer
function FileWriter()
@ -232,6 +225,10 @@ FileWriter.prototype.writeAsText = function(file,text,bAppend)
navigator.fileMgr.addFileWriter(file,this);
this.readyState = 0; // EMPTY
var call = FileUtil.write(file, text, bAppend);
if(call > 0)
this.onerror();
else
this.oncomplete();
this.result = null;
}

View File

@ -97,7 +97,7 @@ public class FileUtils {
data = "FAIL: IO ERROR";
}
mView.loadUrl("javascript:navigator.FileReader.hasRead('" + data + "')");
//mView.loadUrl("javascript:navigator.FileReader.hasRead('" + data + "')");
return data;
}
@ -113,9 +113,11 @@ public class FileUtils {
out.write(buff, 0, rawData.length);
out.flush();
out.close();
mView.loadUrl("javascript:navigator.file.onsuccess('File written')");
//mView.loadUrl("javascript:navigator.FileReader.onsuccess('File written')");
} catch (Exception e) {
mView.loadUrl("javascript:navigator.file.onerror('Fail')");
//mView.loadUrl("javascript:navigator.FileReader.onerror('Fail')");
// So, do we just return -1 at this point!
return -1;
}
return 0;
}