You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dr...@apache.org on 2014/06/04 19:48:57 UTC
[1/9] git commit: CB-285 Add cordova.file.*Directory properties for
iOS & Android
Repository: cordova-plugin-file
Updated Branches:
refs/heads/pluggable_webview 1ef80cbf3 -> 79cebdafb
CB-285 Add cordova.file.*Directory properties for iOS & Android
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/856b8c5c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/856b8c5c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/856b8c5c
Branch: refs/heads/pluggable_webview
Commit: 856b8c5cf3ccbfa36cf61ac4b6cd14bf26aeef88
Parents: bff46b6
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue May 13 21:46:13 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu May 15 21:01:09 2014 -0400
----------------------------------------------------------------------
plugin.xml | 9 ++++++
src/android/FileUtils.java | 20 ++++++++++++++
src/ios/CDVFile.m | 30 ++++++++++++++++++++
www/fileSystemPaths.js | 61 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 120 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/856b8c5c/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 731c51b..21f177e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -135,6 +135,10 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<js-module src="www/fileSystems-roots.js" name="fileSystems-roots">
<runs/>
</js-module>
+ <js-module src="www/fileSystemPaths.js" name="fileSystemPaths">
+ <merges target="cordova" />
+ <runs/>
+ </js-module>
</platform>
<!-- amazon-fireos -->
@@ -208,6 +212,11 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<runs/>
</js-module>
+ <js-module src="www/fileSystemPaths.js" name="fileSystemPaths">
+ <merges target="cordova" />
+ <runs/>
+ </js-module>
+
<framework src="AssetsLibrary.framework" />
<framework src="MobileCoreServices.framework" />
</platform>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/856b8c5c/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 5fbe1f6..9233a62 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -344,6 +344,8 @@ public class FileUtils extends CordovaPlugin {
callbackContext.success(requestAllFileSystems());
}
}, callbackContext);
+ } else if (action.equals("requestAllPaths")) {
+ callbackContext.success(requestAllPaths());
} else if (action.equals("requestFileSystem")) {
final int fstype=args.getInt(0);
final long size = args.optLong(1);
@@ -850,6 +852,24 @@ public class FileUtils extends CordovaPlugin {
return ret;
}
+ private static String toDirUrl(File f) {
+ return Uri.fromFile(f).toString() + '/';
+ }
+
+ private JSONObject requestAllPaths() throws JSONException {
+ Context context = cordova.getActivity();
+ JSONObject ret = new JSONObject();
+ ret.put("applicationDirectory", "file:///android_asset/");
+ ret.put("applicationStorageDirectory", toDirUrl(context.getFilesDir().getParentFile()));
+ ret.put("dataDirectory", toDirUrl(context.getFilesDir()));
+ ret.put("cacheDirectory", toDirUrl(context.getCacheDir()));
+ ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile()));
+ ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null)));
+ ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir()));
+ ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory()));
+ return ret;
+ }
+
/**
* Returns a JSON object representing the given File. Internal APIs should be modified
* to use URLs instead of raw FS paths wherever possible, when interfacing with this plugin.
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/856b8c5c/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index 11b8dd3..b22b7cf 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -458,6 +458,36 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
+- (void)requestAllPaths:(CDVInvokedUrlCommand*)command
+{
+ NSString* libPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
+ NSString* libPathSync = [libPath stringByAppendingPathComponent:@"Cloud"];
+ NSString* libPathNoSync = [libPath stringByAppendingPathComponent:@"NoCloud"];
+ NSString* docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
+ NSString* storagePath = [libPath stringByDeletingLastPathComponent];
+ NSString* cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
+
+ // Create the directories if necessary.
+ [[NSFileManager defaultManager] createDirectoryAtPath:libPathSync withIntermediateDirectories:YES attributes:nil error:nil];
+ [[NSFileManager defaultManager] createDirectoryAtPath:libPathNoSync withIntermediateDirectories:YES attributes:nil error:nil];
+ // Mark NoSync as non-iCloud.
+ [[NSURL fileURLWithPath:libPathNoSync] setResourceValue: [NSNumber numberWithBool: YES]
+ forKey: NSURLIsExcludedFromBackupKey error:nil];
+
+ NSDictionary* ret = @{
+ @"applicationDirectory": [[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]] absoluteString],
+ @"applicationStorageDirectory": [[NSURL fileURLWithPath:storagePath] absoluteString],
+ @"dataDirectory": [[NSURL fileURLWithPath:libPathNoSync] absoluteString],
+ @"syncedDataDirectory": [[NSURL fileURLWithPath:libPathSync] absoluteString],
+ @"documentsDirectory": [[NSURL fileURLWithPath:docPath] absoluteString],
+ @"cacheDirectory": [[NSURL fileURLWithPath:cachePath] absoluteString],
+ @"tempDirectory": [[NSURL fileURLWithPath:NSTemporaryDirectory()] absoluteString]
+ };
+
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:ret];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+}
+
/* Creates and returns a dictionary representing an Entry Object
*
* IN:
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/856b8c5c/www/fileSystemPaths.js
----------------------------------------------------------------------
diff --git a/www/fileSystemPaths.js b/www/fileSystemPaths.js
new file mode 100644
index 0000000..8ef0bb8
--- /dev/null
+++ b/www/fileSystemPaths.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var exec = require('cordova/exec');
+var channel = require('cordova/channel');
+
+exports.file = {
+ // Read-only directory where the application is installed.
+ applicationDirectory: null,
+ // Root of app's private writable storage
+ applicationStorageDirectory: null,
+ // Where to put app-specific data files.
+ dataDirectory: null,
+ // Cached files that should survive app restarts.
+ // Apps should not rely on the OS to delete files in here.
+ cacheDirectory: null,
+ // Android: the application space on external storage.
+ externalApplicationStorageDirectory: null,
+ // Android: Where to put app-specific data files on external storage.
+ externalDataDirectory: null,
+ // Android: the application cache on external storage.
+ externalCacheDirectory: null,
+ // Android: the external storage (SD card) root.
+ externalRootDirectory: null,
+ // iOS: Temp directory that the OS can clear at will.
+ tempDirectory: null,
+ // iOS: Holds app-specific files that should be synced (e.g. to iCloud).
+ syncedDataDirectory: null,
+ // iOS: Files private to the app, but that are meaningful to other applciations (e.g. Office files)
+ documentsDirectory: null
+};
+
+channel.waitForInitialization('onFileSystemPathsReady');
+channel.onCordovaReady.subscribe(function() {
+ function after(paths) {
+ for (var k in paths) {
+ exports.file[k] = paths[k];
+ }
+ channel.initializationComplete('onFileSystemPathsReady');
+ }
+ exec(after, null, 'File', 'requestAllPaths', []);
+});
+
[8/9] git commit: CB-6803 Add license
Posted by dr...@apache.org.
CB-6803 Add license
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/a9b6b402
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/a9b6b402
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/a9b6b402
Branch: refs/heads/pluggable_webview
Commit: a9b6b402260c481eabeffaf8db6cc7a0edd06e1d
Parents: 767e2c5
Author: Marcel Kinard <cm...@gmail.com>
Authored: Fri May 30 11:28:13 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Fri May 30 11:28:13 2014 -0400
----------------------------------------------------------------------
CONTRIBUTING.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/a9b6b402/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1594d12..f7dbcab 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,3 +1,24 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
+
# Contributing to Apache Cordova
Anyone can contribute to Cordova. And we need your contributions.
[6/9] git commit: Small wording tweaks
Posted by dr...@apache.org.
Small wording tweaks
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/890d8d22
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/890d8d22
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/890d8d22
Branch: refs/heads/pluggable_webview
Commit: 890d8d221403a56d9b5f6138fcbc47aee2a0053b
Parents: 94ad2de
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri May 23 15:44:43 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri May 23 15:44:43 2014 -0400
----------------------------------------------------------------------
doc/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/890d8d22/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index e05ff38..74a68d9 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -178,7 +178,7 @@ with FileSystem URLs, so replacing `entry.fullPath` with `entry.toURL()` should
issues getting that plugin to work with files on the device.
In v1.1.0 the return value of `toURL()` was changed (see [CB-6394] (https://issues.apache.org/jira/browse/CB-6394))
-and return an absolute 'file://' URL. To get a 'cdvfile:'-URL you have to use `toInternalURL()` now.
+to return an absolute 'file://' URL. wherever possible. To ensure a 'cdvfile:'-URL you can use `toInternalURL()` now.
This method will now return filesystem URLs of the form
cdvfile://localhost/persistent/path/to/file
[5/9] git commit: Fixed toURL() toInternalURL() information in the
doku
Posted by dr...@apache.org.
Fixed toURL() toInternalURL() information in the doku
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/94ad2dea
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/94ad2dea
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/94ad2dea
Branch: refs/heads/pluggable_webview
Commit: 94ad2deabca64fc808f49fafe9f5c56009e1bb2b
Parents: 2165395
Author: Dominik Pesch <d....@11com7.de>
Authored: Wed May 14 18:02:07 2014 +0200
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri May 23 15:44:13 2014 -0400
----------------------------------------------------------------------
doc/index.md | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/94ad2dea/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index c24e11a..e05ff38 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -166,11 +166,7 @@ object with a `fullPath` of
If your application works with device-absolute-paths, and you previously retrieved those
paths through the `fullPath` property of `Entry` objects, then you should update your code
-to use `entry.toURL()` instead. This method will now return filesystem URLs of the form
-
- cdvfile://localhost/persistent/path/to/file
-
-which can be used to identify the file uniquely.
+to use `entry.toURL()` instead.
For backwards compatibility, the `resolveLocalFileSystemURL()` method will accept a
device-absolute-path, and will return an `Entry` object corresponding to it, as long as that
@@ -181,6 +177,14 @@ device-absolute-paths (and can still accept them). It has been updated to work c
with FileSystem URLs, so replacing `entry.fullPath` with `entry.toURL()` should resolve any
issues getting that plugin to work with files on the device.
+In v1.1.0 the return value of `toURL()` was changed (see [CB-6394] (https://issues.apache.org/jira/browse/CB-6394))
+and return an absolute 'file://' URL. To get a 'cdvfile:'-URL you have to use `toInternalURL()` now.
+This method will now return filesystem URLs of the form
+
+ cdvfile://localhost/persistent/path/to/file
+
+which can be used to identify the file uniquely.
+
## List of Error Codes and Meanings
When an error is thrown, one of the following codes will be used.
@@ -226,4 +230,3 @@ Android also supports a special filesystem named "documents", which represents a
* root: The entire device filesystem
By default, the library and documents directories can be synced to iCloud. You can also request two additional filesystems, "library-nosync" and "documents-nosync", which represent a special non-synced directory within the Library or Documents filesystem.
-
[7/9] git commit: Merge branch 'initial'
Posted by dr...@apache.org.
Merge branch 'initial'
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/767e2c59
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/767e2c59
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/767e2c59
Branch: refs/heads/pluggable_webview
Commit: 767e2c5919ad92e5c94c1b06f19a21b90d8277f1
Parents: 890d8d2 f7f1522
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Tue May 27 15:25:22 2014 +0200
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Tue May 27 15:25:22 2014 +0200
----------------------------------------------------------------------
doc/index.md | 11 +
plugin.xml | 7 +
src/firefoxos/FileProxy.js | 680 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 698 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/767e2c59/doc/index.md
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/767e2c59/plugin.xml
----------------------------------------------------------------------
[3/9] git commit: ios: Don't fail a write of zero-length payload.
Posted by dr...@apache.org.
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/pluggable_webview
Commit: 2165395ee6d75f464e490f2e517c2ef5a12e7392
Parents: f92017f
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue May 20 15:14:26 2014 -0400
Committer: Andrew Grieve <ag...@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 {
[4/9] git commit: Initial implementation for Firefox OS
Posted by dr...@apache.org.
Initial implementation for Firefox OS
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/f7f15224
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/f7f15224
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/f7f15224
Branch: refs/heads/pluggable_webview
Commit: f7f152242f3670d7363c3180035468e09689ffcf
Parents: bff46b6
Author: Rodrigo Silveira <ro...@outlook.com>
Authored: Thu May 8 20:30:38 2014 -0700
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Thu May 22 12:29:05 2014 -0700
----------------------------------------------------------------------
doc/index.md | 11 +
plugin.xml | 7 +
src/firefoxos/FileProxy.js | 680 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 698 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f7f15224/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 11637b1..d0384a5 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -36,6 +36,7 @@ on the subject. For an overview of other storage options, refer to Cordova's
- iOS
- Windows Phone 7 and 8*
- Windows 8*
+- Firefox OS
\* _These platforms do not support `FileReader.readAsArrayBuffer` nor `FileWriter.write(blob)`._
@@ -147,6 +148,16 @@ unable to access their previously-stored files.
If your application is new, or has never previously stored files in the
persistent filesystem, then the "Library" setting is generally recommended.
+### Firefox OS Quirks
+
+The File System API is not natively supported by Firefox OS and is implemented
+as a shim on top of indexedDB.
+
+* Does not fail when removing non-empty directories
+* Does not support metadata for directories
+* Does not support `requestAllFileSystems` and `resolveLocalFileSystemURI` methods
+* Methods `copyTo` and `moveTo` do not support directories
+
## Upgrading Notes
In v1.0.0 of this plugin, the `FileEntry` and `DirectoryEntry` structures have changed,
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f7f15224/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 731c51b..5d19a5d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -299,4 +299,11 @@ xmlns:android="http://schemas.android.com/apk/res/android"
</js-module>
</platform>
+ <!-- firefox os -->
+ <platform name="firefoxos">
+ <js-module src="src/firefoxos/FileProxy.js" name="FileProxy">
+ <runs />
+ </js-module>
+ </platform>
+
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f7f15224/src/firefoxos/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/FileProxy.js b/src/firefoxos/FileProxy.js
new file mode 100644
index 0000000..8f36632
--- /dev/null
+++ b/src/firefoxos/FileProxy.js
@@ -0,0 +1,680 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+var LocalFileSystem = require('./LocalFileSystem'),
+ FileSystem = require('./FileSystem'),
+ FileEntry = require('./FileEntry'),
+ FileError = require('./FileError'),
+ DirectoryEntry = require('./DirectoryEntry'),
+ File = require('./File');
+
+/*
+QUIRKS:
+ Does not fail when removing non-empty directories
+ Does not support metadata for directories
+ Does not support requestAllFileSystems
+ Does not support resolveLocalFileSystemURI
+ Methods copyTo and moveTo do not support directories
+
+ Heavily based on https://github.com/ebidel/idb.filesystem.js
+ */
+
+
+(function(exports, global) {
+ var indexedDB = global.indexedDB || global.mozIndexedDB;
+ if (!indexedDB) {
+ throw "Firefox OS File plugin: indexedDB not supported";
+ }
+
+ var fs_ = null;
+
+ var storageType_ = 'temporary';
+ var idb_ = {};
+ idb_.db = null;
+ var FILE_STORE_ = 'entries';
+
+ var DIR_SEPARATOR = '/';
+ var DIR_OPEN_BOUND = String.fromCharCode(DIR_SEPARATOR.charCodeAt(0) + 1);
+
+/*** Exported functionality ***/
+
+ exports.requestFileSystem = function(successCallback, errorCallback, args) {
+ var type = args[0];
+ var size = args[1];
+
+ if (type !== LocalFileSystem.TEMPORARY && type !== LocalFileSystem.PERSISTENT) {
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ return;
+ }
+ }
+
+ storageType_ = type == LocalFileSystem.TEMPORARY ? 'Temporary' : 'Persistent';
+ var name = (location.protocol + location.host).replace(/:/g, '_') +
+ ':' + storageType_;
+
+ var root = new DirectoryEntry('', DIR_SEPARATOR);
+ var fs_ = new FileSystem(name, root);
+
+ idb_.open(fs_.name, function() {
+ successCallback(fs_);
+ }, errorCallback);
+ };
+
+ // list a directory's contents (files and folders).
+ exports.readEntries = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+
+ if (!successCallback) {
+ throw Error('Expected successCallback argument.');
+ }
+
+ idb_.getAllEntries(fullPath, function(entries) {
+ successCallback(entries);
+ }, errorCallback);
+ };
+
+ exports.getFile = function(successCallback, errorCallback, args) {
+ var fullpath = args[0];
+ var path = args[1];
+ var options = args[2] || {};
+
+ // Create an absolute path if we were handed a relative one.
+ path = resolveToFullPath_(fullpath, path);
+
+ idb_.get(path, function(fileEntry) {
+ if (options.create === true && options.exclusive === true && fileEntry) {
+ // If create and exclusive are both true, and the path already exists,
+ // getFile must fail.
+
+ if (errorCallback) {
+ errorCallback(FileError.PATH_EXISTS_ERR);
+ }
+ } else if (options.create === true && !fileEntry) {
+ // If create is true, the path doesn't exist, and no other error occurs,
+ // getFile must create it as a zero-length file and return a corresponding
+ // FileEntry.
+ var name = path.split(DIR_SEPARATOR).pop(); // Just need filename.
+ var newFileEntry = new FileEntry(name, path, fs_);
+
+ newFileEntry.file_ = new MyFile({
+ size: 0,
+ name: newFileEntry.name,
+ lastModifiedDate: new Date()
+ });
+
+ idb_.put(newFileEntry, successCallback, errorCallback);
+ } else if (options.create === true && fileEntry) {
+ if (fileEntry.isFile) {
+ successCallback(fileEntryFromIdbEntry(fileEntry));
+ } else {
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ }
+ }
+ } else if ((!options.create || options.create === false) && !fileEntry) {
+ // If create is not true and the path doesn't exist, getFile must fail.
+ if (errorCallback) {
+ errorCallback(FileError.NOT_FOUND_ERR);
+ }
+ } else if ((!options.create || options.create === false) && fileEntry &&
+ fileEntry.isDirectory) {
+ // If create is not true and the path exists, but is a directory, getFile
+ // must fail.
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ }
+ } else {
+ // Otherwise, if no other error occurs, getFile must return a FileEntry
+ // corresponding to path.
+
+ successCallback(fileEntryFromIdbEntry(fileEntry));
+ }
+ }, errorCallback);
+ };
+
+ exports.getFileMetadata = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+
+ exports.getFile(function(fileEntry) {
+ successCallback(new File(fileEntry.file_.name, fileEntry.fullPath, '', fileEntry.file_.lastModifiedDate,
+ fileEntry.file_.size));
+ }, errorCallback, [null, fullPath]);
+ };
+
+ exports.getMetadata = function(successCallback, errorCallback, args) {
+ exports.getFile(function (fileEntry) {
+ successCallback(
+ {
+ modificationTime: fileEntry.file_.lastModifiedDate,
+ size: fileEntry.file_.lastModifiedDate
+ });
+ }, errorCallback, args);
+ };
+
+ exports.setMetadata = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+ var metadataObject = args[1];
+
+ exports.getFile(function (fileEntry) {
+ fileEntry.file_.lastModifiedDate = metadataObject.modificationTime;
+ }, errorCallback, [null, fullPath]);
+ };
+
+ exports.write = function(successCallback, errorCallback, args) {
+ var fileName = args[0],
+ data = args[1],
+ position = args[2],
+ isBinary = args[3];
+
+ if (!data) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ return;
+ }
+
+ exports.getFile(function(fileEntry) {
+ var blob_ = fileEntry.file_.blob_;
+
+ if (!blob_) {
+ blob_ = new Blob([data], {type: data.type});
+ } else {
+ // Calc the head and tail fragments
+ var head = blob_.slice(0, position);
+ var tail = blob_.slice(position + data.byteLength);
+
+ // Calc the padding
+ var padding = position - head.size;
+ if (padding < 0) {
+ padding = 0;
+ }
+
+ // Do the "write". In fact, a full overwrite of the Blob.
+ blob_ = new Blob([head, new Uint8Array(padding), data, tail],
+ {type: data.type});
+ }
+
+ // Set the blob we're writing on this file entry so we can recall it later.
+ fileEntry.file_.blob_ = blob_;
+ fileEntry.file_.lastModifiedDate = data.lastModifiedDate || null;
+ fileEntry.file_.size = blob_.size;
+ fileEntry.file_.name = blob_.name;
+ fileEntry.file_.type = blob_.type;
+
+ idb_.put(fileEntry, function() {
+ successCallback(data.byteLength);
+ }, errorCallback);
+ }, errorCallback, [null, fileName]);
+ };
+
+ exports.readAsText = function(successCallback, errorCallback, args) {
+ var fileName = args[0],
+ enc = args[1],
+ startPos = args[2],
+ endPos = args[3];
+
+ readAs('text', fileName, enc, startPos, endPos, successCallback, errorCallback);
+ };
+
+ exports.readAsDataURL = function(successCallback, errorCallback, args) {
+ var fileName = args[0],
+ startPos = args[1],
+ endPos = args[2];
+
+ readAs('dataURL', fileName, null, startPos, endPos, successCallback, errorCallback);
+ };
+
+ exports.readAsBinaryString = function(successCallback, errorCallback, args) {
+ var fileName = args[0],
+ startPos = args[1],
+ endPos = args[2];
+
+ readAs('binaryString', fileName, null, startPos, endPos, successCallback, errorCallback);
+ };
+
+ exports.readAsArrayBuffer = function(successCallback, errorCallback, args) {
+ var fileName = args[0],
+ startPos = args[1],
+ endPos = args[2];
+
+ readAs('arrayBuffer', fileName, null, startPos, endPos, successCallback, errorCallback);
+ };
+
+ exports.removeRecursively = exports.remove = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+
+ // TODO: This doesn't protect against directories that have content in it.
+ // Should throw an error instead if the dirEntry is not empty.
+ idb_['delete'](fullPath, function() {
+ successCallback();
+ }, errorCallback);
+ };
+
+ exports.getDirectory = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+ var path = args[1];
+ var options = args[2];
+
+ // Create an absolute path if we were handed a relative one.
+ path = resolveToFullPath_(fullPath, path);
+
+ idb_.get(path, function(folderEntry) {
+ if (!options) {
+ options = {};
+ }
+
+ if (options.create === true && options.exclusive === true && folderEntry) {
+ // If create and exclusive are both true, and the path already exists,
+ // getDirectory must fail.
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ }
+ } else if (options.create === true && !folderEntry) {
+ // If create is true, the path doesn't exist, and no other error occurs,
+ // getDirectory must create it as a zero-length file and return a corresponding
+ // MyDirectoryEntry.
+ var name = path.split(DIR_SEPARATOR).pop(); // Just need filename.
+ var dirEntry = new DirectoryEntry(name, path, fs_);
+
+ idb_.put(dirEntry, successCallback, errorCallback);
+ } else if (options.create === true && folderEntry) {
+
+ if (folderEntry.isDirectory) {
+ // IDB won't save methods, so we need re-create the MyDirectoryEntry.
+ successCallback(new DirectoryEntry(folderEntry.name, folderEntry.fullPath, folderEntry.fileSystem));
+ } else {
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ }
+ }
+ } else if ((!options.create || options.create === false) && !folderEntry) {
+ // Handle root special. It should always exist.
+ if (path == DIR_SEPARATOR) {
+ folderEntry = new DirectoryEntry('', DIR_SEPARATOR, fs_);
+ successCallback(folderEntry);
+ return;
+ }
+
+ // If create is not true and the path doesn't exist, getDirectory must fail.
+ if (errorCallback) {
+ errorCallback(FileError.NOT_FOUND_ERR);
+ }
+ } else if ((!options.create || options.create === false) && folderEntry &&
+ folderEntry.isFile) {
+ // If create is not true and the path exists, but is a file, getDirectory
+ // must fail.
+ if (errorCallback) {
+ errorCallback(FileError.INVALID_MODIFICATION_ERR);
+ }
+ } else {
+ // Otherwise, if no other error occurs, getDirectory must return a
+ // MyDirectoryEntry corresponding to path.
+
+ // IDB won't' save methods, so we need re-create MyDirectoryEntry.
+ successCallback(new DirectoryEntry(folderEntry.name, folderEntry.fullPath, folderEntry.fileSystem));
+ }
+ }, errorCallback);
+ };
+
+ exports.getParent = function(successCallback, errorCallback, args) {
+ var fullPath = args[0];
+
+ if (fullPath === DIR_SEPARATOR) {
+ successCallback(fs_.root);
+ return;
+ }
+
+ var pathArr = fullPath.split(DIR_SEPARATOR);
+ pathArr.pop();
+ var namesa = pathArr.pop();
+ var path = pathArr.join(DIR_SEPARATOR);
+
+ exports.getDirectory(successCallback, errorCallback, [path, namesa, {create: false}]);
+ };
+
+ exports.copyTo = function(successCallback, errorCallback, args) {
+ var srcPath = args[0];
+ var parentFullPath = args[1];
+ var name = args[2];
+
+ // Read src file
+ exports.getFile(function(srcFileEntry) {
+
+ // Create dest file
+ exports.getFile(function(dstFileEntry) {
+
+ exports.write(function() {
+ successCallback(dstFileEntry);
+ }, errorCallback, [dstFileEntry.fullPath, srcFileEntry.file_.blob_, 0]);
+
+ }, errorCallback, [parentFullPath, name, {create: true}]);
+
+ }, errorCallback, [null, srcPath]);
+ };
+
+ exports.moveTo = function(successCallback, errorCallback, args) {
+ var srcPath = args[0];
+ var parentFullPath = args[1];
+ var name = args[2];
+
+ exports.copyTo(function (fileEntry) {
+
+ exports.remove(function () {
+ successCallback(fileEntry);
+ }, errorCallback, [srcPath]);
+
+ }, errorCallback, args);
+ };
+
+/*** Helpers ***/
+
+ /**
+ * Interface to wrap the native File interface.
+ *
+ * This interface is necessary for creating zero-length (empty) files,
+ * something the Filesystem API allows you to do. Unfortunately, File's
+ * constructor cannot be called directly, making it impossible to instantiate
+ * an empty File in JS.
+ *
+ * @param {Object} opts Initial values.
+ * @constructor
+ */
+ function MyFile(opts) {
+ var blob_ = null;
+
+ this.size = opts.size || 0;
+ this.name = opts.name || '';
+ this.type = opts.type || '';
+ this.lastModifiedDate = opts.lastModifiedDate || null;
+
+ // Need some black magic to correct the object's size/name/type based on the
+ // blob that is saved.
+ Object.defineProperty(this, 'blob_', {
+ enumerable: true,
+ get: function() {
+ return blob_;
+ },
+ set: function(val) {
+ blob_ = val;
+ this.size = blob_.size;
+ this.name = blob_.name;
+ this.type = blob_.type;
+ this.lastModifiedDate = blob_.lastModifiedDate;
+ }.bind(this)
+ });
+ }
+
+ MyFile.prototype.constructor = MyFile;
+
+ // When saving an entry, the fullPath should always lead with a slash and never
+ // end with one (e.g. a directory). Also, resolve '.' and '..' to an absolute
+ // one. This method ensures path is legit!
+ function resolveToFullPath_(cwdFullPath, path) {
+ var fullPath = path;
+
+ var relativePath = path[0] != DIR_SEPARATOR;
+ if (relativePath) {
+ fullPath = cwdFullPath;
+ if (cwdFullPath != DIR_SEPARATOR) {
+ fullPath += DIR_SEPARATOR + path;
+ } else {
+ fullPath += path;
+ }
+ }
+
+ // Adjust '..'s by removing parent directories when '..' flows in path.
+ var parts = fullPath.split(DIR_SEPARATOR);
+ for (var i = 0; i < parts.length; ++i) {
+ var part = parts[i];
+ if (part == '..') {
+ parts[i - 1] = '';
+ parts[i] = '';
+ }
+ }
+ fullPath = parts.filter(function(el) {
+ return el;
+ }).join(DIR_SEPARATOR);
+
+ // Add back in leading slash.
+ if (fullPath[0] != DIR_SEPARATOR) {
+ fullPath = DIR_SEPARATOR + fullPath;
+ }
+
+ // Replace './' by current dir. ('./one/./two' -> one/two)
+ fullPath = fullPath.replace(/\.\//g, DIR_SEPARATOR);
+
+ // Replace '//' with '/'.
+ fullPath = fullPath.replace(/\/\//g, DIR_SEPARATOR);
+
+ // Replace '/.' with '/'.
+ fullPath = fullPath.replace(/\/\./g, DIR_SEPARATOR);
+
+ // Remove '/' if it appears on the end.
+ if (fullPath[fullPath.length - 1] == DIR_SEPARATOR &&
+ fullPath != DIR_SEPARATOR) {
+ fullPath = fullPath.substring(0, fullPath.length - 1);
+ }
+
+ return fullPath;
+ }
+
+ function fileEntryFromIdbEntry(fileEntry) {
+ // IDB won't save methods, so we need re-create the FileEntry.
+ var clonedFileEntry = new FileEntry(fileEntry.name, fileEntry.fullPath, fileEntry.fileSystem);
+ clonedFileEntry.file_ = fileEntry.file_;
+
+ return clonedFileEntry;
+ }
+
+ function readAs(what, fullPath, encoding, startPos, endPos, successCallback, errorCallback) {
+ exports.getFile(function(fileEntry) {
+ var fileReader = new FileReader(),
+ blob = fileEntry.file_.blob_.slice(startPos, endPos);
+
+ fileReader.onload = function(e) {
+ successCallback(e.target.result);
+ };
+
+ fileReader.onerror = errorCallback;
+
+ switch (what) {
+ case 'text':
+ fileReader.readAsText(blob, encoding);
+ break;
+ case 'dataURL':
+ fileReader.readAsDataURL(blob);
+ break;
+ case 'arrayBuffer':
+ fileReader.readAsArrayBuffer(blob);
+ break;
+ case 'binaryString':
+ fileReader.readAsBinaryString(blob);
+ break;
+ }
+
+ }, errorCallback, [null, fullPath]);
+ }
+
+/*** Core logic to handle IDB operations ***/
+
+ idb_.open = function(dbName, successCallback, errorCallback) {
+ var self = this;
+
+ // TODO: FF 12.0a1 isn't liking a db name with : in it.
+ var request = indexedDB.open(dbName.replace(':', '_')/*, 1 /*version*/);
+
+ request.onerror = errorCallback || onError;
+
+ request.onupgradeneeded = function(e) {
+ // First open was called or higher db version was used.
+
+ // console.log('onupgradeneeded: oldVersion:' + e.oldVersion,
+ // 'newVersion:' + e.newVersion);
+
+ self.db = e.target.result;
+ self.db.onerror = onError;
+
+ if (!self.db.objectStoreNames.contains(FILE_STORE_)) {
+ var store = self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/);
+ }
+ };
+
+ request.onsuccess = function(e) {
+ self.db = e.target.result;
+ self.db.onerror = onError;
+ successCallback(e);
+ };
+
+ request.onblocked = errorCallback || onError;
+ };
+
+ idb_.close = function() {
+ this.db.close();
+ this.db = null;
+ };
+
+ idb_.get = function(fullPath, successCallback, errorCallback) {
+ if (!this.db) {
+ return;
+ }
+
+ var tx = this.db.transaction([FILE_STORE_], 'readonly');
+
+ //var request = tx.objectStore(FILE_STORE_).get(fullPath);
+ var range = IDBKeyRange.bound(fullPath, fullPath + DIR_OPEN_BOUND,
+ false, true);
+ var request = tx.objectStore(FILE_STORE_).get(range);
+
+ tx.onabort = errorCallback || onError;
+ tx.oncomplete = function(e) {
+ successCallback(request.result);
+ };
+ };
+
+ idb_.getAllEntries = function(fullPath, successCallback, errorCallback) {
+ if (!this.db) {
+ return;
+ }
+
+ var results = [];
+
+ //var range = IDBKeyRange.lowerBound(fullPath, true);
+ //var range = IDBKeyRange.upperBound(fullPath, true);
+
+ // Treat the root entry special. Querying it returns all entries because
+ // they match '/'.
+ var range = null;
+ if (fullPath != DIR_SEPARATOR) {
+ //console.log(fullPath + '/', fullPath + DIR_OPEN_BOUND)
+ range = IDBKeyRange.bound(
+ fullPath + DIR_SEPARATOR, fullPath + DIR_OPEN_BOUND, false, true);
+ }
+
+ var tx = this.db.transaction([FILE_STORE_], 'readonly');
+ tx.onabort = errorCallback || onError;
+ tx.oncomplete = function(e) {
+ // TODO: figure out how to do be range queries instead of filtering result
+ // in memory :(
+ results = results.filter(function(val) {
+ var valPartsLen = val.fullPath.split(DIR_SEPARATOR).length;
+ var fullPathPartsLen = fullPath.split(DIR_SEPARATOR).length;
+
+ if (fullPath == DIR_SEPARATOR && valPartsLen < fullPathPartsLen + 1) {
+ // Hack to filter out entries in the root folder. This is inefficient
+ // because reading the entires of fs.root (e.g. '/') returns ALL
+ // results in the database, then filters out the entries not in '/'.
+ return val;
+ } else if (fullPath != DIR_SEPARATOR &&
+ valPartsLen == fullPathPartsLen + 1) {
+ // If this a subfolder and entry is a direct child, include it in
+ // the results. Otherwise, it's not an entry of this folder.
+ return val;
+ }
+ });
+
+ successCallback(results);
+ };
+
+ var request = tx.objectStore(FILE_STORE_).openCursor(range);
+
+ request.onsuccess = function(e) {
+ var cursor = e.target.result;
+ if (cursor) {
+ var val = cursor.value;
+
+ results.push(val.isFile ? fileEntryFromIdbEntry(val) : new DirectoryEntry(val.name, val.fullPath, val.fileSystem));
+ cursor['continue']();
+ }
+ };
+ };
+
+ idb_['delete'] = function(fullPath, successCallback, errorCallback) {
+ if (!this.db) {
+ return;
+ }
+
+ var tx = this.db.transaction([FILE_STORE_], 'readwrite');
+ tx.oncomplete = successCallback;
+ tx.onabort = errorCallback || onError;
+
+ //var request = tx.objectStore(FILE_STORE_).delete(fullPath);
+ var range = IDBKeyRange.bound(
+ fullPath, fullPath + DIR_OPEN_BOUND, false, true);
+ var request = tx.objectStore(FILE_STORE_)['delete'](range);
+ };
+
+ idb_.put = function(entry, successCallback, errorCallback) {
+ if (!this.db) {
+ return;
+ }
+
+ var tx = this.db.transaction([FILE_STORE_], 'readwrite');
+ tx.onabort = errorCallback || onError;
+ tx.oncomplete = function(e) {
+ // TODO: Error is thrown if we pass the request event back instead.
+ successCallback(entry);
+ };
+
+ var request = tx.objectStore(FILE_STORE_).put(entry, entry.fullPath);
+ };
+
+ // Global error handler. Errors bubble from request, to transaction, to db.
+ function onError(e) {
+ switch (e.target.errorCode) {
+ case 12:
+ console.log('Error - Attempt to open db with a lower version than the ' +
+ 'current one.');
+ break;
+ default:
+ console.log('errorCode: ' + e.target.errorCode);
+ }
+
+ console.log(e, e.code, e.message);
+ }
+
+// Clean up.
+// TODO: Is there a place for this?
+// global.addEventListener('beforeunload', function(e) {
+// idb_.db && idb_.db.close();
+// }, false);
+
+})(module.exports, window);
+
+require("cordova/exec/proxy").add("File", module.exports);
[2/9] git commit: CB-285 Docs for cordova.file.*Directory properties
Posted by dr...@apache.org.
CB-285 Docs for cordova.file.*Directory properties
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/f92017f2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/f92017f2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/f92017f2
Branch: refs/heads/pluggable_webview
Commit: f92017f25d4d8b8154bfc829fce812211acdee7b
Parents: 856b8c5
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu May 15 21:17:46 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu May 15 21:17:46 2014 -0400
----------------------------------------------------------------------
doc/index.md | 71 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 50 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/f92017f2/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 11637b1..c24e11a 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -39,35 +39,33 @@ on the subject. For an overview of other storage options, refer to Cordova's
\* _These platforms do not support `FileReader.readAsArrayBuffer` nor `FileWriter.write(blob)`._
-## Configuring the Plugin
+## Where to Store Files
-The set of available filesystems can be configured per-platform. Both iOS and
-Android recognize a <preference> tag in `config.xml` which names the
-filesystems to be installed. By default, all file-system roots are enabled.
+As of v1.2.0, URLs to important file-system directories are provided.
+Each URL is in the form _file:///path/to/spot/_, and can be converted to a
+`DirectoryEntry` using `window.resolveLocalFileSystemURL()`.
- <preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
- <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
+`cordova.file.applicationDirectory` - Read-only directory where the application is installed. (_iOS_, _Android_)
-### Android
+`cordova.file.applicationStorageDirectory` - Root of app's private writable storage. (_iOS_, _Android_)
-* files: The application's internal file storage directory
-* files-external: The application's external file storage directory
-* sdcard: The global external file storage directory (this is the root of the SD card, if one is installed). You must have the `android.permission.WRITE_EXTERNAL_STORAGE` permission to use this.
-* cache: The application's internal cache directory
-* cache-external: The application's external cache directory
-* root: The entire device filesystem
+`cordova.file.dataDirectory` - Where to put app-specific data files. (_iOS_, _Android_)
-Android also supports a special filesystem named "documents", which represents a "/Documents/" subdirectory within the "files" filesystem.
+`cordova.file.cacheDirectory` - Cached files that should survive app restarts. Apps should not rely on the OS to delete files in here. (_iOS_, _Android_)
-### iOS
+`cordova.file.externalApplicationStorageDirectory` - Application space on external storage. (_iOS_, _Android_)
-* library: The application's Library directory
-* documents: The application's Documents directory
-* cache: The application's Cache directory
-* bundle: The application's bundle; the location of the app itself on disk (read-only)
-* root: The entire device filesystem
+`cordova.file.externalDataDirectory` - Where to put app-specific data files on external storage. (_Android_)
-By default, the library and documents directories can be synced to iCloud. You can also request two additional filesystems, "library-nosync" and "documents-nosync", which represent a special non-synced directory within the Library or Documents filesystem.
+`cordova.file.externalCacheDirectory` - Application cache on external storage. (_Android_)
+
+`cordova.file.externalRootDirectory` - External storage (SD card) root. (_Android_)
+
+`cordova.file.tempDirectory` - Temp directory that the OS can clear at will. (_iOS_)
+
+`cordova.file.syncedDataDirectory` - Holds app-specific files that should be synced (e.g. to iCloud). (_iOS_)
+
+`cordova.file.documentsDirectory` - Files private to the app, but that are meaningful to other applciations (e.g. Office files). (_iOS_)
## Android Quirks
@@ -198,3 +196,34 @@ When an error is thrown, one of the following codes will be used.
* 10 = QUOTA_EXCEEDED_ERR
* 11 = TYPE_MISMATCH_ERR
* 12 = PATH_EXISTS_ERR
+
+## Configuring the Plugin (Optional)
+
+The set of available filesystems can be configured per-platform. Both iOS and
+Android recognize a <preference> tag in `config.xml` which names the
+filesystems to be installed. By default, all file-system roots are enabled.
+
+ <preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
+ <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
+
+### Android
+
+* files: The application's internal file storage directory
+* files-external: The application's external file storage directory
+* sdcard: The global external file storage directory (this is the root of the SD card, if one is installed). You must have the `android.permission.WRITE_EXTERNAL_STORAGE` permission to use this.
+* cache: The application's internal cache directory
+* cache-external: The application's external cache directory
+* root: The entire device filesystem
+
+Android also supports a special filesystem named "documents", which represents a "/Documents/" subdirectory within the "files" filesystem.
+
+### iOS
+
+* library: The application's Library directory
+* documents: The application's Documents directory
+* cache: The application's Cache directory
+* bundle: The application's bundle; the location of the app itself on disk (read-only)
+* root: The entire device filesystem
+
+By default, the library and documents directories can be synced to iCloud. You can also request two additional filesystems, "library-nosync" and "documents-nosync", which represent a special non-synced directory within the Library or Documents filesystem.
+
[9/9] git commit: Merge branch 'master' into pluggable_webview pick
up fileextras
Posted by dr...@apache.org.
Merge branch 'master' into pluggable_webview
pick up fileextras
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/79cebdaf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/79cebdaf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/79cebdaf
Branch: refs/heads/pluggable_webview
Commit: 79cebdafbc0cad69ba089103b94f5e7aefa0ef4b
Parents: 1ef80cb a9b6b40
Author: David Kemp <dr...@chromium.org>
Authored: Wed Jun 4 13:03:59 2014 -0400
Committer: David Kemp <dr...@chromium.org>
Committed: Wed Jun 4 13:03:59 2014 -0400
----------------------------------------------------------------------
CONTRIBUTING.md | 21 ++
doc/index.md | 95 ++++--
plugin.xml | 16 +
src/android/FileUtils.java | 20 ++
src/firefoxos/FileProxy.js | 680 ++++++++++++++++++++++++++++++++++++++
src/ios/CDVFile.m | 30 ++
src/ios/CDVLocalFilesystem.m | 22 +-
www/fileSystemPaths.js | 61 ++++
8 files changed, 910 insertions(+), 35 deletions(-)
----------------------------------------------------------------------