mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Issue #79: FileWriter.seek() is broken in 0.9.5.
The FileEntry.createWriter() method passes in a FileEntry object instead of a File object. As a result the FileWriter.length was not being set properly so when you do a writer.seek(writer.length) it would go to 0, so your next write would overwrite your file. In order to fix this issue the FileEntry.createWriter() method now makes a call to FileEntry.file() to get the correct file size. The File object is now passed to the FileWriter constructor.
This commit is contained in:
parent
346ed60f0d
commit
116169a4c5
@ -1033,19 +1033,21 @@ FileEntry.prototype.toURI = function(mimeType) {
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
|
||||
var writer = new FileWriter(this.fullPath);
|
||||
|
||||
if (writer.fileName == null || writer.fileName == "") {
|
||||
if (typeof errorCallback == "function") {
|
||||
errorCallback({
|
||||
"code": FileError.INVALID_STATE_ERR
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof successCallback == "function") {
|
||||
successCallback(writer);
|
||||
}
|
||||
this.file(function(filePointer) {
|
||||
var writer = new FileWriter(filePointer);
|
||||
|
||||
if (writer.fileName == null || writer.fileName == "") {
|
||||
if (typeof errorCallback == "function") {
|
||||
errorCallback({
|
||||
"code": FileError.INVALID_STATE_ERR
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof successCallback == "function") {
|
||||
successCallback(writer);
|
||||
}
|
||||
}, errorCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user