CB-7161 [BlackBerry10] Add file system directory paths
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/75fcc925 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/75fcc925 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/75fcc925 Branch: refs/heads/master Commit: 75fcc9256ac7a8907c5c7862261fc7cc90d02fea Parents: 913b9a3 Author: Bryan Higgins <[email protected]> Authored: Thu Jul 17 15:22:22 2014 -0400 Committer: Bryan Higgins <[email protected]> Committed: Fri Jul 18 14:16:45 2014 -0400 ---------------------------------------------------------------------- doc/index.md | 25 +++++++++++++++++----- plugin.xml | 5 ++++- src/blackberry10/index.js | 13 +++++++++++ tests/tests.js | 2 ++ www/blackberry10/info.js | 2 +- www/blackberry10/resolveLocalFileSystemURI.js | 2 +- www/fileSystemPaths.js | 4 +++- 7 files changed, 44 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/doc/index.md ---------------------------------------------------------------------- diff --git a/doc/index.md b/doc/index.md index 0b4d3cb..a8bddaa 100644 --- a/doc/index.md +++ b/doc/index.md @@ -63,22 +63,22 @@ Each URL is in the form _file:///path/to/spot/_, and can be converted to a `DirectoryEntry` using `window.resolveLocalFileSystemURL()`. * `cordova.file.applicationDirectory` - Read-only directory where the application - is installed. (_iOS_, _Android_) + is installed. (_iOS_, _Android_, _BlackBerry 10_) * `cordova.file.applicationStorageDirectory` - Root directory of the application's sandbox; on iOS this location is read-only (but specific subdirectories [like `/Documents`] are read-write). All data contained within is private to the app. ( - _iOS_, _Android_) + _iOS_, _Android_, _BlackBerry 10_) * `cordova.file.dataDirectory` - Persistent and private data storage within the application's sandbox using internal memory (on Android, if you need to use external memory, use `.externalDataDirectory`). On iOS, this directory is not - synced with iCloud (use `.syncedDataDirectory`). (_iOS_, _Android_) + synced with iCloud (use `.syncedDataDirectory`). (_iOS_, _Android_, _BlackBerry 10_) * `cordova.file.cacheDirectory` - Directory for cached data files or any files that your app can re-create easily. The OS may delete these files when the device runs low on storage, nevertheless, apps should not rely on the OS to delete files - in here. (_iOS_, _Android_) + in here. (_iOS_, _Android_, _BlackBerry 10_) * `cordova.file.externalApplicationStorageDirectory` - Application space on external storage. (_Android_) @@ -89,7 +89,7 @@ Each URL is in the form _file:///path/to/spot/_, and can be converted to a * `cordova.file.externalCacheDirectory` - Application cache on external storage. (_Android_) -* `cordova.file.externalRootDirectory` - External storage (SD card) root. (_Android_) +* `cordova.file.externalRootDirectory` - External storage (SD card) root. (_Android_, _BlackBerry 10_) * `cordova.file.tempDirectory` - Temp directory that the OS can clear at will. Do not rely on the OS to clear this directory; your app should always remove files as @@ -101,6 +101,8 @@ Each URL is in the form _file:///path/to/spot/_, and can be converted to a * `cordova.file.documentsDirectory` - Files private to the app, but that are meaningful to other application (e.g. Office files). (_iOS_) +* `cordova.file.sharedDirectory` - Files globally available to all applications (_BlackBerry 10_) + ## File System Layouts Although technically an implementation detail, it can be very useful to know how @@ -160,6 +162,19 @@ the `cordova.file.*` properties map to physical paths on a real device. **Note**: If external storage can't be mounted, the `cordova.file.external*` properties are `null`. +### BlackBerry 10 File System Layout + +| Device Path | `cordova.file.*` | r/w? | persistent? | OS clears | private | +|:-------------------------------------------------------------|:----------------------------|:----:|:-----------:|:---------:|:-------:| +| `file:///accounts/1000/appdata/<app id>/` | applicationStorageDirectory | r/o | N/A | N/A | Yes | +| `app/native` | applicationDirectory | r/o | N/A | N/A | Yes | +| `data/webviews/webfs/temporary/local__0` | cacheDirectory | r/w | No | Yes | Yes | +| `data/webviews/webfs/persistent/local__0` | dataDirectory | r/w | Yes | No | Yes | +| `file:///accounts/1000/removable/sdcard` | externalRemovableDirectory | r/w | Yes | No | No | +| `file:///accounts/1000/shared` | sharedDirectory | r/w | Yes | No | No | + +*Note*: When application is deployed to work perimeter, all paths are relative to /accounts/1000-enterprise. + ## Android Quirks ### Android Persistent storage location http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index 4e1c233..85e6631 100644 --- a/plugin.xml +++ b/plugin.xml @@ -278,6 +278,9 @@ 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" /> + </js-module> <js-module src="www/blackberry10/copyTo.js" name="copyToProxy" /> <js-module src="www/blackberry10/getDirectory.js" name="getDirectoryProxy" /> <js-module src="www/blackberry10/getFile.js" name="getFileProxy" /> @@ -298,7 +301,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" <js-module src="www/blackberry10/setMetadata.js" name="setMetadataProxy" /> <js-module src="www/blackberry10/truncate.js" name="truncateProxy" /> <js-module src="www/blackberry10/write.js" name="writeProxy" /> - <source-file src="src/blackberry10/index.js" /> + <source-file src="src/blackberry10/index.js" target-dir="File" /> </platform> <!-- windows8 --> http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js index e8b597c..913ab30 100644 --- a/src/blackberry10/index.js +++ b/src/blackberry10/index.js @@ -27,5 +27,18 @@ module.exports = { getHomePath: function (success, fail, args, env) { var homeDir = window.qnx.webplatform.getApplication().getEnv("HOME"); new PluginResult(args, env).ok(homeDir); + }, + + requestAllPaths: function (success, fail, args, env) { + var homeDir = 'file://' + window.qnx.webplatform.getApplication().getEnv("HOME").replace('/data', ''), + paths = { + applicationDirectory: homeDir + '/app/native/', + applicationStorageDirectory: homeDir + '/', + dataDirectory: homeDir + '/data/webviews/webfs/persistent/local__0/', + cacheDirectory: homeDir + '/data/webviews/webfs/temporary/local__0/', + externalRootDirectory: 'file:///accounts/1000/removable/sdcard/', + sharedDirectory: homeDir + '/shared/' + }; + success(paths); } }; http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/tests/tests.js ---------------------------------------------------------------------- diff --git a/tests/tests.js b/tests/tests.js index ec79cf3..76c8a90 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -3029,6 +3029,8 @@ exports.defineAutoTests = function () { var expectedPaths = ['applicationDirectory', 'applicationStorageDirectory', 'dataDirectory', 'cacheDirectory']; if (cordova.platformId == 'android') { expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory'); + } else if (cordova.platformId == 'blackberry10') { + expectedPaths.push('externalRootDirectory', 'sharedDirectory'); } else if (cordova.platformId == 'ios') { expectedPaths.push('syncedDataDirectory', 'documentsDirectory', 'tempDirectory'); } else { http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/www/blackberry10/info.js ---------------------------------------------------------------------- diff --git a/www/blackberry10/info.js b/www/blackberry10/info.js index 716dba2..63f9504 100644 --- a/www/blackberry10/info.js +++ b/www/blackberry10/info.js @@ -44,7 +44,7 @@ cordova.exec( function () { console.error('Unable to determine local storage file path'); }, - 'org.apache.cordova.file', + 'File', 'getHomePath', false ); http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/www/blackberry10/resolveLocalFileSystemURI.js ---------------------------------------------------------------------- diff --git a/www/blackberry10/resolveLocalFileSystemURI.js b/www/blackberry10/resolveLocalFileSystemURI.js index a29fe2f..058d76a 100644 --- a/www/blackberry10/resolveLocalFileSystemURI.js +++ b/www/blackberry10/resolveLocalFileSystemURI.js @@ -123,7 +123,7 @@ function resolve(success, fail, path, fsType, sandbox, options, size) { requestAnimationFrame(function () { resolveNative(success, fail, path, fsType, options, size); }); - }, fail, 'org.apache.cordova.file', 'setSandbox', [sandbox], false); + }, fail, 'File', 'setSandbox', [sandbox], false); }); } } http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/75fcc925/www/fileSystemPaths.js ---------------------------------------------------------------------- diff --git a/www/fileSystemPaths.js b/www/fileSystemPaths.js index 8ef0bb8..c332f48 100644 --- a/www/fileSystemPaths.js +++ b/www/fileSystemPaths.js @@ -45,7 +45,9 @@ exports.file = { // 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 + documentsDirectory: null, + // BlackBerry10: Files globally available to all apps + sharedDirectory: null }; channel.waitForInitialization('onFileSystemPathsReady');
