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:
macdonst 2011-05-07 00:27:07 +08:00
parent 346ed60f0d
commit 116169a4c5

View File

@ -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);
};
/**