cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: ios: Don't fail a write of zero-length payload.
Date Tue, 20 May 2014 19:14:51 GMT
Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master f92017f25 -> 2165395ee


ios: Don't fail a write of zero-length payload.


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

Branch: refs/heads/master
Commit: 2165395ee6d75f464e490f2e517c2ef5a12e7392
Parents: f92017f
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue May 20 15:14:26 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue May 20 15:14:26 2014 -0400

----------------------------------------------------------------------
 src/ios/CDVLocalFilesystem.m | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2165395e/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index db3433d..e665b04 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -467,17 +467,21 @@
         NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];
         if (fileStream) {
             NSUInteger len = [encData length];
-            [fileStream open];
+            if (len == 0) {
+                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:len];
+            } else {
+                [fileStream open];
 
-            bytesWritten = (int)[fileStream write:[encData bytes] maxLength:len];
+                bytesWritten = (int)[fileStream write:[encData bytes] maxLength:len];
 
-            [fileStream close];
-            if (bytesWritten > 0) {
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
-                // } else {
-                // can probably get more detailed error info via [fileStream streamError]
-                // errCode already set to INVALID_MODIFICATION_ERR;
-                // bytesWritten = 0; // may be set to -1 on error
+                [fileStream close];
+                if (bytesWritten > 0) {
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
+                    // } else {
+                    // can probably get more detailed error info via [fileStream streamError]
+                    // errCode already set to INVALID_MODIFICATION_ERR;
+                    // bytesWritten = 0; // may be set to -1 on error
+                }
             }
         } // else fileStream not created return INVALID_MODIFICATION_ERR
     } else {


Mime
View raw message