You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/15 21:43:29 UTC
[2/2] js commit: Always pass slice parameters to FileReader
Updated Branches:
refs/heads/master 6973f8ac6 -> fed89510e
Always pass slice parameters to FileReader
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/1d879077
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/1d879077
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/1d879077
Branch: refs/heads/master
Commit: 1d87907716be8ab1b2fec4de3296a84196109bf1
Parents: 6973f8a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Mar 14 11:31:05 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Mar 15 16:42:47 2013 -0400
----------------------------------------------------------------------
lib/common/plugin/FileReader.js | 43 ++++-----------------------------
1 files changed, 6 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/1d879077/lib/common/plugin/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileReader.js b/lib/common/plugin/FileReader.js
index 3a698c0..ae62cbd 100644
--- a/lib/common/plugin/FileReader.js
+++ b/lib/common/plugin/FileReader.js
@@ -137,14 +137,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
// Default encoding is UTF-8
var enc = encoding ? encoding : "UTF-8";
var me = this;
- var execArgs = [this._fileName, enc];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, enc, file.start, file.end];
// Read file
exec(
@@ -213,14 +206,7 @@ FileReader.prototype.readAsDataURL = function(file) {
}
var me = this;
- var execArgs = [this._fileName];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, file.start, file.end];
// Read file
exec(
@@ -285,14 +271,7 @@ FileReader.prototype.readAsBinaryString = function(file) {
}
var me = this;
- var execArgs = [this._fileName];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, file.start, file.end];
// Read file
exec(
@@ -306,8 +285,7 @@ FileReader.prototype.readAsBinaryString = function(file) {
// DONE state
me._readyState = FileReader.DONE;
- // Convert the result from an ArrayBuffer to a binary string.
- me._result = String.fromCharCode.apply(null, new Uint8Array(r));
+ me._result = r;
// If onload callback
if (typeof me.onload === "function") {
@@ -343,9 +321,7 @@ FileReader.prototype.readAsBinaryString = function(file) {
if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
- }, "File", "readAsArrayBuffer", execArgs);
- // Yes, readAsArrayBuffer. The conversion is done in Javascript, since we can
- // only exchange binary data across the bridge using ArrayBuffers.
+ }, "File", "readAsBinaryString", execArgs);
};
/**
@@ -359,14 +335,7 @@ FileReader.prototype.readAsArrayBuffer = function(file) {
}
var me = this;
- var execArgs = [this._fileName];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, file.start, file.end];
// Read file
exec(