You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2013/08/28 16:57:11 UTC

git commit: [iOS] Simplify the code in resolveLocalFileSystemURI

Updated Branches:
  refs/heads/dev f6c3c6a28 -> e27899c32


[iOS] Simplify the code in resolveLocalFileSystemURI


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

Branch: refs/heads/dev
Commit: e27899c326ef6a65d80b7d9e328943a40b6557ff
Parents: f6c3c6a
Author: lmnbeyond <lm...@gmail.com>
Authored: Mon Jul 29 19:50:42 2013 +0800
Committer: Max Woghiren <ma...@gmail.com>
Committed: Wed Aug 28 10:56:35 2013 -0400

----------------------------------------------------------------------
 src/ios/CDVFile.m | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/e27899c3/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index c245ee3..6b2602d 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -233,19 +233,14 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
         // see if exists and is file or dir
         BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];
         if (bExists) {
-            // see if it contains docs path
-            NSRange range = [path rangeOfString:self.appDocsPath];
+            // see if it contains docs path or temp path
             NSString* foundFullPath = nil;
-            // there's probably an api or easier way to figure out the path type but I can't find it!
-            if ((range.location != NSNotFound) && (range.length == [self.appDocsPath length])) {
+            if ([path hasPrefix:self.appDocsPath]) {
                 foundFullPath = self.appDocsPath;
-            } else {
-                // see if it contains the temp path
-                range = [path rangeOfString:self.appTempPath];
-                if ((range.location != NSNotFound) && (range.length == [self.appTempPath length])) {
-                    foundFullPath = self.appTempPath;
-                }
+            } else if ([path hasPrefix:self.appTempPath]) {
+                foundFullPath = self.appTempPath;
             }
+
             if (foundFullPath == nil) {
                 // error SECURITY_ERR - not one of the two paths types supported
                 result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SECURITY_ERR];