mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Minor change for synchronous write. This seems like a bad idea.
This commit is contained in:
parent
9c0259c2c1
commit
f93c2badcc
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user