You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/12/03 21:07:40 UTC

[1/2] git commit: CB-5532 WP8. Add binary data support to FileWriter

Updated Branches:
  refs/heads/dev e0f59bd37 -> 86f3446ae


CB-5532 WP8. Add binary data support to FileWriter


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/ef636d93
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/ef636d93
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/ef636d93

Branch: refs/heads/dev
Commit: ef636d93cba502a0881bd22abe744d0b9540424c
Parents: cfdb4ed
Author: sgrebnov <se...@gmail.com>
Authored: Tue Dec 3 14:47:32 2013 +0400
Committer: sgrebnov <se...@gmail.com>
Committed: Tue Dec 3 14:47:32 2013 +0400

----------------------------------------------------------------------
 src/wp/File.cs    | 7 +++++--
 www/FileWriter.js | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/ef636d93/src/wp/File.cs
----------------------------------------------------------------------
diff --git a/src/wp/File.cs b/src/wp/File.cs
index b0534f0..c1ac8a9 100644
--- a/src/wp/File.cs
+++ b/src/wp/File.cs
@@ -799,6 +799,9 @@ namespace WPCordovaClassLib.Cordova.Commands
                     return;
                 }
 
+                char[] dataToWrite = isBinary ? JSON.JsonHelper.Deserialize<char[]>(data) :
+                    data.ToCharArray();
+
                 using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                 {
                     // create the file if not exists
@@ -817,12 +820,12 @@ namespace WPCordovaClassLib.Cordova.Commands
                         using (BinaryWriter writer = new BinaryWriter(stream))
                         {
                             writer.Seek(0, SeekOrigin.End);
-                            writer.Write(data.ToCharArray());
+                            writer.Write(dataToWrite);
                         }
                     }
                 }
 
-                DispatchCommandResult(new PluginResult(PluginResult.Status.OK, data.Length), callbackId);
+                DispatchCommandResult(new PluginResult(PluginResult.Status.OK, dataToWrite.Length), callbackId);
             }
             catch (Exception ex)
             {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/ef636d93/www/FileWriter.js
----------------------------------------------------------------------
diff --git a/www/FileWriter.js b/www/FileWriter.js
index 44d7a32..70b5ebd 100644
--- a/www/FileWriter.js
+++ b/www/FileWriter.js
@@ -118,7 +118,11 @@ FileWriter.prototype.write = function(data) {
 
     // Mark data type for safer transport over the binary bridge
     isBinary = supportsBinary && (data instanceof ArrayBuffer);
-
+    if (isBinary) {
+        // create a plain array, using the keys from the Uint8Array view so that we can serialize it
+        data = Array.apply(null, new Uint8Array(data));
+    }
+    
     // Throw an exception if we are already writing a file
     if (this.readyState === FileWriter.WRITING) {
         throw new FileError(FileError.INVALID_STATE_ERR);


[2/2] git commit: Merge branch 'CB-5532' of https://github.com/sgrebnov/cordova-plugin-file into dev

Posted by pu...@apache.org.
Merge branch 'CB-5532' of https://github.com/sgrebnov/cordova-plugin-file into dev


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/86f3446a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/86f3446a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/86f3446a

Branch: refs/heads/dev
Commit: 86f3446aef63838686871a39ed449ad18e089687
Parents: e0f59bd ef636d9
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Dec 3 12:07:00 2013 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Dec 3 12:07:00 2013 -0800

----------------------------------------------------------------------
 src/wp/File.cs    | 7 +++++--
 www/FileWriter.js | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/86f3446a/src/wp/File.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/86f3446a/www/FileWriter.js
----------------------------------------------------------------------