You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/02/11 00:22:48 UTC

[22/50] git commit: Android, iOS: Replace "filesystem" protocol string with constant

Android, iOS: Replace "filesystem" protocol string with constant


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

Branch: refs/heads/master
Commit: 2a225e322ea2fac7e45e5348b0aaf2127ca0a2f5
Parents: fc2fc56
Author: Ian Clelland <ic...@chromium.org>
Authored: Sat Jan 11 09:56:48 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Jan 13 10:10:24 2014 -0500

----------------------------------------------------------------------
 src/android/FileUtils.java          | 4 ++--
 src/android/LocalFilesystem.java    | 2 +-
 src/android/LocalFilesystemURL.java | 5 ++++-
 src/ios/CDVFile.h                   | 1 +
 src/ios/CDVFile.m                   | 6 +++---
 src/ios/CDVLocalFilesystem.m        | 2 +-
 www/android/FileSystem.js           | 4 +++-
 www/ios/FileSystem.js               | 4 +++-
 8 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index b04c901..0a7bf7b 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -702,11 +702,11 @@ public class FileUtils extends CordovaPlugin {
         LocalFilesystemURL rootURL;
         if (type == TEMPORARY) {
             fs.put("name", "temporary");
-            rootURL = new LocalFilesystemURL("filesystem://localhost/temporary/");
+            rootURL = new LocalFilesystemURL(LocalFilesystemURL.FILESYSTEM_PROTOCOL + "://localhost/temporary/");
         }
         else if (type == PERSISTENT) {
             fs.put("name", "persistent");
-            rootURL = new LocalFilesystemURL("filesystem://localhost/persistent/");
+            rootURL = new LocalFilesystemURL(LocalFilesystemURL.FILESYSTEM_PROTOCOL+ "://localhost/persistent/");
         }
         else {
             throw new IOException("No filesystem of type requested");

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/android/LocalFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystem.java b/src/android/LocalFilesystem.java
index b64118b..171dd9d 100644
--- a/src/android/LocalFilesystem.java
+++ b/src/android/LocalFilesystem.java
@@ -51,7 +51,7 @@ public class LocalFilesystem extends Filesystem {
 	public LocalFilesystemURL URLforFilesystemPath(String path) {
 	    String fullPath = this.fullPathForFilesystemPath(path);
 	    if (fullPath != null) {
-	        return new LocalFilesystemURL("filesystem://localhost/"+this.name+"/"+fullPath);
+	        return new LocalFilesystemURL(LocalFilesystemURL.FILESYSTEM_PROTOCOL + "://localhost/"+this.name+"/"+fullPath);
 	    }
 	    return null;
 	}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/android/LocalFilesystemURL.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystemURL.java b/src/android/LocalFilesystemURL.java
index 1065382..a3aade8 100644
--- a/src/android/LocalFilesystemURL.java
+++ b/src/android/LocalFilesystemURL.java
@@ -3,6 +3,9 @@ package org.apache.cordova.file;
 import android.net.Uri;
 
 public class LocalFilesystemURL {
+	
+	public static final String FILESYSTEM_PROTOCOL = "filesystem";
+	
 	public static final int TEMPORARY = 0;
 	public static final int PERSISTENT = 1;
 
@@ -31,7 +34,7 @@ public class LocalFilesystemURL {
 	}
 
 	private int filesystemTypeForLocalURL(Uri URL) {
-		if ("filesystem".equals(URL.getScheme()) && "localhost".equals(URL.getHost())) {
+		if (FILESYSTEM_PROTOCOL.equals(URL.getScheme()) && "localhost".equals(URL.getHost())) {
 			String path = URL.getPath();
 			if (path != null) {
 				if (path.startsWith("/temporary")) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/ios/CDVFile.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.h b/src/ios/CDVFile.h
index 1f2c812..0693f68 100644
--- a/src/ios/CDVFile.h
+++ b/src/ios/CDVFile.h
@@ -21,6 +21,7 @@
 #import <Cordova/CDVPlugin.h>
 
 NSString* const kCDVAssetsLibraryPrefix;
+NSString* const kCDVFilesystemURLPrefix;
 
 enum CDVFileError {
     NO_ERROR = 0,

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index e53733d..7bc39b9 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -30,6 +30,8 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
     NSString* const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
 #endif
 
+NSString* const kCDVFilesystemURLPrefix = @"filesystem";
+
 @implementation CDVFilesystemURL
 @synthesize url=_url;
 @synthesize fileSystemType=_fileSystemType;
@@ -62,7 +64,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
  */
 - (CDVFileSystemType)filesystemTypeForLocalURI:(NSURL *)uri
 {
-    if ([[uri scheme] isEqualToString:@"filesystem"] && [[uri host] isEqualToString:@"localhost"]) {
+    if ([[uri scheme] isEqualToString:kCDVFilesystemURLPrefix] && [[uri host] isEqualToString:@"localhost"]) {
         if ([[uri path] hasPrefix:@"/temporary"]) {
             return TEMPORARY;
         } else if ([[uri path] hasPrefix:@"/persistent"]) {
@@ -106,8 +108,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
 
 @implementation CDVFilesystemURLProtocol
 
-NSString* const kCDVFilesystemURLPrefix = @"filesystem";
-
 + (BOOL)canInitWithRequest:(NSURLRequest*)request
 {
     NSURL* url = [request URL];

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index 6b409c9..5ad2200 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -106,7 +106,7 @@
 {
     NSString *fullPath = [self fullPathForFileSystemPath:path];
     if (fullPath) {
-        return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"filesystem://localhost/%@%@", self.name, fullPath]];
+        return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, fullPath]];
     }
     return nil;
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/www/android/FileSystem.js
----------------------------------------------------------------------
diff --git a/www/android/FileSystem.js b/www/android/FileSystem.js
index 765d4f4..2099a99 100644
--- a/www/android/FileSystem.js
+++ b/www/android/FileSystem.js
@@ -19,10 +19,12 @@
  *
 */
 
+FILESYSTEM_PROTOCOL = "filesystem";
+
 module.exports = {
     __format__: function(fullPath) {
         var path = ('/'+this.name+(fullPath[0]==='/'?'':'/')+encodeURI(fullPath)).replace('//','/');
-        return 'filesystem://localhost' + path;
+        return FILESYSTEM_PROTOCOL + '://localhost' + path;
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2a225e32/www/ios/FileSystem.js
----------------------------------------------------------------------
diff --git a/www/ios/FileSystem.js b/www/ios/FileSystem.js
index 765d4f4..2099a99 100644
--- a/www/ios/FileSystem.js
+++ b/www/ios/FileSystem.js
@@ -19,10 +19,12 @@
  *
 */
 
+FILESYSTEM_PROTOCOL = "filesystem";
+
 module.exports = {
     __format__: function(fullPath) {
         var path = ('/'+this.name+(fullPath[0]==='/'?'':'/')+encodeURI(fullPath)).replace('//','/');
-        return 'filesystem://localhost' + path;
+        return FILESYSTEM_PROTOCOL + '://localhost' + path;
     }
 };