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:06:02 UTC

[1/2] git commit: CB-5531 WP8. File Api readAsText incorrectly handles position args

Updated Branches:
  refs/heads/dev 9a5278b0c -> e0f59bd37


CB-5531 WP8. File Api readAsText incorrectly handles position args


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/f2f22abe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/f2f22abe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/f2f22abe

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

----------------------------------------------------------------------
 src/wp/File.cs | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f2f22abe/src/wp/File.cs
----------------------------------------------------------------------
diff --git a/src/wp/File.cs b/src/wp/File.cs
index b0534f0..68448df 100644
--- a/src/wp/File.cs
+++ b/src/wp/File.cs
@@ -657,30 +657,34 @@ namespace WPCordovaClassLib.Cordova.Commands
                     }
                     Encoding encoding = Encoding.GetEncoding(encStr);
 
-                    using (TextReader reader = new StreamReader(isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read), encoding))
+                    using (IsolatedStorageFileStream reader = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
                     {
-                        text = reader.ReadToEnd();
                         if (startPos < 0)
                         {
-                            startPos = Math.Max(text.Length + startPos, 0);
+                            startPos = Math.Max((int)reader.Length + startPos, 0);
                         }
                         else if (startPos > 0)
                         {
-                            startPos = Math.Min(text.Length, startPos);
+                            startPos = Math.Min((int)reader.Length, startPos);
                         }
 
                         if (endPos > 0)
                         {
-                            endPos = Math.Min(text.Length, endPos);
+                            endPos = Math.Min((int)reader.Length, endPos);
                         }
                         else if (endPos < 0)
                         {
-                            endPos = Math.Max(endPos + text.Length, 0);
+                            endPos = Math.Max(endPos + (int)reader.Length, 0);
                         }
-                        
-                        
-                        text = text.Substring(startPos, endPos - startPos);
-                        
+
+
+                        var buffer = new byte[endPos - startPos];
+
+                        reader.Seek(startPos, SeekOrigin.Begin);
+                        reader.Read(buffer, 0, buffer.Length);
+
+                        text = encoding.GetString(buffer, 0, buffer.Length);
+                       
                     }
                 }
 


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

Posted by pu...@apache.org.
Merge branch 'CB-5531' 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/e0f59bd3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/e0f59bd3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/e0f59bd3

Branch: refs/heads/dev
Commit: e0f59bd37fe579617a2d866559670716e85c248a
Parents: 9a5278b f2f22ab
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Dec 3 11:23:39 2013 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Dec 3 11:23:39 2013 -0800

----------------------------------------------------------------------
 src/wp/File.cs | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------